-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcreate-ros.sh
245 lines (217 loc) · 7.33 KB
/
create-ros.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
#!/bin/bash
trap exit INT
SECONDS=0
features=$( cat /boot/features )
banner() {
echo
def='\e[0m'
bg='\e[44m'
printf "$bg%*s$def\n" $COLUMNS
printf "$bg%-${COLUMNS}s$def\n" " $1"
printf "$bg%*s$def\n" $COLUMNS
}
#----------------------------------------------------------------------------
banner 'Initialize Arch Linux Arm ...'
pacman-key --init
pacman-key --populate archlinuxarm
systemctl restart systemd-timesyncd # force time sync
rm -f /var/lib/pacman/db.lck # in case of rerun
# fill entropy pool (fix - Kernel entropy pool is not initialized)
systemctl start systemd-random-seed
title='r A u d i o'
optbox=( --colors --no-shadow --no-collapse )
opt=( --backtitle "$title" ${optbox[@]} )
#----------------------------------------------------------------------------
dialog "${optbox[@]}" --infobox "
\Z1r\Z0Audio
" 9 58
sleep 2
clear -x # needed: fix stdout not scroll
#----------------------------------------------------------------------------
banner 'Upgrade system and default packages ...'
packages='alsaequal alsa-utils cava cronie cd-discid dosfstools dtc evtest gifsicle
hdparm hfsprogs i2c-tools imagemagick inetutils iwd jq kid3-common libgpiod mmc-utils mpc mpd mpd_oled nfs-utils nginx-mainline nss-mdns
parted php-fpm python-rpi-gpio python-rplcd python-smbus2 python-websocket-client python-websockets sudo udevil websocat wget '
if [[ -e /boot/kernel8.img ]]; then
pacman -R --noconfirm linux-aarch64 uboot-raspberrypi
packages+='linux-rpi raspberrypi-utils '
fi
# add +R repo
if ! grep -q '^\[+R\]' /etc/pacman.conf; then
sed -i -e '/community/,/^$/ d
' -e '/aur/,/^$/ d
' -e '/core/ i\
[+R]\
SigLevel = Optional TrustAll\
Server = https://rern.github.io/$arch\
' /etc/pacman.conf
fi
pacman -Syu --noconfirm
if [[ $? != 0 ]]; then
echo -e "\e[38;5;0m\e[48;5;3m ! \e[0m Retry upgrade system ..."
sleep 3
pacman -Syu --noconfirm
if [[ $? != 0 ]]; then
echo -e "\e[38;5;7m\e[48;5;1m ! \e[0m System upgrade incomplete."
exit
fi
fi
if [[ -e /boot/cmdline.txt0 ]]; then
mv -f /boot/cmdline.txt{0,}
mv -f /boot/config.txt{0,}
fi
# usb boot - disable sd card polling
! df | grep -q /dev/mmcblk && echo 'dtoverlay=sdtweak,poll_once' >> /boot/config.txt
#----------------------------------------------------------------------------
banner 'Install packages ...'
pacman -S --noconfirm --needed $packages $features
if [[ $? != 0 ]]; then
echo -e "\e[38;5;0m\e[48;5;3m ! \e[0m Retry download packages ..."
pacman -S --noconfirm --needed $packages $features
if [[ $? != 0 ]]; then
echo -e "\e[38;5;7m\e[48;5;1m ! \e[0m Packages download incomplete."
exit
fi
fi
#----------------------------------------------------------------------------
banner 'Get configurations and user interface ...'
mkdir -p /tmp/config
release=$( cat /boot/release )
curl -skL https://github.com/rern/rAudio/archive/$release.tar.gz | bsdtar xvf - --strip 1 -C /tmp/config
curl -skL https://github.com/rern/rOS/archive/main.tar.gz | bsdtar xvf - --strip 1 -C /tmp/config
rm -f /tmp/config/{.*,*}
chmod -R go-wx /tmp/config
chmod -R u+rwX,go+rX /tmp/config
cp -r /tmp/config/* /
chown http:http /etc/fstab
chown -R http:http /etc/netctl /etc/systemd/network
dirbash=/srv/http/bash
chmod -R 755 $dirbash
mkdir /srv/http/assets/img/guide
curl -skL https://github.com/rern/_assets/raw/master/guide/guide.tar.xz | bsdtar xf - -C /srv/http/assets/img/guide
#---------------------------------------------------------------------------------
banner 'Configure ...'
# alsa
alsactl store
# prompt
cat << 'EOF' >> /etc/bash.bashrc
PS1='\[\e[38;5;242m\]'$HOSTNAME'\[\e[0m\]\
:\
\[\e[36m\]\w\[\e[0m\]\
\[\e[30m\e[46m\] \$ \[\e[0m\] '
EOF
# bluetooth
if [[ -e /usr/bin/bluetoothctl ]]; then
sed -i 's/#*\(AutoEnable=\).*/\1true/' /etc/bluetooth/main.conf
else
rm -rf /etc/systemd/system/{bluealsa,bluetooth}.service.d
rm -f /etc/systemd/system/blue*
fi
# camilladsp
if [[ -e /usr/bin/camilladsp ]]; then
sed -i '/^CONFIG/ s|etc|srv/http/data|' /etc/default/camilladsp
dirconfigs=/srv/http/data/camilladsp/configs
mkdir -p $dirconfigs
sed -e '/ Volume:/,/type: Volume/ d
' -e '/- Volume/ d
' /etc/camilladsp/configs/camilladsp.yml > $dirconfigs/camilladsp.yml
else
rm -f /srv/http/data/mpdconf/conf/camilladsp.conf
fi
# cron - for addons updates
echo "00 01 * * * $dirbash/settings/addons-data.sh" | crontab -
echo VISUAL=nano >> /etc/environment
# firefox
if [[ -e /usr/bin/firefox ]]; then
echo MOZ_USE_XINPUT2 DEFAULT=1 >> /etc/security/pam_env.conf # fix touch scroll
chmod 775 /etc/X11/xorg.conf.d # fix permission for rotate file
ln -sf $dirbash/xinitrc /etc/X11/xinit # startx
mv /usr/share/X11/xorg.conf.d/{10,45}-evdev.conf # reorder
timeout 1 firefox --headless &> /dev/null # init /root/.mozilla/firefox
systemctl disable getty@tty1 # disable login prompt
systemctl enable bootsplash localbrowser
else
rm -f /etc/systemd/system/{bootsplash,localbrowser}* \
/etc/X11/* \
/etc/X11/xinit/rotateconf
fi
# initramfs disable
dirhooks=/etc/pacman.d/hooks
mkdir -p $dirhooks
for file in linux-rpi mkinitcpio-install; do
ln -s /dev/null $dirhooks/90-$file.hook
done
# iwd
if [[ -e /usr/bin/iwctl ]]; then
mkdir -p /var/lib/iwd/ap
echo "\
[Security]
Passphrase=raudioap
[IPv4]
Address=192.168.5.1
" > /var/lib/iwd/ap/rAudio.ap
groupadd netdev # fix: group for iwd
fi
# mpd
chsh -s /bin/bash mpd
# motd
ln -sf $dirbash/motd.sh /etc/profile.d/
# pam - fix freedesktop.home1.service not found (upgrade somehow overwrite)
sed -i '/^-.*pam_systemd_home/ s/^/#/' /etc/pam.d/system-auth
# password
echo root:ros | chpasswd
# samba
[[ -e /usr/bin/smbd ]] && ( echo ros; echo ros ) | smbpasswd -s -a root
# shairport-sync - not installed
[[ ! -e /usr/bin/shairport-sync ]] && rm /etc/sudoers.d/shairport-sync /etc/systemd/system/shairport-meta.service
# snapcast
sed -i '/^#bind_to_address/ a\
bind_to_address = 0.0.0.0
' /etc/snapserver.conf
# spotifyd
if [[ -e /usr/bin/spotifyd ]]; then
mv /lib/systemd/{user,system}/spotifyd.service
else
rm /etc/spotifyd.conf
fi
# sshd
sed -i -e 's/\(PermitEmptyPasswords \).*/#\1no/
' -e 's/.*\(PrintLastLog \).*/\1no/
' /etc/ssh/sshd_config
# user
users=$( cut -d: -f1 /etc/passwd )
for user in $users; do
chage -E -1 $user # set expire to none
done
# upmpdcli
if [[ -e /usr/bin/upmpdcli ]]; then
dir=/var/cache/upmpdcli/ohcreds
file=$dir/credkey.pem
mkdir -p $dir
openssl genrsa -out $file 4096
openssl rsa -in $file -RSAPublicKey_out
chown upmpdcli:root $file
else
rm -rf /etc/upmpdcli.conf /etc/systemd/system/upmpdcli.service.d
fi
# wireless-regdom
echo 'WIRELESS_REGDOM="00"' > /etc/conf.d/wireless-regdom
# default startup services
systemctl daemon-reload
systemctl enable avahi-daemon cronie devmon@http nginx php-fpm startup websocket
#---------------------------------------------------------------------------------
# data - settings directories
$dirbash/settings/system-datadefault.sh $release
# flag expand partition
touch /boot/expand
[[ -e /boot/finish.sh ]] && . /boot/finish.sh
rm -f /boot/{features,finish.sh,release} \
/boot/{cmdline,config}.txt.pacnew \
/root/create-ros.sh
#----------------------------------------------------------------------------
dialog "${optbox[@]}" --infobox "
\Z1r\Z0Audio created successfully.
\Z1Reboot\Z0 ...
$( date -d@$SECONDS -u +%M:%S )
" 9 58
shutdown -r now