-
Notifications
You must be signed in to change notification settings - Fork 3
/
chsh
executable file
·83 lines (74 loc) · 1.64 KB
/
chsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/QOpenSys/pkgs/bin/bash
declare -a shell_list=("/QOpenSys/pkgs/bin/bash" "/QOpenSys/usr/bin/csh" "/QOpenSys/usr/bin/ksh" "/QOpenSys/usr/bin/psh" "/QOpenSys/usr/bin/sh" "/QOpenSys/usr/bin/bsh" "/QOpenSys/pkgs/bin/zsh" "/QOpenSys/pkgs/bin/csh" "/QOpenSys/pkgs/bin/tcsh")
USER=""
SHELL2SET=""
function usage {
echo "chsh [-s shell] [-l] [-u] [-v] [username]"
exit 0
}
function list {
for i in "${shell_list[@]}"
do
echo "$i"
done
exit 0
}
function validate_shell {
if [ ! -f "$1" ] ; then
echo "ERROR!! specified shell does not exist: $1" >&2
exit 8
fi
for i in "${shell_list[@]}"
do
if [ "$i" == "$1" ] ; then
return 0
fi
done
echo "ERROR!! specified shell not allowed: $1" >&2
exit 7
}
while [[ $# -gt 0 ]]
do
arg="$1"
case $arg in
-l)
list
;;
-u|-h)
usage
;;
-v|--version)
LIBPATH="$2"
echo "Version 1.0"
exit 0
;;
-s)
SHELL2SET="$2"
shift
shift
;;
*)
if [ -z "$USER" ];
then
USER="$1"
shift
else
echo "ERROR!! Improper syntax" >&2
echo "" >&2
usage
fi
;;
esac
done
if [ "$SHELL2SET" == "" ] ; then
echo "ERROR!! Shell not specified." >&2
exit 8
fi
if [ "$USER" == "" ] ; then
USER="*CURRENT" #effectively making this an option parm, defaulting to *CURRENT
fi
if [[ "$SHELL2SET" != /* ]]; then
SHELL2SET="/QOpenSys/pkgs/bin/$SHELL2SET"
fi
validate_shell "$SHELL2SET"
exec /usr/bin/qsh -c "/usr/bin/db2 \"CALL QSYS2.SET_PASE_SHELL_INFO('$USER', '$SHELL2SET')\" "