-
Notifications
You must be signed in to change notification settings - Fork 1
/
livesettings
executable file
·107 lines (91 loc) · 3.07 KB
/
livesettings
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/sh
# script for live-settings
set -e
if [ -f /etc/default/distro ]; then
. /etc/default/distro
fi
all_users_common_settings() {
# we run all users settings
if [ -f /usr/share/${CODENAME_SAFE}-common-livesettings/all-users-settings ] ;then
/usr/share/${CODENAME_SAFE}-common-livesettings/all-users-settings
fi
}
gen_adduser_conf() {
sed -i 's/^DIR_MODE=.*/DIR_MODE=0700/' /etc/adduser.conf
unset GROUPS
for g in ${FLL_LIVE_USER_GROUPS}; do
if getent group ${g} >/dev/null; then
GROUPS="${GROUPS} ${g}"
fi
done
sed -i -e 's/^#\?\(EXTRA_GROUPS=\).*/\1"'"${GROUPS# }"'"/' \
-e 's/^#\?\(ADD_EXTRA_GROUPS=\).*/\11/' \
/etc/adduser.conf
}
add_live_user() {
adduser --gecos ${FLL_LIVE_USER} ${FLL_LIVE_USER} \
<< EOF
live
live
EOF
}
user_home_common_settings() {
if [ -f /usr/share/${CODENAME_SAFE}-common-livesettings/user-home-settings ] ;then
su "${FLL_LIVE_USER}" -c /usr/share/${CODENAME_SAFE}-common-livesettings/user-home-settings
fi
}
hack_bashrc() {
grep -s -q 'alias su' /home/${FLL_LIVE_USER}/.bashrc && return 0
printf "\nalias su='sudo su'\n" \
>> /home/${FLL_LIVE_USER}/.bashrc
chown ${FLL_LIVE_USER} /home/${FLL_LIVE_USER}/.bashrc
}
setup_calamares() {
mkdir -p /home/${FLL_LIVE_USER}/Desktop
if [ -e /usr/share/siduction/calamares.desktop ]; then
cp -f /usr/share/siduction/calamares.desktop /home/${FLL_LIVE_USER}/Desktop
cp -f /usr/share/siduction/calamares.desktop /usr/share/applications/
#sed -i 's/pkexec calamares/sudo -E calamares/' /home/${FLL_LIVE_USER}/Desktop/calamares.desktop
chmod +x /home/${FLL_LIVE_USER}/Desktop/calamares.desktop
fi
if [ -e /usr/share/siduction/chroot-helper.desktop ]; then
cp -f /usr/share/siduction/chroot-helper.desktop /home/${FLL_LIVE_USER}/Desktop
chmod +x /home/${FLL_LIVE_USER}/Desktop/chroot-helper.desktop
fi
}
chown_user_dir() {
# central point setting the ownership of users home
chown -R ${FLL_LIVE_USER} /home/${FLL_LIVE_USER}
}
case "$1" in
configure)
all_users_common_settings
if [ -d /home/${FLL_LIVE_USER} ]; then
echo " "
echo "*************************************"
echo " "
echo " Something went terrible wrong: "
echo " /home/$FLL_LIVE_USER exist! "
echo " That should not be, please check "
echo " involved packages and pyfll. "
echo " This dir must not be created by "
echo " somehow or somewhat - only adduser "
echo " should do so. "
echo " "
echo "*************************************"
echo " "
exit 1
fi
gen_adduser_conf
add_live_user
setup_calamares
hack_bashrc
user_home_common_settings
chown_user_dir
;;
*)
echo "livesettings called with unknown argument \`$1'" >&2
exit 1
;;
esac
exit 0