-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathimagereset.sh
88 lines (75 loc) · 2.29 KB
/
imagereset.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
#!/bin/bash
dirdata=/srv/http/data
optbox=( --colors --no-shadow --no-collapse )
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
}
select=$( dialog "${optbox[@]}" \
--output-fd 1 \
--checklist '\n\Z1Select tasks:\n
\Z4[space] = Select / Deselect\Z0' 9 50 0 \
1 "Reset MPD database" on \
2 "Reset user data directory" on \
3 "Clear package cache" on \
4 "Clear system log" on \
5 "Clear Wi-Fi connection" on )
clear
[[ $? == 1 ]] && exit
select=" $select "
systemctl stop mpd
mount | grep /mnt/MPD/NAS && umount -l "/mnt/MPD/NAS/"*
mount | grep /mnt/MPD/USB && udevil umount -l "/mnt/MPD/USB/"*
if [[ $select == *' 1 '* ]]; then
banner 'Reset MPD database ...'
rm -f $dirdata/mpd/*
fi
if [[ $select == *' 2 '* ]]; then
banner 'Reset user data directory ...'
rm -rf /root/.cache/*
rm -f $dirdata/{bookmarks,coverarts,lyrics,playlists,webradios}/*
curl -skL https://github.com/rern/rAudio-addons/raw/main/webradio/radioparadise.tar.xz | bsdtar xvf - -C $dirdata/webradio
echo '{
"playlists" : 0
, "webradio" : '$( find -L $dirdata/webradio -type f ! -path '*/img/*' | wc -l )'
}' > $dirdata/mpd/counts
fi
if [[ $select == *' 3 '* ]]; then
banner 'Clear package cache ...'
rm -f /var/cache/pacman/pkg/*
fi
if [[ $select == *' 4 '* ]]; then
banner 'Clear system log ...'
rm -rf /var/log/journal/*
fi
if [[ $select == *' 5 '* ]]; then
banner 'Clear Bluetooth and Wi-Fi connection ...'
rm -rf /var/lib/bluetooth/*
profiles=$( ls -1p /etc/netctl | grep -v / )
if [[ $profiles ]]; then
while read profile; do
netctl disable "$profile"
done <<< $profiles
rm /etc/netctl/* 2> /dev/null
fi
fi
if [[ ! -e /boot/kernel.img ]]; then # skip on rpi 0, 1
curl -skL https://github.com/archlinuxarm/PKGBUILDs/raw/master/core/pacman-mirrorlist/mirrorlist -o /etc/pacman.d/mirrorlist
fi
rm -rf /root/.config/chromium
banner 'Check disk ...'
fsck.fat -traw /dev/mmcblk0p1
rm -f /boot/FSCK*
dialog "${optbox[@]}" --infobox "
\Z1r\Z0Audio reset finished.
\Z1Shutdown\Z0 ...
Before disconnecting power, observe \Z2\Zr \ZR\Z0 LED:
- Stop all services - Blips
- Shutdown - 10 steady flashes to completely off
" 11 65
shutdown -h now
exit