/
mod_profile
executable file
·72 lines (72 loc) · 1.27 KB
/
mod_profile
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
# MODFS_MODSCRIPT
# SPDX-License-Identifier: GPL-2.0-or-later
# SUPPORTS precheck postcheck install language(en,de)
# NAME enable custom profile extension
# DESCRIPTION en
# include /var/custom/etc/profile in /etc/profile
# DESCRIPTION de
# Kommandos in /var/custom/etc/profile in /etc/profile einschließen
# EOH
#
# process parameters
#
language=$1
rootdir=$2
mode=$3
step=$4
[ ${#4} -eq 0 ] && exit 59 # invalid call
#
# execute the requested step
#
rc=0
modfile="$rootdir/etc/profile"
insertline="[ -f /var/custom/etc/profile ] && . /var/custom/etc/profile"
find_line()
{
local line rc=0
line="$(sed -n -e "\\#$insertline#p" $modfile)"
[ ${#line} -gt 0 ] && rc=0 || rc=1
return $rc
}
case $step in
precheck)
find_line
rc=$?
if [ $rc -eq 0 ]; then
case "$language" in
de)
echo "Die Modifikation wurde bereit angewendet."
;;
*)
echo "The startup file is modified already."
;;
esac
rc=1
else
rc=0
fi
;;
postcheck)
find_line
rc=$?
if [ $rc -eq 1 ]; then
case "$language" in
de)
echo "Die Modifikation war nicht erfolgreich."
;;
*)
echo "The startup file seems to be unmodified."
;;
esac
rc=1
fi
;;
install)
sed -e "\$a$insertline" -i "$modfile"
rc=0
;;
*)
rc=59
;;
esac
exit $rc