forked from bobrathbone/piradio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
piradio.preinst
47 lines (42 loc) · 1.21 KB
/
piradio.preinst
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
#!/bin/bash
set -e
# Radio daemon pre-install script
# $Id: piradio.preinst,v 1.6 2016/08/04 19:27:09 bob Exp $
RADIOLIB=/var/lib/radiod
MPDCONF=/etc/mpd.conf
INITTAB=/etc/inittab
BOOTCMD=/boot/cmdline.txt
MODULES=/etc/modules
INIT=/etc/init.d/radiod
# Check if the script is being run as root
if [[ $EUID -ne 0 ]]
then
printf 'This script must be run using sudo.\nExiting..\n'
exit 1
fi
echo "Raspberry PI internet radio installation"
if [[ -d ${RADIOLIB} ]]; then
echo "The radio software appears to be already installed"
if [[ ! -f ${MPDCONF}.orig ]]; then
echo "Saving current configuration"
echo "Copying ${MPDCONF} to ${MPDCONF}.orig"
sudo cp -fp ${MPDCONF} ${MPDCONF}.orig
echo "Copying ${INITTAB} to ${INITTAB}.orig"
sudo cp -fp ${INITTAB} ${INITTAB}.orig
echo "Copying ${BOOTCMD} to ${BOOTCMD}.orig"
sudo cp -fp ${BOOTCMD} ${BOOTCMD}.orig
echo "Copying ${MODULES} to ${MODULES}.orig"
sudo cp -fp ${MODULES} ${MODULES}.orig
else
echo "Software only will be upgraded"
echo "Your existing configuration will not be changed"
fi
sleep 2
if [[ -f ${INIT} ]]; then
echo "Stopping radiod service"
sudo service radiod stop
fi
fi
exit 0
# End of preinst script
# End of pre-install script