diff options
author | Hugo Doria <hugodoria@archlinux-br.org> | 2007-12-12 02:32:07 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2007-12-12 23:40:58 +0100 |
commit | ee02c935d5fe4e513b42e614bc543e62aa453f0f (patch) | |
tree | b50caa322f396611a1fcb8e63d42068349983515 | |
parent | 3370d4cfa2b0addc6240b5a6b815bcb34d8987f8 (diff) |
Fix services saving in ArchLinux.
-rw-r--r-- | Init/Services.pm | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/Init/Services.pm b/Init/Services.pm index 675262f..0e0c139 100644 --- a/Init/Services.pm +++ b/Init/Services.pm @@ -978,19 +978,31 @@ sub set_archlinux_service_status my ($script, $active) = @_; my $rcconf = '/etc/rc.conf'; my ($daemons); + $daemons = &Utils::Parse::get_sh ($rcconf, "DAEMONS"); - $daemons =~ s/[()]//; + $daemons =~ s/[\(\)]//g; + + # escape these chars + $script =~ s/([\\\.\^\$\*\+\?\{\}\[\]\(\)\|])/\\\1/g; + $notscript = "\!" . $script; - if (($daemons =~ m/$script/) && !$active) + if (($daemons =~ m/$notscript/) && $active) + { + # It was disabled, enable it + $daemons =~ s/$notscript/$script/g; + } + elsif (($daemons =~ m/$script/) && !$active) { - $daemons =~ s/$script[ \t]*//; + # It was enabled, disable it + $daemons =~ s/$script/$notscript/g; } elsif (($daemons !~ m/$script/) && $active) { - $daemons =~ s/network/network $script/g; + $daemons .= " ".$script; } - &Utils::Replace::set_sh ($rcconf, "DAEMONS", "($daemons)", 1); + $daemons = "(" . $daemons . ")"; + &Utils::Replace::set_sh ($rcconf, "DAEMONS", $daemons, 1); &run_rcng_script ($service, ($active) ? "start" : "stop"); } |