This repository has been archived by the owner on Oct 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathstackscript.sh
110 lines (87 loc) · 3.36 KB
/
stackscript.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
104
105
106
107
108
109
110
#!/bin/bash
# <UDF name="website" Label="Website" example="passky.domain.com" />
# <UDF name="email" Label="Email Address" example="info@rabbit-company.com" />
# <UDF name="adminuser" Label="Admin Username" />
# <UDF name="admin_password" Label="Admin Password" />
# Motd
cat << EOF > /etc/motd
_____ _
| __ \ | |
| |__) |_ _ ___ ___| | ___ _
| ___/ _\` / __/ __| |/ / | | |
| | | (_| \__ \__ \ <| |_| |
|_| \__,_|___/___/_|\_\\__, |
__/ |
|___/
Installing...
Please logout and come back in few minutes.
EOF
## REQUIRED IN EVERY MARKETPLACE SUBMISSION
# Add Logging to /var/log/stackscript.log for future troubleshooting
exec > >(tee /dev/ttyS0 /var/log/stackscript.log) 2>&1
# System Updates updates
apt-get -o Acquire::ForceIPv4=true update -y
DEBIAN_FRONTEND=noninteractive apt-get -y -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" install grub-pc
apt-get -o Acquire::ForceIPv4=true update -y
## END OF REQUIRED CODE FOR MARKETPLACE SUBMISSION
## Import the Bash StackScript Library
source <ssinclude StackScriptID=1>
# Install docker compose
system_install_package docker-compose
#
# Passky Server
#
wget https://github.com/Rabbit-Company/Passky-Server/releases/latest/download/passky-server.tar.xz
tar -xf passky-server.tar.xz
cd passky-server
cp .env.example .env
SERVER_CORES=$(grep -c ^processor /proc/cpuinfo)
IP_ADDRESS=$(system_primary_ip)
sed -i "s/SERVER_CORES=1/SERVER_CORES=$SERVER_CORES/g" .env
sed -i "s/ADMIN_USERNAME=admin/ADMIN_USERNAME=$ADMINUSER/g" .env
sed -i "s/ADMIN_PASSWORD=/ADMIN_PASSWORD=$ADMIN_PASSWORD/g" .env
docker-compose up -d
apache_install
a2enmod proxy && a2enmod proxy_http && systemctl restart apache2
echo "<VirtualHost *:80>" > /etc/apache2/sites-available/$WEBSITE.conf
echo " ProxyPreserveHost On" >> /etc/apache2/sites-available/$WEBSITE.conf
echo " ProxyRequests Off" >> /etc/apache2/sites-available/$WEBSITE.conf
echo " ServerName $WEBSITE" >> /etc/apache2/sites-available/$WEBSITE.conf
echo " ProxyPass / http://localhost:8080/" >> /etc/apache2/sites-available/$WEBSITE.conf
echo " ProxyPassReverse / http://localhost:8080/" >> /etc/apache2/sites-available/$WEBSITE.conf
echo "</VirtualHost>" >> /etc/apache2/sites-available/$WEBSITE.conf
a2ensite "$WEBSITE"
systemctl restart apache2
# Install SSL
system_install_package python3-certbot-apache
cat << EOF > /usr/local/bin/installCert
#!/bin/bash
if ! certbot -n --apache --agree-tos --redirect -d $WEBSITE -m $EMAIL; then
echo "There was a problem while installing SSL certificate. Make sure your A record for domain: $WEBSITE does redirect to IP: $IP_ADDRESS"
else
echo "Certificate installed successfully."
fi
EOF
chmod +x /usr/local/bin/installCert
# Configure auto-renewal for the certificate
crontab -l > cron
echo "0 4 * * * /usr/bin/certbot renew" >> cron
crontab cron
rm cron
stackscript_cleanup
# Motd
cat << EOF > /etc/motd
_____ _
| __ \ | |
| |__) |_ _ ___ ___| | ___ _
| ___/ _\` / __/ __| |/ / | | |
| | | (_| \__ \__ \ <| |_| |
|_| \__,_|___/___/_|\_\\__, |
__/ |
|___/
Admin Panel:
Link: http://$IP_ADDRESS (https://$WEBSITE)
Username: $ADMINUSER
Password: $ADMIN_PASSWORD
To install SSL certificate please run command: installCert
EOF