-
-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathmodule_desktop.sh
More file actions
198 lines (183 loc) · 5.05 KB
/
module_desktop.sh
File metadata and controls
198 lines (183 loc) · 5.05 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
module_options+=(
["module_desktop,author"]="@igorpecovnik"
["module_desktop,feature"]="module_desktop"
["module_desktop,desc"]="XFCE desktop packages"
["module_desktop,example"]="install remove disable enable status auto manual login help"
["module_desktop,status"]="Active"
["module_desktop,arch"]="x86-64"
)
#
# Module install and configure desktop
#
function module_desktop() {
local title="test"
local condition=$(which "$title" 2>/dev/null)
# get user who executed this script
if [ $SUDO_USER ]; then local user=$SUDO_USER; else local user=$(whoami); fi
# read additional parameters from command line
local parameter
IFS=' ' read -r -a parameter <<< "${2}"
for feature in de; do
for selected in ${parameter[@]}; do
IFS='=' read -r -a split <<< "${selected}"
[[ ${split[0]} == $feature ]] && eval "$feature=${split[1]}"
done
done
local de="${de:-xfce}" # DE
# Convert the example string to an array
local commands
IFS=' ' read -r -a commands <<< "${module_options["module_desktop,example"]}"
case "$1" in
"${commands[0]}")
# Add APA development repository - this will be moved to main repo once it gets out of testing phase
rm /etc/apt/sources.list.d/armbian-apa.list
tee /etc/apt/sources.list.d/armbian-apa.sources > /dev/null <<- 'EOT'
Types: deb
URIs: https://github.armbian.com/apa
Suites: current
Components: main
Signed-By: /usr/share/keyrings/armbian.gpg
EOT
# update package list
pkg_update
# Install desktop package
pkg_install armbian-desktop-${de}
# add user to groups
for additionalgroup in sudo netdev audio video dialout plugdev input bluetooth systemd-journal ssh; do
usermod -aG ${additionalgroup} ${user} 2> /dev/null
done
# set up profile sync daemon on desktop systems
which psd > /dev/null 2>&1
if [[ $? -eq 0 && -z $(grep overlay-helper /etc/sudoers) ]]; then
echo "${user} ALL=(ALL) NOPASSWD: /usr/bin/psd-overlay-helper" >> /etc/sudoers
touch /home/${user}/.activate_psd
fi
# update skel
update_skel
# stop display managers in case we are switching them
if srv_active gdm3; then
srv_stop gdm3
elif srv_active lightdm; then
srv_stop lightdm
elif srv_active sddm; then
srv_stop sddm
fi
# start new default display manager
srv_restart display-manager
# enable auto login
${module_options["module_desktop,feature"]} ${commands[5]}
;;
"${commands[1]}")
# disable auto login
${module_options["module_desktop,feature"]} ${commands[6]}
# remove destkop
srv_stop display-manager
pkg_remove ${PACKAGES}
pkg_remove armbian-${DISTROID}-desktop-${de}
;;
"${commands[2]}")
# disable
srv_stop display-manager
srv_disable display-manager
;;
"${commands[3]}")
# enable
srv_enable display-manager
srv_start display-manager
;;
"${commands[4]}")
# status
case "$de" in
gnome)
if srv_active gdm3; then
return 0
else
return 1
fi
;;
kde-neon)
if srv_active sddm; then
return 0
else
return 1
fi
;;
*)
if srv_active lightdm; then
return 0
else
return 1
fi
;;
esac
;;
"${commands[5]}")
# autologin methods
case "$de" in
gnome)
# gdm3 autologin
mkdir -p /etc/gdm3
cat <<- EOF > /etc/gdm3/custom.conf
[daemon]
AutomaticLoginEnable = true
AutomaticLogin = ${user}
EOF
;;
kde-neon)
# sddm autologin
mkdir -p "/etc/sddm.conf.d/"
cat <<- EOF > "/etc/sddm.conf.d/autologin.conf"
[Autologin]
User=${user}
EOF
;;
*)
# lightdm autologin
mkdir -p /etc/lightdm/lightdm.conf.d
cat <<- EOF > "/etc/lightdm/lightdm.conf.d/22-armbian-autologin.conf"
[Seat:*]
autologin-user=${user}
autologin-user-timeout=0
user-session=xfce
EOF
;;
esac
# restart after selection
srv_restart display-manager
;;
"${commands[6]}")
# manual login, disable auto-login
case "$de" in
gnome) rm -f /etc/gdm3/custom.conf ;;
kde-neon) rm -f /etc/sddm.conf.d/autologin.conf ;;
*) rm -f /etc/lightdm/lightdm.conf.d/22-armbian-autologin.conf ;;
esac
# restart after selection
srv_restart display-manager
;;
"${commands[7]}")
# status
if [[ -f /etc/gdm3/custom.conf ]] || [[ -f /etc/sddm.conf.d/autologin.conf ]] || [[ -f /etc/lightdm/lightdm.conf.d/22-armbian-autologin.conf ]]; then
return 0
else
return 1
fi
;;
"${commands[8]}")
echo -e "\nUsage: ${module_options["module_desktop,feature"]} <command>"
echo -e "Commands: ${module_options["module_desktop,example"]}"
echo "Available commands:"
echo -e "\tinstall\t- Generate packages for $title."
echo -e "\tremove\t- Generate packages for $title."
echo -e "\tdisable\t- Generate packages for $title."
echo -e "\tenable\t- Generate packages for $title."
echo -e "\tstatus\t- Generate packages for $title."
echo -e "\nAvailable switches:\n"
echo -e "\tkvmprefix\t- Name prefix (default = kvmtest)"
echo
;;
*)
${module_options["module_desktop,feature"]} ${commands[8]}
;;
esac
}