1
|
#! /usr/bin/perl -w
|
2
|
|
3
|
# All rights reserved and Copyright (c) 2020 Origo Systems ApS.
|
4
|
# This file is provided with no warranty, and is subject to the terms and conditions defined in the license file LICENSE.md.
|
5
|
# The license file is part of this source code package and its content is also available at:
|
6
|
# https://www.origo.io/info/stabiledocs/licensing/stabile-open-source-license
|
7
|
|
8
|
use strict;
|
9
|
use Debconf::Client::ConfModule qw(:all);
|
10
|
|
11
|
my $cmd = shift if $ARGV[0];
|
12
|
|
13
|
# Debconf does not like us printing to STDOUT so we print to STDERR if we need to say something
|
14
|
my $out = *STDERR;
|
15
|
|
16
|
if ($cmd eq 'purge') {
|
17
|
# Remove systemd units
|
18
|
my $service = "pressurecontrol";
|
19
|
print $out `systemctl stop $service`;
|
20
|
print $out `systemctl disable $service`;
|
21
|
# print $out `rm /etc/systemd/system/$service.service`;
|
22
|
# print $out `rm /etc/systemd/system/multi-user.target.wants/$service.service`;
|
23
|
|
24
|
$service = "movepiston";
|
25
|
print $out `systemctl stop $service`;
|
26
|
print $out `systemctl disable $service`;
|
27
|
# print $out `rm /etc/systemd/system/$service.service`;
|
28
|
# print $out `rm /etc/systemd/system/multi-user.target.wants/$service.service`;
|
29
|
|
30
|
print $out `systemctl daemon-reload`;
|
31
|
|
32
|
# Remove database
|
33
|
`echo "DROP DATABASE steamregister;" | mysql`;
|
34
|
|
35
|
# Unconfigure Apache
|
36
|
`rm "/etc/apache2/sites-available/stabile-ssl.conf"` if (-e "/etc/apache2/sites-available/stabile-ssl.conf");
|
37
|
`rm "/etc/apache2/sites-enabled/stabile-ssl.conf"` if (-e "/etc/apache2/sites-enabled/stabile-ssl.conf");
|
38
|
`perl -pi -e 's/.*include.+stabile.*\\\n//si;' /etc/apache2/sites-available/000-default.conf`;
|
39
|
`systemctl restart apache2`;
|
40
|
`rm /etc/apache2/ssl/stabile.*`;
|
41
|
|
42
|
# Unconfigure dhcpd
|
43
|
`perl -pi -e 's/.*include.+stabile.*\\\n//si;' /etc/dhcp/dhcpd.conf`;
|
44
|
|
45
|
# Unconfigure tftpd
|
46
|
`perl -pi -e 's/.*TFTP_DIRECTORY=.+stabile.*\\\n//si;' /etc/default/tftpd-hpa`;
|
47
|
`perl -pi -e 's/#(.*TFTP_DIRECTORY=.+)/\$1/i;' /etc/default/tftpd-hpa`;
|
48
|
|
49
|
# Unconfigure nfs
|
50
|
`perl -pi -e 's/.*\\\/stabile.+\\\n//si;' /etc/exports`;
|
51
|
|
52
|
# Unconfigure Guacamole
|
53
|
unlink("/etc/guacamole/extensions/guacamole-auth-stabile-0.9.14.jar") if (-e "/etc/guacamole/extensions/guacamole-auth-stabile-0.9.14.jar");
|
54
|
|
55
|
# Unconfigure ntpd
|
56
|
`perl -pi -e 's/listen on 10.0.0.1\\\n//si;' /etc/openntpd/ntpd.conf`;
|
57
|
|
58
|
# Remove directories
|
59
|
`rm /usr/share/stabile/openssl.config`;
|
60
|
`rm /usr/local/bin/config_data`if (-e "/usr/local/bin/config_data");
|
61
|
`rm /mnt/stabile/images/irigo/.htaccess` if (-e "/mnt/stabile/images/irigo/.htaccess");
|
62
|
`rm -r /etc/stabile`;
|
63
|
`rm -r /mnt/stabile`;
|
64
|
`rm -r /var/www/stabile` if (-e "/var/www/stabile");
|
65
|
`rm /usr/share/applications/stabile.desktop` if (-e "/usr/share/applications/stabile.desktop");
|
66
|
|
67
|
# Clear debconf db
|
68
|
# set('stabile/hostname');
|
69
|
# set('stabile/initial_user');
|
70
|
# set('stabile/initial_password');
|
71
|
|
72
|
# Clear debconf
|
73
|
# `echo PURGE | debconf-communicate stabile`;
|
74
|
purge();
|
75
|
}
|