-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquickinstall.sh
executable file
·75 lines (63 loc) · 1.76 KB
/
quickinstall.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
#!/usr/bin/env bash
# Currently this should not be changed; stay tuned
INSTALL_DIR="/opt"
function verify_root {
if [[ $(whoami) != 'root' ]]; then
echo "You must be root to install this program"
exit 1
fi
}
function verify_requirements {
export CURL_EXEC=$(command -v curl)
if [[ $CURL_EXEC == '' ]]; then
echo "Please install curl and retry the installation script"
exit 1
fi
export TAR_EXEC=$(command -v tar)
if [[ $TAR_EXEC == '' ]]; then
echo "Please install tar and retry the installation script"
exit 1
fi
}
function prepare_install_root {
mkdir -p "$INSTALL_DIR"
}
function download_release {
RELEASE_URL=$($CURL_EXEC -s https://api.github.com/repos/Cesura/avologo/releases/latest | grep browser_download_url | cut -d'"' -f4)
export PACKAGE_NAME=${RELEASE_URL##*/}
echo "Downloading latest release..."
$CURL_EXEC -L -s -O "$RELEASE_URL"
}
function extract_release {
echo "Extracting archive..."
$TAR_EXEC xf "$PACKAGE_NAME" -C "$INSTALL_DIR"
}
function copy_config {
echo "Copying sample config file..."
cp -n "$INSTALL_DIR/avologo/avologo.conf.example" /etc/avologo.conf
}
function prepare_systemd {
if [[ $(command -v systemctl) != "" ]]; then
echo "Preparing systemd..."
cp $INSTALL_DIR/avologo/systemd/* /etc/systemd/system/
systemctl daemon-reload
fi
}
function success_message {
echo "Done!"
SHORT_PKG=${PACKAGE_NAME%.tar.gz}
echo "You have successfully installed $SHORT_PKG"
echo "Please configure avologo in /etc/avologo.conf and then run:"
echo -e "\tsystemctl start avologo-server"
echo "or"
echo -e "\tsystemctl start avologo-client"
}
# Entry point
verify_root
verify_requirements
download_release
prepare_install_root
extract_release
copy_config
prepare_systemd
success_message