-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-ros.sh
205 lines (179 loc) · 6.57 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
#!/bin/bash
trap exit INT
SECONDS=0
. /boot/versions
features=$( cat /boot/features )
banner() {
echo
def='\e[0m'
bg='\e[44m'
printf "$bg%*s$def\n" $col
printf "$bg%-${col}s$def\n" " $1"
printf "$bg%*s$def\n" $col
}
#----------------------------------------------------------------------------
banner 'Initialize Arch Linux Arm ...'
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="rAudio $version"
optbox=( --colors --no-shadow --no-collapse )
opt=( --backtitle "$title" ${optbox[@]} )
#----------------------------------------------------------------------------
dialog "${optbox[@]}" --infobox "
\Z1r\Z0Audio $version
" 9 58
sleep 2
clear -x # needed: fix stdout not scroll
#----------------------------------------------------------------------------
banner 'Upgrade system and default packages ...'
packages='alsaequal alsa-utils audio_spectrum_oled cava cronie cd-discid dosfstools evtest gifsicle hdparm hfsprogs
i2c-tools imagemagick inetutils jq mpc mpd nfs-utils nginx-mainline-pushstream nss-mdns
parted php-fpm sshpass python-rplcd python-smbus2 sudo udevil wget wiringpi'
# add +R repo
if ! grep -q '^\[+R\]' /etc/pacman.conf; then
sed -i '/\[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
#----------------------------------------------------------------------------
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 ...'
curl -skLO https://github.com/rern/rOS/archive/main.tar.gz
curl -skLO https://github.com/rern/rAudio-$version/archive/$release.tar.gz
mkdir -p /tmp/config
bsdtar --strip 1 -C /tmp/config -xvf main.tar.gz
bsdtar --strip 1 -C /tmp/config -xvf $release.tar.gz
rm *.gz /tmp/config/*.* /tmp/config/.* 2> /dev/null
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
chmod -R 755 /srv/http/bash
mv -f /boot/cmdline.txt{0,}
mv -f /boot/config.txt{0,}
rm -f /boot/{cmdline,config}.txt.pacsave
ln -s /srv/http/assets /srv/http/settings/camillagui/build/static
curl -skL https://github.com/rern/_assets/raw/master/guide/guide.tar.xz | bsdtar xf - -C /srv/http/assets/img
#---------------------------------------------------------------------------------
banner 'Configure ...'
# alsa
alsactl store
# 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
# browser
if [[ -e /usr/bin/chromium ]]; then
sed -i 's/\(console=\).*/\1tty3 quiet loglevel=0 logo.nologo vt.global_cursor_default=0/' /boot/cmdline.txt # boot splash
chmod 775 /etc/X11/xorg.conf.d # fix permission for rotate file
ln -sf /srv/http/bash/xinitrc /etc/X11/xinit # startx
mv /usr/share/X11/xorg.conf.d/{10,45}-evdev.conf # reorder
systemctl disable getty@tty1 # login prompt
systemctl enable bootsplash localbrowser
[[ $( uname -m ) == armv7l ]] && sed -i '/^chromium/ a\ --no-xshm \\' /srv/http/bash/xinitrc
else
rm -f /etc/systemd/system/{bootsplash,localbrowser}* /etc/X11/* \
/srv/http/assets/img/{splah,CW,CCW,NORMAL,UD}* /srv/http/bash/xinitrc /usr/local/bin/ply-image 2> /dev/null
fi
# camilladsp
if [[ -e /usr/bin/camilladsp ]]; then
dir=/srv/http/settings/camillagui/build/static/assets
ln -s /srv/http/assets $dir
chown -h http:http $dir
fi
# cron - for addons updates
( crontab -l &> /dev/null; echo '00 01 * * * /srv/http/bash/cmd.sh addonsupdates &' ) | crontab -
# hostapd
[[ ! -e /usr/bin/hostapd ]] && rm -rf /etc/{hostapd,dnsmasq.conf}
# mpd
chsh -s /bin/bash mpd
# motd
ln -sf /srv/http/bash/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
# 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
# timesyncd - fix if no eth connection
[[ -e /boot/kernel8.img ]] && eth=eth || eth=eth0
file=/etc/systemd/network/$eth.network
grep -q RequiredForOnline=no $file || echo "
[Link]
RequiredForOnline=no" >> $file
# user - set expire to none
users=$( cut -d: -f1 /etc/passwd )
for user in $users; do
chage -E -1 $user
done
# upmpdcli - not installed
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
#---------------------------------------------------------------------------------
# data - settings directories
/srv/http/bash/settings/system-datareset.sh $version $release
# remove files and package cache
rm /boot/{features,versions} /root/create-ros.sh /var/cache/pacman/pkg/*
# usb boot - disable sd card polling
! df | grep -q /dev/mmcblk && echo 'dtoverlay=sdtweak,poll_once' >> /boot/config.txt
# expand partition
touch /boot/expand
#----------------------------------------------------------------------------
dialog "${optbox[@]}" --infobox "
\Z1r\Z0Audio $version created successfully.
\Z1Reboot\Z0 ...
$( date -d@$SECONDS -u +%M:%S )
" 9 58
shutdown -r now