-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathimage-reset.sh
More file actions
79 lines (72 loc) · 1.81 KB
/
image-reset.sh
File metadata and controls
79 lines (72 loc) · 1.81 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
#!/bin/bash
BRANCH="${BRANCH:-main}"
. <( curl -sL https://github.com/rern/rOS/raw/$BRANCH/common.sh )
dirnas=/mnt/MPD/NAS
dirusb=/mnt/MPD/USB
dirdata=/srv/http/data
selected() {
grep -q $1 <<< $reset && return 0
}
#............................
dialog.splash Reset for Image
list_reset="\
Reset MPD database
Reset user data directory
Clear package cache
Clear system log
Clear Wi-Fi connection"
readarray -t list_check < <( awk '{print $0; print "on"}' <<< $list_reset )
#............................
reset=$( dialog $opt_check '
\Z1Tasks:\Zn
' 8 $W 0 "${list_check[@]}" )
systemctl stop mpd
mount | grep $dirnas && umount -l $dirnas/*
mount | grep $dirusb && udevil umount -l $dirusb/*
clear -x
if selected database; then
bar Reset MPD database ...
rm -f $dirdata/mpd/*
cat << EOF > $dirdata/mpd/counts
{
"song" : 0
, "playlists" : 0
, "webradio" : $( find $dirdata/webradio -maxdepth 1 -type f | wc -l )
}
EOF
fi
if selected directory; then
bar Reset user data directory ...
rm -rf /root/.cache/*
rm -f $dirdata/{bookmarks,coverarts,lyrics,playlists}/*
fi
if selected cache; then
bar Clear package cache ...
rm -f /var/cache/pacman/pkg/*
fi
if selected connection; then
bar 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 selected log; then
bar Clear system log ...
rm -rf /var/log/journal/*
fi
if [[ -e /bin/firefox ]]; then
systemctl disable getty@tty1
systemctl enable bootsplash localbrowser
fi
bar 'rAudio reset done.
Shutdown ...
Before disconnecting power, observe \e[32;5m■\e[0m LED:
- Stop services - Blips
- Shutdown - 10 steady flashes » off'
find /root -mindepth 1 -delete
poweroff