Update README
This commit is contained in:
38
revert_v2.py
Normal file
38
revert_v2.py
Normal file
@ -0,0 +1,38 @@
|
||||
"""REVERT v2: Remove leftover lines 13-15 from gfil Nginx config"""
|
||||
import paramiko
|
||||
|
||||
JD_HOST = "111.228.37.165"
|
||||
JD_USER = "root"
|
||||
JD_PASS = "Liudecai110"
|
||||
|
||||
LAB_HOST = "216.144.233.14"
|
||||
LAB_USER = "root"
|
||||
LAB_PASS = "Kt9V72Tx2c48ChikKU"
|
||||
|
||||
jd = paramiko.SSHClient()
|
||||
jd.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
jd.connect(JD_HOST, port=22, username=JD_USER, password=JD_PASS,
|
||||
timeout=20, banner_timeout=60, allow_agent=False, look_for_keys=False)
|
||||
|
||||
# Precisely remove the 3 leftover lines
|
||||
revert_cmd = r"""sshpass -p 'Kt9V72Tx2c48ChikKU' ssh -o StrictHostKeyChecking=no root@216.144.233.14 '
|
||||
# Remove the 3 leftover lines from robots.txt block
|
||||
sed -i "/alias \/var\/www\/gfil-lab\/robots\.txt/d" /etc/nginx/sites-enabled/gfil
|
||||
sed -i "/default_type text\/plain/d" /etc/nginx/sites-enabled/gfil
|
||||
# Remove the orphan closing brace on its own line after the comment line
|
||||
sed -i "/^ }$/d" /etc/nginx/sites-enabled/gfil
|
||||
|
||||
echo "=== Final config ==="
|
||||
cat -n /etc/nginx/sites-enabled/gfil
|
||||
|
||||
nginx -t 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
systemctl reload nginx
|
||||
echo "SUCCESS: Nginx reloaded, config clean"
|
||||
else
|
||||
echo "STILL FAILING"
|
||||
fi
|
||||
'"""
|
||||
stdin, stdout, stderr = jd.exec_command(revert_cmd, timeout=30)
|
||||
print(stdout.read().decode())
|
||||
jd.close()
|
||||
Reference in New Issue
Block a user