36 lines
1.8 KiB
Bash
Executable File
36 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
SUBDOMAIN=$1
|
|
SUBNODOT=$(echo -n $1 | cut -d"." -f1- --output-delimiter="" )
|
|
|
|
if [[ -z "$SUBDOMAIN" ]]; then
|
|
echo "Set subdomain"
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z "$CTIPADDRESS" ]]; then
|
|
sed -i 's/CTIPADDRESS/'$CTIPADDRESS'/g' /etc/nginx/sites-available/subdomain.dmz.rs.proxy
|
|
mv /etc/nginx/sites-available/subdomain.dmz.rs.proxy /etc/nginx/sites-available/subdomain.dmz.rs.https
|
|
fi
|
|
|
|
sed -i 's/subdomain/'$SUBDOMAIN'/g' /etc/nginx/sites-available/subdomain.dmz.rs.http
|
|
sed -i 's/subdomain/'$SUBDOMAIN'/g' /etc/nginx/sites-available/subdomain.dmz.rs.https
|
|
sed -i 's/subnodot/'$SUBNODOT'/g' /etc/nginx/sites-available/subdomain.dmz.rs.http
|
|
sed -i 's/subnodot/'$SUBNODOT'/g' /etc/nginx/sites-available/subdomain.dmz.rs.https
|
|
|
|
|
|
mkdir /var/www/"$SUBNODOT"dmzrs/
|
|
mv /etc/nginx/sites-available/subdomain.dmz.rs.http /etc/nginx/sites-available/"$SUBDOMAIN".dmz.rs.http
|
|
mv /etc/nginx/sites-available/subdomain.dmz.rs.https /etc/nginx/sites-available/"$SUBDOMAIN".dmz.rs.https
|
|
ln -s /etc/nginx/sites-available/"$SUBDOMAIN".dmz.rs.http /etc/nginx/sites-enabled/"$SUBDOMAIN".dmz.rs.http
|
|
service nginx reload
|
|
certbot certonly -d "$SUBDOMAIN".dmz.rs,"$SUBDOMAIN".decentrala.org --webroot -w /var/www/"$SUBNODOT"dmzrs
|
|
unlink /etc/nginx/sites-enabled/"$SUBDOMAIN".dmz.rs.http
|
|
cat /etc/nginx/sites-available/"$SUBDOMAIN".dmz.rs.http /etc/nginx/sites-available/"$SUBDOMAIN".dmz.rs.https > /etc/nginx/sites-available/"$SUBDOMAIN".dmz.rs.all
|
|
mv /etc/nginx/sites-available/"$SUBDOMAIN".dmz.rs.all /etc/nginx/sites-available/"$SUBDOMAIN".dmz.rs
|
|
ln -s /etc/nginx/sites-available/"$SUBDOMAIN".dmz.rs /etc/nginx/sites-enabled/"$SUBDOMAIN".dmz.rs
|
|
rm /etc/nginx/sites-available/"$SUBDOMAIN".dmz.rs.https
|
|
rm /etc/nginx/sites-available/"$SUBDOMAIN".dmz.rs.http
|
|
service nginx reload
|
|
rm /root/remotecmd.sh
|