-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·68 lines (51 loc) · 1.46 KB
/
install.sh
File metadata and controls
executable file
·68 lines (51 loc) · 1.46 KB
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
#!/bin/bash
set -e
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "This script must be run as root"
exit 1
fi
INSTALL_DIR=/opt/DWE_OS_2
SCRIPT_RUN_DIR=$PWD
# Check if a tag name was provided as an argument
if [ -z "$1" ]; then
VERSION="latest"
else
VERSION=$1
fi
if [ "$VERSION" == "latest" ]; then
echo "Installing DWE_OS 2 (latest release)"
DOWNLOAD_URL="https://github.com/DeepwaterExploration/DWE_OS_2/releases/latest/download/release.tar.gz"
else
echo "Installing DWE_OS 2 ($VERSION)"
DOWNLOAD_URL="https://github.com/DeepwaterExploration/DWE_OS_2/releases/download/$VERSION/release.tar.gz"
fi
wget $DOWNLOAD_URL -O release.tar.gz
tar -xvzf release.tar.gz
if [ -d "$INSTALL_DIR" ]; then
echo "$INSTALL_DIR does exist, deleting."
rm -rf $INSTALL_DIR
fi
mkdir -p ${INSTALL_DIR}
cp -r release/* ${INSTALL_DIR}
cd ${INSTALL_DIR}
sh install_requirements.sh &&
sh create_venv.sh &&
# check if the service is already running, and stop it if necessary
if systemctl is-active --quiet dwe_os_2; then
echo "Stopping currently running dwe_os_2 service..."
systemctl stop dwe_os_2
fi
# copy and enable service
cp ${INSTALL_DIR}/service/* /etc/systemd/system/
systemctl enable dwe_os_2
systemctl start dwe_os_2
# cleanup
cd $SCRIPT_RUN_DIR
rm -rf release
rm release.tar.gz
if [ "$VERSION" == "latest" ]; then
echo "Successfully installed DWE_OS 2 (latest version)"
else
echo "Successfully installed DWE_OS 2 ($VERSION)"
fi