-
Notifications
You must be signed in to change notification settings - Fork 2
/
archbox_6boot.sh
304 lines (263 loc) · 11.8 KB
/
archbox_6boot.sh
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
#!/bin/bash
################################################################################################################
#------------------------------------------------------------------------------------------------------
# ARCHBOX_6BOOT.SH --> DEBUT
#------------------------------------------------------------------------------------------------------
archi=`uname -m`
rep=`(cd $(dirname "$0"); pwd)` 2>/dev/null
export LANG="fr_FR.UTF-8"
export keymap="fr-pc"
export blue="\\033[1;34m"
export cyan="\\033[1;36m"
export green="\\033[1;32m"
export nc="\\033[0;39m"
export red="\\033[1;31m"
export white="\\033[1;37m"
export yellow="\\033[1;33m"
export ok="[ $yellow OK $white ]$green"
echo " "
echo " "
echo -e "$green ******************************************************************************"
echo -e "$green * "
echo -e "$green * [$red ARCHBOX$green ]"
echo -e "$green * Votre console multimedia de salon"
echo -e "$green * Installation $yellow [BOOT]$cyan [En cour...]"
echo -e "$green * "
echo -e "$green ******************************************************************************"
echo " "
################################################################################################################
################################################################################################################
#------------------------------------------------------------------------------------------------------
# Vérification fichier lck
#------------------------------------------------------------------------------------------------------
sh $rep/tools/archbox-opt/archbox_error.sh "lck" "$rep/6boot.lck"
if [ -f "$rep/6boot.lck" ] ; then
rm $rep/6boot.lck
fi
#------------------------------------------------------------------------------------------------------
# Nouveau utilisateur
#------------------------------------------------------------------------------------------------------
if [ -z "$1" ] ; then
read -p "Nouveau utilisateur : (défaut xbmc) " user
if [ -z "$user" ] ; then
user="xbmc"
fi
else
user="$1"
fi
export HOME="/home/$user"
#------------------------------------------------------------------------------------------------------
# Architecture (i386 - i686 - x86_64 - armv6l)
#------------------------------------------------------------------------------------------------------
echo -e "Votre architecture : $cyan$archi"
echo -e "$red"
if [ "$archi" = "armv6l" ] ; then
read -p "Votre machine est elle un Raspberry Pi Oui ? Non ? [def:Non] : " rpi
case $rpi in
"o"|"oui"|"O"|"Oui"|"OUI"|"y"|"yes"|"Y"|"Yes"|"YES")
archi="rpi" ;;
*)
echo " " ;;
esac
fi
#------------------------------------------------------------------------------------------------------
# Mise à jour + Installation
#------------------------------------------------------------------------------------------------------
sh $rep/tools/archbox-opt/archbox_maj.sh
################################################################################################################
################################################################################################################
echo -e "Reglage de la carte reseau... $cyan"
ifconfig -a | more
echo -e "$red"
read -p "Souhaitez-vous definir une adresse IP fixe Oui ? Non ? [Non] : " REP
read -p "Veuillez saisir le nom de votre carte réseau (defaut aucune) : " cartereseau
case $REP in
"o"|"oui"|"O"|"Oui"|"OUI"|"y"|"yes"|"Y"|"Yes"|"YES")
read -p "Adresse IP souhaité : " ip
read -p "Adresse du masque de sous réseau (defaut : 255.255.255.0) " mask
read -p "Adresse de la passerelle par défaut : " gateway
if [ -z "$mask" ] ; then
mask="255.255.255.0"
fi
export ip=$ip
echo "Votre ip : "$ip
echo "interface="$cartereseau"" > /etc/conf.d/network
echo "address="$ip"" >> /etc/conf.d/network
echo "netmask="$mask"" >> /etc/conf.d/network
echo "broadcast=192.168.1.255" >> /etc/conf.d/network
echo "gateway="$gateway"" >> /etc/conf.d/network
systemctl disable dhcpcd.service
systemctl disable dhcpcd@$cartereseau.service
systemctl enable network.service
echo -e "$white$ok Configuration ip fixe";;
*)
if [ -z "$cartereseau" ] ; then
systemctl enable dhcpcd.service
else
systemctl enable dhcpcd@$cartereseau.service
fi
echo -e "$white$ok Configuration dhcpd";;
esac
cp $rep/tools/archbox-network/network.service /etc/systemd/system/
echo "# ARCHBOX " > /etc/resolv.conf
echo "# Configuration DNS sur Open Nic [1-188.165.91.48 / 2-87.98.175.85]" >> /etc/resolv.conf
echo "nameserver 188.165.91.48" >> /etc/resolv.conf
echo "nameserver 87.98.175.85" >> /etc/resolv.conf
echo "nameserver "$gateway"" >> /etc/resolv.conf
echo -e "$white$ok Configuration réseau & dns"
#------------------------------------------------------------------------------------------------------
# Config /etc/netctl (par defaut)
#------------------------------------------------------------------------------------------------------
echo -e "Configuration par defaut de netctl : /etc/netctl/"
cp $rep/tools/archbox-network/netctl-wifi $rep/tools/archbox-network/netctl-ethernet /etc/netctl/
echo -e "$white$ok Configuration netctl"
################################################################################################################
################################################################################################################
if [ "$archi" == "rpi" ] ; then
ln -s /usr/lib/systemd/system/[email protected] /etc/systemd/system/getty.target.wants/[email protected]
fi
#------------------------------------------------------------------------------------------------------
# Install autologin
#------------------------------------------------------------------------------------------------------
echo -e "Installation de l'autologin sur $user"
echo -e "Copie /usr/lib/systemd/system/autologin.service"
if [ -f "$rep/tools/archbox-boot/[email protected]" ] ; then
rm $rep/tools/archbox-boot/[email protected]
fi
cat <<EOF > $rep/tools/archbox-boot/[email protected]
[Unit]
Description=Getty on %I
Documentation=man:agetty(8) man:systemd-getty-generator(8)
Documentation=http://0pointer.de/blog/projects/serial-console.html
After=systemd-user-sessions.service plymouth-quit-wait.service
# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes
# On systems without virtual consoles, don't start any getty. (Note
# that serial gettys are covered by [email protected], not this
# unit
ConditionPathExists=/dev/tty0
[Service]
# the VT is cleared by TTYVTDisallocate
ExecStart=-/sbin/agetty --noclear -a $user %I 38400 linux
Type=idle
Restart=always
RestartSec=0
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
KillMode=process
IgnoreSIGPIPE=no
# Unset locale for the console getty since the console has problems
# displaying some internationalized messages.
Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION=
# Some login implementations ignore SIGTERM, so we send SIGHUP
# instead, to ensure that login terminates cleanly.
KillSignal=SIGHUP
[Install]
Alias=getty.target.wants/[email protected]
EOF
cp $rep/tools/archbox-boot/[email protected] /usr/lib/systemd/system/[email protected]
cp $rep/tools/archbox-boot/[email protected] /etc/systemd/system/
echo -e "$white$ok Autologin sur $user"
#------------------------------------------------------------------------------------------------------
# Install splash screen
#------------------------------------------------------------------------------------------------------
if [ -s /boot/grub/grub.cfg ] ; then
echo -e "Copie /boot/grub/splash.png ..."
cp $rep/tools/archbox-boot/splash.png /boot/grub/
printf 'GRUB_BACKGROUND="/boot/grub/splash.png"\n' >> /etc/default/grub
grub-mkconfig -o /boot/grub/grub.cfg
echo -e "$white$ok ARCHBOX Splash screen sur GRUB "
fi
#------------------------------------------------------------------------------------------------------
# Install archboxboot
#------------------------------------------------------------------------------------------------------
cp $rep/tools/archbox-boot/archboxboot /usr/bin/
echo -e "Copie /usr/bin/archboxboot ..."
chmod 755 /usr/bin/archboxboot
echo -e "Copie /etc/systemd/system/archbox.service ..."
cp $rep/tools/archbox-boot/[email protected] /etc/systemd/system/
echo -e "$white$ok ARCHBOX Service (voir /usr/bin/archboxboot pour le script de lancement) "
#------------------------------------------------------------------------------------------------------
# Config xinitrc
#------------------------------------------------------------------------------------------------------
if [ -f "$HOME/.xinitrc" ] ; then
rm $HOME/.xinitrc
fi
cat <<EOF > $HOME/.xinitrc
#!/bin/sh
# ~/.xinitrc
# Executed by startx (run your window manager from here)
if [ -d /etc/X11/xinit/xinitrc.d ]; then
for f in /etc/X11/xinit/xinitrc.d/*; do
[ -x "$f" ] && . "$f"
done
unset f
fi
# exec startxfce4
# exec xbmc
EOF
echo -e "$white$ok Config .xinitrc "
#------------------------------------------------------------------------------------------------------
# Config bash_profile
#------------------------------------------------------------------------------------------------------
if [ -f "$HOME/.bash_profile" ] ; then
rm $HOME/.bash_profile
fi
cat <<EOF > $HOME/.bash_profile
# ~/.bash_profile
#
#[[ -f ~/.bashrc ]] && . ~/.bashrc
#[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx
EOF
echo "exec /usr/bin/archboxboot" >> /home/$user/.bash_profile
echo -e "$white$ok Config .bash_profile (ajout de script archboxboot au demarrage) "
#------------------------------------------------------------------------------------------------------
# Config xsession
#------------------------------------------------------------------------------------------------------
if [ -f "$HOME/.xsession" ] ; then
rm $HOME/.xsession
fi
cat <<EOF > $HOME/.xsession
#!/bin/sh
# ~/.xsession
# Executed by xdm/gdm/kdm at login
/bin/bash --login -i ~/.xinitrc
EOF
echo -e "$white$ok Config .xsession "
#------------------------------------------------------------------------------------------------------
# Services au demarrage
#------------------------------------------------------------------------------------------------------
echo -e "Activation des services au démarrage ..."
# systemctl enable [email protected] <-- PAS DE ARCHBOXBOOT
systemctl enable upower
systemctl disable getty@tty1
systemctl daemon-reload
systemctl enable autologin@$user.service
systemctl enable multi-user.target
systemctl enable devmon@$user
if [ "$archi" == "rpi" ] ; then
systemctl enable [email protected]
fi
echo -e "$white$ok Activation des services"
cat <<EOF > $rep/6boot.lck
#----------------------------
# ARCHBOX_6BOOT.SH --> [OK]
#----------------------------
EOF
################################################################################################################
################################################################################################################
echo -e "$green **********************************************************************************************************"
echo -e "$green * "
echo -e "$green * [$red ARCHBOX$green ]"
echo -e "$green * Installation $yellow [BOOT]$red Terminé"
echo -e "$green * "
echo -e "$red * Attention si ce n'ai pas déjà fait ajouter manuellement 'bna' dans $MODULES "
echo -e "$red * sur /etc/mkinitcpio.conf et recharger mkinitcpio avec ==> mkinitcpio -p linux"
echo -e "$green ********************************************************************************************************** $nc"
################################################################################################################