add uninstall

This commit is contained in:
2022-02-06 22:01:04 +01:00
parent 36bfacde18
commit 634c042f21

View File

@@ -39,14 +39,17 @@ def check_version():
## }
return str('.'.join(json.loads(mattermost_raw_version)['version'].split('.')[0:3]))
def systemd_stop_service(servicename):
print('Systemd stop %s' % servicename)
run('systemctl stop %s' % servicename)
def systemd_start_service(servicename):
print('Systemd start %s' % servicename)
run('systemctl start %s' % servicename)
def install():
print('Installing %s' % control.asrequirement())
@@ -184,6 +187,7 @@ def install():
f.truncate()
print('Create Mattermost server service')
jinja_env = jinja2.Environment(loader=jinja2.FileSystemLoader('templates'))
template = jinja_env.get_template('mattermost.service.j2')
@@ -211,6 +215,7 @@ def install():
print('Mattermost Server is installed !')
# Install Nginx if needed
if use_nginx:
#WAPT.install('{}-nginx'.format(control.package.split('-')[0]))
print('Install Nginx Web Server')
@@ -265,13 +270,33 @@ def install():
print('Create symlink to activate mattermost site')
if not os.path.exists('/etc/nginx/sites-enabled/mattermost.conf'):
print(run('ln -s /etc/nginx/sites-available/mattermost.conf /etc/nginx/sites-enabled/mattermost.conf'))
print(run('ln -s /etc/nginx/sites-available/mattermost.conf /etc/nginx/sites-enabled/mattermost.conf'))
print('Test Nginx configuration and start nginx')
print(run('nginx -t'))
print(run('systemctl restart nginx'))
print(run('systemctl enable nginx'))
def uninstall():
print('Uninstall Mattermost Server')
print("Warning ! This script doesn't remove Mysql Server or Postgresql Server")
systemd_stop_service('mattermost')
print('Remove nginx configuration files')
os.unlink(makepath('/etc','nginx','sites-enabled','mattermost.conf'))
remove_file(makepath('/etc','nginx','sites-avalables','mattermost.conf'))
print(run('nginx -t'))
print(run('systemctl restart nginx'))
print('Remove Mattermost Server Service')
remove_file(makepath('/lib','systemd','system','mattermost.service'))
run('systemctl daemon-reload')
print('Remove Mattermost server folder')
remove_tree(mattermost_path)
def audit():
installed_version = check_version()
@@ -284,7 +309,6 @@ def audit():
def update_package():
proxies = {}
if isfile(makepath(application_data(),'waptconsole','waptconsole.ini')):
proxywapt = inifile_readstring(makepath(user_local_appdata(),'waptconsole','waptconsole.ini'),'global','http_proxy')