-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-domain.sh
86 lines (72 loc) · 2.04 KB
/
init-domain.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
#!/usr/bin/env bash
echo ""
echo ""
echo " _____ _ _____ _____ _ _ "
echo " | __ \ | |/ ____/ ____| | | | "
echo " | |__) |_ _ _ __ ___| | (___| (___ | |__| | "
echo " | ___/ _' | '_ \ / _ \ |\___ \\___ \| __ | "
echo " | | | (_| | | | | __/ |____) |___) | | | | "
echo " |_| \__,_|_| |_|\___|_|_____/_____/|_| |_| "
echo ""
echo ""
echo ''
echo ' > ------------------------------------------------------------'
echo ' > Run script: init-domain.sh'
echo ' > Short link: https://git.io/panelssh-init-domain'
echo ' > Repository: https://github.com/panelssh/installer-script.git'
echo ' > Created by: Panel SSH <[email protected]>'
echo ' > ------------------------------------------------------------'
echo ''
# init vars
DOMAIN="panelssh.com"
WWW=0
while [ $# -gt 0 ]; do
case "$1" in
-d|--domain)
DOMAIN="$2"
;;
-w|--www)
WWW=$2
;;
-h|--help)
echo "FLAGS:"
echo " -h, --help Prints help information"
echo ""
echo "OPTIONS:"
echo " -d, --domain <value> Set Domain"
echo " [default: $DOMAIN]"
echo " -w, --www <value> Append www"
echo " [default: $WWW]"
exit 1
;;
esac
shift
done
# Add Site
echo ' > Add Site ...'
if [ "$WWW" -eq "1" ]; then
SERVER_NAME="$DOMAIN www.$DOMAIN"
else
SERVER_NAME=$DOMAIN
fi
cat > /etc/nginx/sites-available/${DOMAIN}.conf <<EOL
server {
server_name $SERVER_NAME;
location / {
return 403;
}
}
EOL
# Symlink site
echo ' > Symlink site...'
ln -sf /etc/nginx/sites-available/${DOMAIN}.conf /etc/nginx/sites-enabled
# Restart nginx
echo ' > Restart nginx...'
service nginx restart
# Instal SSL
echo ' > Install SSL...'
if [ "$WWW" -eq "1" ]; then
certbot --nginx --redirect --expand -d ${DOMAIN} -d www.${DOMAIN} --register-unsafely-without-email --non-interactive --agree-tos
else
certbot --nginx --redirect -d ${DOMAIN} --register-unsafely-without-email --non-interactive --agree-tos
fi