From bff79467588899f46e1501d0dcfbdb8ccf5a6d74 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Sat, 15 Dec 2018 15:05:51 +0100 Subject: [PATCH] Revert using 7z.exe for extraction, and replace sc with service_start and service_stop --- WAPT/control | 4 ++-- setup.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/WAPT/control b/WAPT/control index 6255200..36d4496 100644 --- a/WAPT/control +++ b/WAPT/control @@ -1,11 +1,11 @@ package : fws-openssh -version : 7.7.2.0-4 +version : 7.7.2.0-5 architecture : all section : base priority : optional maintainer : Daniel Berteaud description : OpenSSH for Windows -depends : +depends : fws-7zip conflicts : maturity : DEV locale : diff --git a/setup.py b/setup.py index 11b8a1b..b5a847b 100644 --- a/setup.py +++ b/setup.py @@ -8,25 +8,27 @@ def install(): print('Installing OpenSSH') mkdirs(makepath(programfiles,'OpenSSH')) print(' Stoping the service') - run_notfatal(r'sc stop sshd') - killalltasks('sshd.exe') + if service_installed('sshd') and service_is_running('sshd'): + service_stop('sshd') + killalltasks('sshd.exe') print(' Extract OpenSSH archive') - unzip('OpenSSH-Win%s.zip' % '64' if iswin64() else '32',makepath(programfiles,'OpenSSH')) + run('"%s" e -y -o"%s" OpenSSH-Win%s.zip' % (makepath(programfiles,'7-Zip','7z.exe'),makepath(programfiles,'OpenSSH'),'64' if iswin64() else '32')) print(' Installing the service') run(r'powershell.exe -ExecutionPolicy Bypass -File "%s\install-sshd.ps1"' % makepath(programfiles,'OpenSSH')) print(' Opening port 22 in the firewall') run_notfatal(r'netsh advfirewall firewall del rule name="OpenSSH Server"') run(r'netsh advfirewall firewall add rule name="OpenSSH Server" dir=in action=allow protocol=TCP localport=22 enable=yes') print(' Starting the service') - run(r'sc start sshd', accept_returncodes=[0,1056]) + service_start('sshd') print(r' Enabling sshd service on boot') run('sc config sshd start= auto') def uninstall(): print('Removing OpenSSH') print(' Stoping the service') - run_notfatal('sc stop sshd') - killalltasks('ssh.exe') + if service_is_running('sshd'): + service_stop('sshd') + killalltasks('sshd.exe') print(' Uninstalling the service') run(r'powershell.exe -ExecutionPolicy Bypass -File "%s\uninstall-sshd.ps1"' % makepath(programfiles,'OpenSSH')) print(' Removing files')