2024-01-05 10:42:17 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
SUBDOMAIN=$1
|
2024-01-22 16:02:28 +00:00
|
|
|
SUBNODOT=$(echo -n $1 | cut -d"." -f1- --output-delimiter="" )
|
2024-01-05 10:42:17 +00:00
|
|
|
|
|
|
|
if [[ -z "$SUBDOMAIN" ]]; then
|
|
|
|
echo "Set subdomain"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-01-22 16:02:28 +00:00
|
|
|
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
|
2024-01-05 10:42:17 +00:00
|
|
|
service nginx reload
|
2024-01-22 16:02:28 +00:00
|
|
|
certbot certonly -d "$SUBDOMAIN".dmz.rs,"$SUBDOMAIN".decentrala.org --webroot -w /var/www/"$SUBNODOT"dmzrs
|
2024-01-22 16:44:58 +00:00
|
|
|
unlink /etc/nginx/sites-enabled/"$SUBDOMAIN".dmz.rs.http
|
2024-01-22 16:02:28 +00:00
|
|
|
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
|
2024-01-22 16:44:58 +00:00
|
|
|
ln -s /etc/nginx/sites-available/"$SUBDOMAIN".dmz.rs /etc/nginx/sites-enabled/"$SUBDOMAIN".dmz.rs
|
2024-01-22 16:02:28 +00:00
|
|
|
rm /etc/nginx/sites-available/"$SUBDOMAIN".dmz.rs.https
|
|
|
|
rm /etc/nginx/sites-available/"$SUBDOMAIN".dmz.rs.http
|
2024-01-05 10:42:17 +00:00
|
|
|
service nginx reload
|
|
|
|
rm /root/remotecmd.sh
|