2009-03-14 07:32:01 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Registers or unregisters a shell in /etc/shells.
|
|
|
|
#
|
|
|
|
# Arguments: $1 = action [run/targets]
|
|
|
|
# $2 = target [post-install]
|
|
|
|
# $3 = pkgname
|
|
|
|
# $4 = version
|
|
|
|
#
|
2009-05-19 02:13:58 +02:00
|
|
|
shells_file=var/db/xbps/metadata/$3/shells
|
2009-03-14 07:32:01 +01:00
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
targets)
|
|
|
|
echo "post-install post-remove"
|
|
|
|
;;
|
|
|
|
run)
|
|
|
|
[ "$2" != "post-install" -a "$2" != "post-remove" ] && exit 1
|
|
|
|
[ ! -f ${shells_file} ] && exit 1
|
|
|
|
|
|
|
|
case "$2" in
|
|
|
|
post-install)
|
2009-05-19 02:13:58 +02:00
|
|
|
if [ ! -f etc/shells ]; then
|
2009-03-14 07:32:01 +01:00
|
|
|
cat ${shells_file} | while read line; do
|
2009-05-19 02:13:58 +02:00
|
|
|
echo $line >> etc/shells
|
2009-03-14 07:32:01 +01:00
|
|
|
echo "Registered $line into /etc/shells."
|
|
|
|
done
|
2009-05-19 02:13:58 +02:00
|
|
|
chmod 644 etc/shells
|
2009-03-14 07:32:01 +01:00
|
|
|
else
|
|
|
|
cat ${shells_file} | while read line; do
|
2009-05-19 02:13:58 +02:00
|
|
|
if ! grep -q $line etc/shells; then
|
|
|
|
echo $line >> etc/shells
|
2009-03-14 08:41:45 +01:00
|
|
|
echo -n "Registered $line into "
|
|
|
|
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-03-14 07:32:01 +01:00
|
|
|
cat ${shells_file} | while read line; do
|
2009-05-19 02:13:58 +02:00
|
|
|
if grep -q $line etc/shells; then
|
2009-03-14 08:41:45 +01:00
|
|
|
shell=$(echo $line|sed "s|\\/|\\\/|g")
|
2009-05-19 02:13:58 +02:00
|
|
|
sed -i -e "/$shell/d" etc/shells
|
2009-03-14 08:41:45 +01:00
|
|
|
echo -n "Unregistered $line from "
|
|
|
|
echo "/etc/shells."
|
2009-03-14 07:32:01 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|