parent
edd8ec6d05
commit
114218cf17
5 changed files with 393 additions and 0 deletions
Binary file not shown.
Binary file not shown.
@ -0,0 +1,32 @@ |
||||
package : fws-openssh |
||||
version : 7.7.2.0-1 |
||||
architecture : all |
||||
section : base |
||||
priority : optional |
||||
maintainer : Daniel Berteaud <daniel@firewall-services.com> |
||||
description : OpenSSH for Windows |
||||
depends : |
||||
conflicts : |
||||
maturity : DEV |
||||
locale : |
||||
target_os : windows |
||||
min_os_version : 6.1 |
||||
max_os_version : |
||||
min_wapt_version : 1.5 |
||||
sources : |
||||
installed_size : |
||||
impacted_process : sshd.exe,ssh.exe |
||||
description_fr : OpenSSH pour WIndows |
||||
description_pl : |
||||
description_de : |
||||
description_es : |
||||
audit_schedule : 2d |
||||
editor : |
||||
keywords : ssh |
||||
licence : |
||||
homepage : https://github.com/PowerShell/Win32-OpenSSH |
||||
package_uuid : |
||||
signer : Daniel Berteaud |
||||
signer_fingerprint: |
||||
signature_date : |
||||
signed_attributes : |
@ -0,0 +1,60 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from setuphelpers import * |
||||
import requests,json |
||||
|
||||
uninstallkey = [] |
||||
|
||||
def install(): |
||||
print('Installing OpenSSH') |
||||
mkdirs(makepath(programfiles,'OpenSSH')) |
||||
print(' Stoping the service') |
||||
run_notfatal(r'sc stop sshd') |
||||
print(' Extract OpenSSH archive') |
||||
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]) |
||||
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') |
||||
print(' Uninstalling the service') |
||||
run(r'powershell.exe -ExecutionPolicy Bypass -File "%s\uninstall-sshd.ps1"' % makepath(programfiles,'OpenSSH')) |
||||
print(' Removing files') |
||||
remove_tree(makepath(programfiles,'OpenSSH')) |
||||
|
||||
def update_package(): |
||||
print('Updating OpenSSH Package') |
||||
latest = json.loads(requests.get('https://api.github.com/repos/PowerShell/Win32-OpenSSH/releases/latest').text.encode('utf-8')) |
||||
version = latest['tag_name'].split('-',1)[0].lstrip('v').rstrip('p1') |
||||
pe = PackageEntry(); |
||||
control = pe.load_control_from_wapt('.') |
||||
for arch in ['32','64']: |
||||
for asset in latest['assets']: |
||||
if asset['name'] == 'OpenSSH-Win%s.zip' % arch and not isfile('OpenSSH-Win%s.zip' % arch): |
||||
url = asset['browser_download_url'] |
||||
print('Downloading OpenSSH %s for win%s from %s' % (version,arch,url)) |
||||
wget(url,'OpenSSH-Win%s.zip' % arch) |
||||
if Version(version) > Version(control['version'].split('-',1)[0]): |
||||
print('Updating control file with new version %s' % version) |
||||
pe.version = version + '-0' |
||||
pe.save_control_to_wapt('.') |
||||
|
||||
def audit(): |
||||
version = control['version'].split('-',1)[0] |
||||
installed_version = get_file_properties(makepath(programfiles,'OpenSSH','sshd.exe'))['FileVersion'] |
||||
if Version(version) != Version(installed_version): |
||||
print('Installed version %s does not match version %s' % (version, installed_version)) |
||||
return "ERROR" |
||||
return "OK" |
||||
|
||||
if __name__ == '__main__': |
||||
update_package() |
Loading…
Reference in new issue