mirror of
https://github.com/xHyroM/void-packages.git
synced 2024-11-14 02:48:06 +01:00
67 lines
1.2 KiB
Text
67 lines
1.2 KiB
Text
|
#!/bin/sh
|
||
|
#
|
||
|
# Registers or unregisters a shell in /etc/shells.
|
||
|
#
|
||
|
# Arguments: $ACTION = [run/targets]
|
||
|
# $TARGET = [post-install/post-remove]
|
||
|
# $PKGNAME
|
||
|
# $VERSION
|
||
|
# $UPDATE = [yes/no]
|
||
|
#
|
||
|
ACTION="$1"
|
||
|
TARGET="$2"
|
||
|
PKGNAME="$3"
|
||
|
VERSION="$4"
|
||
|
UPDATE="$5"
|
||
|
|
||
|
case "$ACTION" in
|
||
|
targets)
|
||
|
echo "post-install post-remove"
|
||
|
;;
|
||
|
run)
|
||
|
[ "$TARGET" != "post-install" -a "$TARGET" != "post-remove" ] && exit 1
|
||
|
|
||
|
if [ -z "$register_shell" ]; then
|
||
|
echo "Trigger register-shell: empty \$register_shell!"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
case "$TARGET" in
|
||
|
post-install)
|
||
|
if [ ! -f etc/shells ]; then
|
||
|
for f in ${register_shell}; do
|
||
|
echo $f >> etc/shells
|
||
|
echo "Registered $f into /etc/shells."
|
||
|
done
|
||
|
chmod 644 etc/shells
|
||
|
else
|
||
|
for f in ${register_shell}; do
|
||
|
if ! grep -qFx "$f" etc/shells; then
|
||
|
echo "$f" >> etc/shells
|
||
|
echo -n "Registered $f into "
|
||
|
echo "/etc/shells."
|
||
|
fi
|
||
|
done
|
||
|
fi
|
||
|
;;
|
||
|
post-remove)
|
||
|
if [ -f etc/shells ]; then
|
||
|
for f in ${register_shell}; do
|
||
|
if grep -q $f etc/shells; then
|
||
|
shell=$(echo $f|sed "s|\\/|\\\/|g")
|
||
|
sed -i -e "/$shell/d" etc/shells
|
||
|
echo -n "Unregistered $f from "
|
||
|
echo "/etc/shells."
|
||
|
fi
|
||
|
done
|
||
|
fi
|
||
|
;;
|
||
|
esac
|
||
|
;;
|
||
|
*)
|
||
|
exit 1
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
exit 0
|