-
Notifications
You must be signed in to change notification settings - Fork 6
/
update_i2c2oled.sh
69 lines (59 loc) · 2.7 KB
/
update_i2c2oled.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
#!/bin/bash
URL="https://www.tty2tft.de/i2c2oled"
# URL="https://www.tty2tft.de/i2c2oled/testing"
I2C2OLED_PATH="/media/fat/i2c2oled"
USERSTARTUP="/media/fat/linux/user-startup.sh"
USERSTARTUPTPL="/media/fat/linux/_user-startup.sh"
INITSCRIPT="${I2C2OLED_PATH}/S60i2c2oled"
DAEMONNAME="i2c2oled.sh"
HOSTID="$(hostid)"
export RSYNC_PASSWORD="93CdeEfF49ba92fEd2dEb29efi"
# Stop an already running daemon
if [ $(pidof ${DAEMONNAME}) ]; then
${INITSCRIPT} stop
sleep 0.5
fi
# Check for i2c2oled path's and create it if neccessary, download/update scripts
! [ -d /media/fat/i2c2oled/Pix ] && mkdir -p /media/fat/i2c2oled/Pix
! [ -d /media/fat/i2c2oled/PRI ] && mkdir -p /media/fat/i2c2oled/PRI
! [ -d /media/fat/i2c2oled/Pix_Onecolor ] && mkdir -p /media/fat/i2c2oled/Pix_Onecolor
! [ -d /media/fat/i2c2oled/PRI_Onecolor ] && mkdir -p /media/fat/i2c2oled/PRI_Onecolor
# Check update_all.ini for i2c2oled Update/Install Script
if [ $(grep -c "I2C2OLED_FILES_DOWNLOADER=\"true\"" "/media/fat/Scripts/update_all.ini") = "0" ]; then
cd /media/fat/Scripts
wget -N --no-use-server-timestamps ${URL}/update_i2c2oled.sh
[ -x update_i2c2oled.sh ] || chmod +x update_i2c2oled.sh
sleep 0.5
else
echo "UPDATE_ALL is responsible for the i2c2oled updater. Skipping Download/Update!"
fi
# Download/Update i2c2oled Scripts
cd /media/fat/i2c2oled
wget -N --no-use-server-timestamps ${URL}/MAC.html?${HOSTID} ${URL}/S60i2c2oled ${URL}/i2c2oled.sh ${URL}/i2c2oled_slideshow.sh ${URL}/i2c2oled-system.ini
wget -nc ${URL}/i2c2oled-user.ini
[ -x S60i2c2oled ] || chmod +x S60i2c2oled
[ -x i2c2oled.sh ] || chmod +x i2c2oled.sh
[ -x i2c2oled_slideshow.sh ] || chmod +x i2c2oled_slideshow.sh
# Old MiSTer layout: remove init script
[[ -e /etc/init.d/S60i2c2oled ]] && /etc/init.d/S60i2c2oled stop && rm /etc/init.d/S60i2c2oled
# New MiSTer layout: setup init script
if [ ! -e ${USERSTARTUP} ] && [ -e /etc/init.d/S99user ]; then
if [ -e ${USERSTARTUPTPL} ]; then
echo "Copying ${USERSTARTUPTPL} to ${USERSTARTUP}"
cp ${USERSTARTUPTPL} ${USERSTARTUP}
else
echo "Building ${USERSTARTUP}"
echo -e "#!/bin/sh\n" > ${USERSTARTUP}
echo -e 'echo "***" $1 "***"' >> ${USERSTARTUP}
fi
fi
if [ $(grep -c "i2c2oled" ${USERSTARTUP}) = "0" ]; then
echo -e "Adding i2c2oled to ${USERSTARTUP}\n"
echo -e "\n# Startup i2c2oled" >> ${USERSTARTUP}
echo -e "[[ -e ${INITSCRIPT} ]] && ${INITSCRIPT} \$1" >> ${USERSTARTUP}
fi
# Synchronize pictures
rsync -crlzzP --modify-window=1 --delete rsync://[email protected]/i2c2oled-pictures/Pix/ ${I2C2OLED_PATH}/Pix/
rsync -crlzzP --modify-window=1 --delete rsync://[email protected]/i2c2oled-pictures/Pix_Onecolor/ ${I2C2OLED_PATH}/Pix_Onecolor/
${INITSCRIPT} start
exit 0