-
Notifications
You must be signed in to change notification settings - Fork 3
/
Boom-Boom-izer.sh
executable file
·141 lines (115 loc) · 3.53 KB
/
Boom-Boom-izer.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
#!/bin/bash
## DEFINITIONS
DEFPLAYLIST="https://www.youtube.com/playlist?list=PL_K5oM8g3x84_JuMJhWpJvOKmjaay1inl"
export LC_ALL=C
cd `dirname $(realpath "$0")`
## STAGE 1: change base config
if [[ ! -e PLAYLIST ]]; then
whiptail --title "Potty Boom Boom is dangerous!" \
--yesno "This would install Potty Boom Boom - and several reboots will be necessary! Proceed?" 8 78 \
|| exit
PLAYLIST=$(whiptail --title "Default Playlist" \
--inputbox "\
Your servile boomer could install a first playlist. What list should \
that be? (cancel for none)" \
8 78 "$DEFPLAYLIST" \
3>&1 1>&2 2>&3 || echo "")
sudo /usr/bin/raspi-config nonint do_expand_rootfs
sudo /usr/bin/raspi-config nonint do_memory_split 64
echo $PLAYLIST > PLAYLIST # trigger second stage upon reboot
sudo tee /etc/systemd/system/potty-boom-install.service >/dev/null <<EOF
[Unit]
Description=Potty Boom Boom - second stage install
[Service]
Type=oneshot
ExecStart=`realpath $0`
StandardInput=tty
TTYPath=/dev/tty2
TTYReset=yes
TTYVHangup=yes
[Install]
WantedBy=default.target
EOF
sudo systemctl enable potty-boom-install
sudo reboot
exit
fi
## STAGE 2: full size install
function err_apt {
whiptail --title "ERROR" --infobox "Package installation failed - \
is there a network available? Please connect and restart..." 8 78
exit 42
}
function err_common {
whiptail --title "ERROR" --infobox "there was a problem - \
Maybe I had too little boom boom sleep?" 8 78
exit 42
}
chvt 2
echo "second stage install taking off..."
setterm -blank 0 -powersave off
trap "err_apt" ERR
debconf-apt-progress -- apt update -y
debconf-apt-progress -- apt install -y omxplayer i3 lightdm youtube-dl
whiptail --title "youtube-dl" --infobox "patch in the latest youtube-dl..." 8 78
wget https://yt-dl.org/latest/youtube-dl -O /usr/local/bin/youtube-dl 2> /dev/null
chmod a+rx /usr/local/bin/youtube-dl
whiptail --title "configuration" --infobox "installing configs..." 8 78
mkdir -p /home/pi/Potty-Boom-Boom/Files
cp Potty-Boom-Boom-watchdog.sh /home/pi/Potty-Boom-Boom/
tee /etc/lightdm/lightdm.conf > /dev/null <<EOF
[SeatDefaults]
autologin-user=pi
autologin-user-timeout=0
[XDMCPServer]
[VNCServer]
EOF
mkdir -p /home/pi/.i3
tee /home/pi/.i3/config > /dev/null <<EOF
# i3 config file (v4)
exec_always /home/pi/Potty-Boom-Boom/Potty-Boom-Boom-watchdog.sh
EOF
chown -R pi.pi /home/pi/.i3
PLAYLIST=`cat PLAYLIST`
if [[ -n "$PLAYLIST" ]]; then
# we have to play with mawk as it is debian standard :(
(
cd /home/pi/Potty-Boom-Boom/Files/
youtube-dl --prefer-free-formats --newline --format 'mp4[height<=720]' \
"$PLAYLIST"
) | /usr/bin/mawk -W interactive '
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s }
function trim(s) { return rtrim(ltrim(s)); }
BEGIN {
current=0;
total=0;
videoname="";
print "HALLO";
}
/\[download\] Downloading video/ {
current=$4;
total=$6;
print "A";
}
/\[download\] Destination:/ {
$1="";
$2="";
videoname=trim($0);
print "B";
}
/\[download\] +[0-9.]+% of/ {
printf( "XXX\n%d\nVideo %d/%d: %s (ETA %s)\nXXX\n",
(100/total)*(current-1+int($2)/100), current, total, videoname, $8 );
}
' > >( whiptail --title "Download Initial Playlist" --gauge "starting download..." 8 70 0 )
fi
chown -R pi:pi /home/pi/Potty-Boom-Boom
amixer sset PCM,0 100 > /dev/null
alsactl store
# remove ourselves
systemctl disable potty-boom-install > /dev/null
rm /etc/systemd/system/potty-boom-install.service
shutdown -r now
exit 0