-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathmain.sh
71 lines (58 loc) · 2.4 KB
/
main.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
#!/bin/bash
# check for docker
if ! [ -x "$(command -v docker)" ]; then
echo 'Error: Docker must be installed for this script to work. Please refer to the documentation for details.' >&2
exit 1
fi
# check for docker-compose
# if the output of the command docker compose is "docker: 'compose' is not a docker command." then docker-compose is not installed
if [ "$(docker compose)" = "docker: 'compose' is not a docker command." ]; then
echo 'Error: Docker Compose must be installed for this script to work. Please refer to the documentation for details.' >&2
exit 1
fi
# check for git
if ! [ -x "$(command -v git)" ]; then
echo 'Error: Git must be installed for this script to work. Please refer to the documentation for details.' >&2
exit 1
fi
# check for nano
if ! [ -x "$(command -v nano)" ]; then
echo 'Error: Nano must be installed for this script to work. Please refer to the documentation for details.' >&2
exit 1
fi
# check to make sure that the user is running this script as root
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root. Please run it as root." 1>&2
exit 1
fi
# ensure the user has at least 10 GB of free space
if [ "$(df -BG / | awk 'NR==2 {print $4}' | sed 's/G//')" -lt "10" ]; then
echo "You do not have enough free space to run this script. Please free up at least 10 GB of space and try again." 1>&2
exit 1
fi
# ask the user if they would like to proceed
echo "This script will install the latest version of the open source version of the Kazwire. It will also install bare-server and Caddy. Would you like to proceed? (Y/n)"
read -r proceed
if [ "$proceed" = "n" ]; then
echo "Exiting..."
exit 0
fi
# clone the repository
git clone https://github.com/whos-evan/kazwire.git
# prompt the user to change the domain name in the caddyfile
echo "Please change the domain name in the Caddyfile to your domain name that is pointed to this server. Please also ensure that the server has the ports 443 and 80 open. Press enter to continue."
read -r
nano caddy/Caddyfile
# prompt the user to continue
echo "Do you want to continue with the installation? (Y/n)"
read -r proceed
if [ "$proceed" = "n" ]; then
echo "Exiting..."
exit 0
fi
# run the docker compose file
echo "Pulling the latest images and starting the containers..."
docker compose pull
docker compose up -d
# tell the user that the script has finished
echo "The script has finished. Please visit your domain name!"