@@ -5,53 +5,134 @@ install_file()
5
5
src=" $1 "
6
6
dest=" $2 "
7
7
8
- if [ -e " $dest " ] && ! cmp --quiet " $src " " $dest "
8
+ if [ ! -e " $dest " ]
9
9
then
10
- cp " $src " " ${dest} .new"
11
- else
12
10
cp " $src " " ${dest} "
11
+ return 1
12
+ else
13
+ echo " --> Service file already exists, skip creation"
14
+ return 0
13
15
fi
14
16
}
15
17
16
18
17
- echo " --- hyperion ambilight postinstall ---"
18
- echo " - install configuration template"
19
- mkdir -p /etc/hyperion
20
- install_file /usr/share/hyperion/config/hyperion.config.json /etc/hyperion/hyperion.config.json
19
+ echo " ---Hyperion ambient light postinstall ---"
20
+
21
+ # check system
22
+ CPU_RPI=` grep -m1 -c ' BCM2708\|BCM2709\|BCM2710\|BCM2835' /proc/cpuinfo`
23
+ CPU_X32X64=` uname -m | grep ' x86_32\|i686\|x86_64' | wc -l`
24
+
25
+ # Check for a bootloader as Berryboot
26
+ BOOT_BERRYBOOT=$( grep -m1 -c ' \(/var/media\|/media/pi\)/berryboot' /etc/mtab)
27
+
28
+ # get current system ip
29
+ NET_IP=` hostname -I | cut -d " " -f1`
30
+
31
+ # search for users in system, returns first entry
32
+ FOUND_USR=` who | grep -o ' ^\w*\b' ` || " root"
33
+
34
+ # determine if we should use a service
35
+ ENABLE_SERVICE=0
36
+ STARTUP_MSG=" echo ---> You can start Hyperion from your menu now"
21
37
38
+ if [ $CPU_RPI -eq 1 ]; then
39
+ ENABLE_SERVICE=1
40
+ STARTUP_MSG=" echo ---> Hyperion has been installed as service, it will start on each system startup"
41
+ fi
42
+
43
+ start_msg=" "
44
+ restart_msg=" "
22
45
23
46
if grep -m1 systemd /proc/1/comm > /dev/null
24
47
then
48
+ echo " ---> init deamon: systemd"
25
49
# systemd
26
- echo
27
- systemctl stop hyperion 2> /dev/null
28
- install_file /usr/share/hyperion/service/hyperion.systemd.sh /etc/systemd/system/hyperion.service
29
- systemctl -q enable hyperion.service
30
- # if [ $OS_OSMC -eq 1 ]; then
31
- # echo '---> Modify systemd script for OSMC usage'
32
- # # Wait until kodi is sarted (for kodi checker)
33
- # sed -i '/After = mediacenter.service/d' /etc/systemd/system/hyperion.service
34
- # sed -i '/Unit/a After = mediacenter.service' /etc/systemd/system/hyperion.service
35
- # sed -i 's/User=osmc/User=root/g' /etc/systemd/system/hyperion.service
36
- # sed -i 's/Group=osmc/Group=root/g' /etc/systemd/system/hyperion.service
37
- # systemctl -q daemon-reload
38
- # fi
39
- systemctl start hyperion
50
+ install_file /usr/share/hyperion/service/hyperion.systemd /etc/systemd/system/
[email protected]
51
+ # service registration just on Raspberry Pi, probably need to ask the user how we should use the service. TODO service start in user login scope eg for x11?!
52
+ if [ $ENABLE_SERVICE -eq 1 ]; then
53
+ systemctl enable hyperiond" @${FOUND_USR} " .service
54
+ start_msg=" --> systemctl start hyperiond for user ${FOUND_USR} "
55
+ systemctl start hyperiond" @${FOUND_USR} "
56
+ fi
40
57
41
58
elif [ -e /sbin/initctl ]
42
59
then
60
+ echo " ---> init deamon: upstart"
43
61
# upstart
44
- install_file /usr/share/hyperion/service/hyperion.initctl.sh /etc/init/hyperion.conf
45
- initctl reload-configuration
46
- initctl start hyperion
62
+ if [ $ENABLE_SERVICE -eq 1 ]; then
63
+ install_file /usr/share/hyperion/service/hyperiond.initctl /etc/init/hyperion.conf && initctl reload-configuration
64
+ start_msg=" --> initctl start hyperiond"
65
+ initctl start hyperiond
66
+ fi
47
67
48
68
else
69
+ echo " ---> init deamon: sysV"
49
70
# sysV
50
- service hyperion stop 2> /dev/null
51
- install_file /usr/share/hyperion/service/hyperion.init.sh /etc/init.d/hyperion
52
- chmod +x /etc/init.d/hyperion
53
- update-rc.d hyperion defaults 98 02
54
- service hyperion start
71
+ if [ $ENABLE_SERVICE -eq 1 ]; then
72
+ install_file /usr/share/hyperion/service/hyperion.init /etc/init.d/hyperiond && chmod +x /etc/init.d/hyperiond && update-rc.d hyperiond defaults 98 02
73
+ start_msg=" ---> service hyperiond start"
74
+ service hyperiond start
75
+ fi
76
+ fi
77
+
78
+ # cleanup
79
+ rm -r /usr/share/hyperion/service
80
+
81
+ # link binarys and set exec bit
82
+ BINSP=/usr/share/hyperion/bin
83
+ BINTP=/usr/bin
84
+ chmod +x -R $BINSP
85
+ ln -fs $BINSP /hyperiond $BINTP /hyperiond
86
+ ln -fs $BINSP /hyperion-remote $BINTP /hyperion-remote
87
+ ln -fs $BINSP /hyperion-v4l2 $BINTP /hyperion-v4l2
88
+ ln -fs $BINSP /hyperion-framebuffer $BINTP /hyperion-framebuffer 2> /dev/null
89
+ ln -fs $BINSP /hyperion-dispmanx $BINTP /hyperion-dispmanx 2> /dev/null
90
+ ln -fs $BINSP /hyperion-x11 $BINTP /hyperion-x11 2> /dev/null
91
+ ln -fs $BINSP /hyperion-aml $BINTP /hyperion-aml 2> /dev/null
92
+ ln -fs $BINSP /hyperion-qt $BINTP /hyperion-qt 2> /dev/null
93
+
94
+ # Check, if dtparam=spi=on is in place
95
+ if [ $CPU_RPI -eq 1 ]; then
96
+ BOOT_DIR=" /boot"
97
+ if [ $BOOT_BERRYBOOT -eq 1 ]; then
98
+ BOOT_DIR=$( sed -ne " s#/dev/mmcblk0p1 \([^ ]*\) vfat rw,.*#\1#p" /etc/mtab)
99
+ fi
100
+ if [ -z " $BOOT_DIR " -o ! -f " $BOOT_DIR /config.txt" ]; then
101
+ echo ' ---> Warning: RPi using BERRYBOOT found but can not locate where config.txt is to enable SPI. (BOOT_DIR=' " $BOOT_DIR )"
102
+ SPIOK=1 # Not sure if OK, but don't ask to reboot
103
+ else
104
+ SPIOK=` grep ' ^\dtparam=spi=on' " $BOOT_DIR /config.txt" | wc -l`
105
+ if [ $SPIOK -ne 1 ]; then
106
+ echo ' ---> Raspberry Pi found, but SPI is not set, we write "dtparam=spi=on" to ' " $BOOT_DIR /config.txt"
107
+ sed -i ' $a dtparam=spi=on' " $BOOT_DIR /config.txt"
108
+ REBOOTMESSAGE=" echo Please reboot your Raspberry Pi, we inserted dtparam=spi=on to $BOOT_DIR /config.txt"
109
+ fi
110
+ fi
111
+ fi
112
+
113
+ echo ${start_msg}
114
+
115
+ echo " -----------------------------------------------------------------------------"
116
+ echo " ---> Hyperion has been installed/updated!"
117
+ echo " ---> "
118
+ $STARTUP_MSG
119
+ echo " ---> For configuration, visit with your browser: ${NET_IP} :8090"
120
+ echo " ---> or if already used by another service try: ${NET_IP} :8091"
121
+ $REBOOTMESSAGE
122
+ echo " -----------------------------------------------------------------------------"
123
+ echo " Webpage: www.hyperion-project.org"
124
+ echo " Wiki: wiki.hyperion-project.org"
125
+ echo " Forum: forum.hyperion-project.org"
126
+ echo " -----------------------------------------------------------------------------"
127
+
128
+
129
+ if [ -e /opt/hyperion/ ]
130
+ then
131
+ echo
132
+ echo " ---------------------------------------------------------------------------------"
133
+ echo " - It seemd that you have an older version of hyperion installed in /opt/hyperion -"
134
+ echo " - please remove it to avoid problems -"
135
+ echo " ---------------------------------------------------------------------------------"
55
136
fi
56
- echo " - done"
57
137
138
+ exit 0
0 commit comments