This repository has been archived by the owner on Sep 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 138
/
setup.sh
103 lines (80 loc) · 2.61 KB
/
setup.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
#!/bin/sh
if [ `id -u` -ne 0 ]
then
echo "Please run this script with root privileges!"
echo "Try again with sudo."
exit 0
fi
echo "This script will install RaspberryCast"
read -p "Which user do you want to install RaspberryCast as? (Leave blank to set to default): " USER
if ! [ -n "$USER" ]; then
echo "Setting user to default value 'pi'."
USER="pi"
fi
if ! getent passwd $USER > /dev/null 2>&1; then
echo "User $USER does not exist. Exiting."
exit
fi
echo "Your system will be rebooted on completion"
echo "Do you wish to continue? (y/n)"
while true; do
read -p "" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit 0;;
* ) echo "Please answer with Yes or No [y|n].";;
esac
done
echo ""
echo "============================================================"
echo ""
echo "Installing necessary dependencies... (This could take a while)"
echo ""
echo "============================================================"
apt-get install -y lsof python-pip git wget omxplayer libnss-mdns fbi
echo "============================================================"
if [ "$?" = "1" ]
then
echo "An unexpected error occured during apt-get!"
exit 0
fi
pip install youtube-dl bottle livestreamer
if [ "$?" = "1" ]
then
echo "An unexpected error occured during pip install!"
exit 0
fi
echo ""
echo "============================================================"
echo ""
echo "Cloning project from GitHub.."
echo ""
echo "============================================================"
su - $USER -c "git clone https://github.com/vincelwt/RaspberryCast.git"
chmod +x ./RaspberryCast/RaspberryCast.sh
echo ""
echo "============================================================"
echo ""
echo "Adding project to startup sequence and custom options"
echo ""
echo "============================================================"
#Gives right to all user to get out of screen standby
chmod 666 /dev/tty1
#Add to rc.local startup
sed -i '$ d' /etc/rc.local
echo "su - $USER -c \"cd ./RaspberryCast/ && ./RaspberryCast.sh start\"" >> /etc/rc.local
echo "exit 0" >> /etc/rc.local
#Adding right to current pi user to shutdown
chmod +s /sbin/shutdown
#Adding right to sudo fbi without password
echo "$USER ALL = (root) NOPASSWD: /usr/bin/fbi" >> /etc/sudoers
rm setup.sh
echo "============================================================"
echo "Setup was successful."
echo "Do not delete the 'RaspberryCast' folder as it contains all application data!"
echo "Rebooting system now..."
echo "============================================================"
sleep 2
#Reboot to ensure cleaness of Pi memory and displaying of log
reboot
exit 0