Add a trigger to (un)register shells from /etc/shells.
--HG-- extra : convert_revision : 6f82e9b19f880b388d5e800e1d159f4f3287ab26
This commit is contained in:
58
triggers/register-shell
Executable file
58
triggers/register-shell
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Registers or unregisters a shell in /etc/shells.
|
||||
#
|
||||
# Arguments: $1 = action [run/targets]
|
||||
# $2 = target [post-install]
|
||||
# $3 = pkgname
|
||||
# $4 = version
|
||||
#
|
||||
trigger="register-shell"
|
||||
shells_file="./var/db/xbps/metadata/$3/shells"
|
||||
|
||||
case "$1" in
|
||||
targets)
|
||||
echo "post-install post-remove"
|
||||
;;
|
||||
run)
|
||||
[ "$2" != "post-install" -a "$2" != "post-remove" ] && exit 1
|
||||
[ ! -f ${shells_file} ] && exit 1
|
||||
|
||||
echo "Running $trigger trigger..."
|
||||
|
||||
case "$2" in
|
||||
post-install)
|
||||
if [ ! -f ./etc/shells ]; then
|
||||
cat ${shells_file} | while read line; do
|
||||
echo $line >> ./etc/shells
|
||||
echo "Registered $line into /etc/shells."
|
||||
done
|
||||
chmod 644 ./etc/shells
|
||||
else
|
||||
cat ${shells_file} | while read line; do
|
||||
if ! grep -q $line ./etc/shells; then
|
||||
echo $line >> ./etc/shells
|
||||
echo "Registered $line into /etc/shells."
|
||||
fi
|
||||
done
|
||||
fi
|
||||
;;
|
||||
post-remove)
|
||||
if [ -f ./etc/shells ]; then
|
||||
cat ${shells_file} | while read line; do
|
||||
if grep -q $line ./etc/shells; then
|
||||
shell=$(echo $line | sed "s|\\/|\\\/|g")
|
||||
sed -i -e "/$shell/d" ./etc/shells
|
||||
echo "Unregistered $line from /etc/shells."
|
||||
fi
|
||||
done
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user