forked from retronas/retronas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_retronas.sh
executable file
·79 lines (65 loc) · 1.49 KB
/
install_retronas.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
#!/bin/bash
set -u
GITREPO='https://github.com/danmons/retronas.git'
FORCE=0
TARGET=/opt/retronas/
MYID=$( whoami )
_usage() {
echo "Usage $0"
echo "-h this help"
echo "-o override git repo/branch to install from"
echo "-f force re-installation (EXPERT)"
exit 0
}
if [ "${MYID}" != "root" ]
then
echo "This script needs to be run as sudo/root"
echo "Please re-run:"
echo "sudo $0"
exit 1
fi
OPTSTRING="fho:"
while getopts $OPTSTRING ARG
do
case $ARG in
h)
_usage
;;
o)
GITREPO="${OPTARG}"
;;
f)
FORCE=1
;;
esac
done
# handle existing installations
[ -f ${TARGET}/.git/config ] && [ $FORCE -eq 0 ] && echo "Existing installation pass -f to overwrite" && exit 1
[ -f ${TARGET}/.git/config ] && [ $FORCE -eq 1 ] && echo "Installation exists, -f passed, removing" && rm -rf "${TARGET}"
echo
echo "Updating repo cache..."
apt update
echo
echo "Installing necessary tools..."
apt install -y ansible git dialog jq
if [ ! -f ${TARGET}/.git/config ]
then
echo
echo "Downloading RetroNAS...from ${GITREPO}"
cd /opt
git clone "$GITREPO"
chmod a+x /opt/retronas/retronas.sh
if [ $? -eq 0 ]
then
#installing a simple starup script
cp /opt/retronas/dist/retronas /usr/local/bin/retronas
chmod a+x /usr/local/bin/retronas
echo
echo "All done. You can now run the RetroNAS config tool with the following command:"
echo
echo "retronas"
echo
else
echo "Installation FAILED, check previous messages"
fi
fi