ssh: Cleanup permanent ssh patch
parent
c868bb410c
commit
f428bc449e
@ -1,9 +1,16 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
grep -v "/ssh_patch.sh" /etc/crontabs/root > /etc/crontabs/root.new
|
DIR_PATCH=/etc/crontabs/patches
|
||||||
mv /etc/crontabs/root.new /etc/crontabs/root
|
|
||||||
/etc/init.d/cron restart
|
|
||||||
|
|
||||||
rm -f /etc/crontabs/patches/ssh_patch.sh
|
if grep -q '/ssh_patch.sh' /etc/crontabs/root ; then
|
||||||
|
# remove older version of patch
|
||||||
|
grep -v "/ssh_patch.sh" /etc/crontabs/root > /etc/crontabs/root.new
|
||||||
|
mv /etc/crontabs/root.new /etc/crontabs/root
|
||||||
|
/etc/init.d/cron restart
|
||||||
|
fi
|
||||||
|
uci delete firewall.auto_ssh_patch
|
||||||
|
uci commit firewall
|
||||||
|
|
||||||
|
rm -f $DIR_PATCH/ssh_patch.sh
|
||||||
rm -f /tmp/ssh_patch.log
|
rm -f /tmp/ssh_patch.log
|
||||||
|
|
||||||
|
|||||||
@ -1,53 +1,41 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
import xmir_base
|
|
||||||
import gateway
|
import xmir_base
|
||||||
from gateway import die
|
from gateway import *
|
||||||
|
|
||||||
|
gw = Gateway()
|
||||||
gw = gateway.Gateway()
|
|
||||||
|
FN_patch = 'data/ssh_patch.sh'
|
||||||
fn_dir = 'data/'
|
fn_patch = '/tmp/ssh_patch.sh'
|
||||||
fn_local = 'data/ssh_patch.sh'
|
FN_install = 'data/ssh_install.sh'
|
||||||
fn_remote = '/tmp/ssh_patch.sh'
|
fn_install = '/tmp/ssh_install.sh'
|
||||||
fn_local_i = 'data/ssh_install.sh'
|
FN_uninstall = 'data/ssh_uninstall.sh'
|
||||||
fn_remote_i = '/tmp/ssh_install.sh'
|
fn_uninstall = '/tmp/ssh_uninstall.sh'
|
||||||
fn_local_u = 'data/ssh_uninstall.sh'
|
|
||||||
fn_remote_u = '/tmp/ssh_uninstall.sh'
|
action = 'install'
|
||||||
|
if len(sys.argv) > 1:
|
||||||
action = 'install'
|
if sys.argv[1].startswith('u') or sys.argv[1].startswith('r'):
|
||||||
if len(sys.argv) > 1:
|
action = 'uninstall'
|
||||||
if sys.argv[1].startswith('u') or sys.argv[1].startswith('r'):
|
|
||||||
action = 'uninstall'
|
if action == 'install':
|
||||||
|
gw.upload(FN_patch, fn_patch)
|
||||||
if action == 'install':
|
gw.upload(FN_install, fn_install)
|
||||||
gw.upload(fn_local, fn_remote)
|
|
||||||
gw.upload(fn_local_i, fn_remote_i)
|
gw.upload(FN_uninstall, fn_uninstall)
|
||||||
|
|
||||||
gw.upload(fn_local_u, fn_remote_u)
|
print("All files uploaded!")
|
||||||
|
|
||||||
print("All files uploaded!")
|
print("Run scripts...")
|
||||||
'''
|
run_script = fn_install if action == 'install' else fn_uninstall
|
||||||
if action == 'install':
|
gw.run_cmd(f"chmod +x {run_script} ; {run_script}")
|
||||||
gw.ssh_close()
|
|
||||||
import passw
|
time.sleep(1.5)
|
||||||
gw = gateway.Gateway()
|
|
||||||
if not gw.ping():
|
gw.run_cmd(f"rm -f {fn_patch} ; rm -f {fn_install} ; rm -f {fn_uninstall}")
|
||||||
die('SSH not active!')
|
|
||||||
'''
|
print("Ready! The Permanent SSH patch installed.")
|
||||||
|
|
||||||
print("Run scripts...")
|
|
||||||
if action == 'install':
|
|
||||||
gw.run_cmd("sh " + fn_remote_i)
|
|
||||||
else:
|
|
||||||
gw.run_cmd("sh " + fn_remote_u)
|
|
||||||
|
|
||||||
gw.run_cmd("rm -f " + fn_remote)
|
|
||||||
gw.run_cmd("rm -f " + fn_remote_i)
|
|
||||||
gw.run_cmd("rm -f " + fn_remote_u)
|
|
||||||
|
|
||||||
print("Ready! The SSH patch installed.")
|
|
||||||
|
|||||||
Loading…
Reference in New Issue