python-texttable: update to 1.3.1
[void-packages.git] / srcpkgs / xbps-triggers / files / register-shell
blobec0873697ea5f1a6abee6a1fa17c33ed3f06b126
1 #!/bin/sh
3 # Registers or unregisters a shell in /etc/shells.
5 # Arguments: $ACTION = [run/targets]
6 # $TARGET = [post-install/post-remove]
7 # $PKGNAME
8 # $VERSION
9 # $UPDATE = [yes/no]
11 ACTION="$1"
12 TARGET="$2"
13 PKGNAME="$3"
14 VERSION="$4"
15 UPDATE="$5"
17 export PATH="$PATH:/usr/local/bin"
19 case "$ACTION" in
20 targets)
21 echo "post-install post-remove"
23 run)
24 [ "$TARGET" != "post-install" -a "$TARGET" != "post-remove" ] && exit 1
26 if [ -z "$register_shell" ]; then
27 echo "Trigger register-shell: empty \$register_shell!"
28 exit 1
31 case "$TARGET" in
32 post-install)
33 if [ ! -f etc/shells ]; then
34 for f in ${register_shell}; do
35 echo $f >> etc/shells
36 echo "Registered $f into /etc/shells."
37 done
38 chmod 644 etc/shells
39 else
40 for f in ${register_shell}; do
41 if ! grep -q $f etc/shells; then
42 echo $f >> etc/shells
43 echo -n "Registered $f into "
44 echo "/etc/shells."
46 done
49 post-remove)
50 if [ -f etc/shells ]; then
51 for f in ${register_shell}; do
52 if grep -q $f etc/shells; then
53 shell=$(echo $f|sed "s|\\/|\\\/|g")
54 sed -i -e "/$shell/d" etc/shells
55 echo -n "Unregistered $f from "
56 echo "/etc/shells."
58 done
61 esac
64 exit 1
66 esac
68 exit 0