2009-12-11 07:23:49 +01:00
|
|
|
#!/bin/sh -e
|
2009-03-14 07:32:01 +01:00
|
|
|
#
|
|
|
|
# Registers or unregisters a shell in /etc/shells.
|
|
|
|
#
|
2009-12-11 07:23:49 +01:00
|
|
|
# Arguments: $ACTION = [run/targets]
|
|
|
|
# $TARGET = [post-install/post-remove]
|
|
|
|
# $PKGNAME
|
|
|
|
# $VERSION
|
|
|
|
# $UPDATE = [yes/no]
|
2009-03-14 07:32:01 +01:00
|
|
|
#
|
2009-12-11 07:23:49 +01:00
|
|
|
ACTION="$1"
|
|
|
|
TARGET="$2"
|
|
|
|
PKGNAME="$3"
|
|
|
|
VERSION="$4"
|
|
|
|
UPDATE="$5"
|
2009-03-14 07:32:01 +01:00
|
|
|
|
2009-12-11 07:23:49 +01:00
|
|
|
case "$ACTION" in
|
2009-03-14 07:32:01 +01:00
|
|
|
targets)
|
|
|
|
echo "post-install post-remove"
|
|
|
|
;;
|
|
|
|
run)
|
2009-12-11 07:23:49 +01:00
|
|
|
[ "$TARGET" != "post-install" -a "$TARGET" != "post-remove" ] && exit 1
|
2009-07-30 12:34:31 +02:00
|
|
|
|
|
|
|
if [ -z "$register_shell" ]; then
|
|
|
|
echo "Trigger register-shell: empty \$register_shell!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2009-03-14 07:32:01 +01:00
|
|
|
|
2009-12-11 07:23:49 +01:00
|
|
|
case "$TARGET" in
|
2009-03-14 07:32:01 +01:00
|
|
|
post-install)
|
2009-05-19 02:13:58 +02:00
|
|
|
if [ ! -f etc/shells ]; then
|
2009-07-30 12:34:31 +02:00
|
|
|
for f in ${register_shell}; do
|
|
|
|
echo $f >> etc/shells
|
|
|
|
echo "Registered $f into /etc/shells."
|
2009-03-14 07:32:01 +01:00
|
|
|
done
|
2009-05-19 02:13:58 +02:00
|
|
|
chmod 644 etc/shells
|
2009-03-14 07:32:01 +01:00
|
|
|
else
|
2009-07-30 12:34:31 +02:00
|
|
|
for f in ${register_shell}; do
|
|
|
|
if ! grep -q $f etc/shells; then
|
|
|
|
echo $f >> etc/shells
|
|
|
|
echo -n "Registered $f into "
|
2009-03-14 08:41:45 +01:00
|
|
|
echo "/etc/shells."
|
2009-03-14 07:32:01 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
post-remove)
|
2009-05-19 02:13:58 +02:00
|
|
|
if [ -f etc/shells ]; then
|
2009-07-30 12:34:31 +02:00
|
|
|
for f in ${register_shell}; do
|
|
|
|
if grep -q $f etc/shells; then
|
|
|
|
shell=$(echo $f|sed "s|\\/|\\\/|g")
|
2009-05-19 02:13:58 +02:00
|
|
|
sed -i -e "/$shell/d" etc/shells
|
2009-07-30 12:34:31 +02:00
|
|
|
echo -n "Unregistered $f from "
|
2009-03-14 08:41:45 +01:00
|
|
|
echo "/etc/shells."
|
2009-03-14 07:32:01 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|