/[soft]/drakwizard/trunk/common/Wizcommon.pm
ViewVC logotype

Contents of /drakwizard/trunk/common/Wizcommon.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8720 - (show annotations) (download)
Fri Aug 23 23:53:27 2013 UTC (10 years, 8 months ago) by djennings
File size: 2701 byte(s)
- fix race condition checking service status (mga#10934)
- fix directory definition in proxy wizard
- fix parameter format in proxy wizard
- updated default proxy config file

1 #!/usr/bin/perl
2
3 # Copyright (C) 2003 Mandrakesoft
4 #
5 # Author: Florent Villard <warly@mandrakesoft.com>
6 # A Ginies
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
11 # any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
22 package MDK::Wizard::Wizcommon;
23 use strict;
24 use standalone;
25 use common;
26 use services;
27 use MDK::Common;
28 use MDK::Wizard::IFCFG;
29
30 our @ISA = qw(Exporter);
31 our @EXPORT = qw(check_started check_starts_on_boot test_host_domain reload_or_restart);
32
33 sub check_dhcp {
34 my ($wiz) = @_;
35 $wiz->{net}->is_dhcp and return 'dhcp_warning';
36 }
37
38 sub new {
39 my ($class) = @_;
40 bless {
41 net => MDK::Wizard::IFCFG->new,
42 }, $class;
43 }
44
45 sub check_started {
46 my ($service) = @_;
47 my ($isrunning) = services::is_service_running($service);
48 return 'error_end' if !$isrunning;
49 }
50
51 sub reload_or_restart {
52 my ($service) = @_;
53 if (run_program::rooted($::prefix, '/bin/mountpoint', '-q', '/sys/fs/cgroup/systemd')) {
54 run_program::rooted($::prefix, '/bin/systemctl', 'reload-or-restart', "$service.service");
55 } else {
56 run_program::rooted($::prefix, "/etc/rc.d/init.d/$service", "restart");
57 }
58 }
59
60 sub check_starts_on_boot($$) {
61 my ($in, $servicename) = @_;
62 if (!services::starts_on_boot($servicename)) {
63 my $start_service = $in->ask_yesorno(N("Start %s server on boot", $servicename), N("Would you like to start the %s service automatically on every boot?", $servicename), 1);
64 if ($start_service) {
65 services::start_service_on_boot($servicename);
66 }
67 }
68 }
69
70 sub test_host_domain {
71 my ($SHORTHOSTNAME, $DOMAINNAME) = @_;
72 if ($SHORTHOSTNAME =~ /localhost/) {
73 return 0, N("You need to readjust your hostname. 'localhost' is not a correct hostname for a DNS server. Hostname must be a FQDN: Fully Qualified Domain Name");
74 }
75 if (member($DOMAINNAME, qw(localdomain (none))) && -z $DOMAINNAME) {
76 return 0, N("You need to readjust your domainname. For a DNS server you need a correct domainname, not equal to localdomain or none. Hostname must be a FQDN: Fully Qualified Domain Name. Launch drakconnect to adjust it.");
77 }
78 return 1;
79 }
80
81 1;

  ViewVC Help
Powered by ViewVC 1.1.30