rcconf-3.1ubuntu1/0000755000000000000000000000000012240061370011034 5ustar rcconf-3.1ubuntu1/update-rcconf-guide0000755000000000000000000001437412240061175014623 0ustar #!/usr/bin/perl -w # update-rcconf-guide # Copyright (c) 2004-2009 kamop@debian.org # =head1 NAME update-rcconf-guide - Create default guide file for rcconf =head1 SYNOPSIS B =head1 DESCRIPTION B creates the default guide file which B uses. B searches the package names corresponding to each service file in /etc/init.d directory from dpkg info files(/var/lib/dpkg/info/*.list) and get the description of these packages using apt-cache. B uses Short-Description in priority to the description if service files has Short-Description field. B writes those results to /var/lib/rcconf/guide.default file. You can write your own guide in user guide file(/var/lib/rcconf/guide) by hand. B refers Guides in /var/lib/rcconf/guide before those in /var/lib/rcconf/guide.default. If you install some packages after executed B, you need to re-create this file using B so as to refresh guide.default that includes new guides for installed new services. Notice: B was not executed when you installed B package. =head1 FILE =over 8 =item /var/lib/rcconf/guide.default Guide File update-rcconf-guide generates. =item /var/lib/rcconf/guide Guide File user(Administrator) can define. =back =head1 SEE ALSO rcconf(8) =head1 AUTHOR Atsushi KAMOSHIDA =cut use strict; use FileHandle; use DirHandle; my @unselects = ("\^\\\.\$", "\^\\\.\\\.\$", "\^rc\$", "\^rcS\$", "\^README\$", "\^skeleton\$", ".*\\\.dpkg-dist\$", ".*\\\.dpkg-old\$", ".*\\\.dpkg-bak\$", ".*\\\.sh\$"); my $APTCACHE_BIN = "/usr/bin/apt-cache"; my $GREP_BIN = "/bin/grep"; my $RCCONF_DIR = "/var/lib/rcconf"; my $GUIDE_FILE = $RCCONF_DIR."/guide.default"; my $INITD_DIR = "/etc/init.d"; if ( ! -d $RCCONF_DIR ) { die "Can't file rcconf dir($RCCONF_DIR).\n"; } print "Reading $INITD_DIR and getting package description ...\n"; my $initd_files_array = &read_initd_dir($INITD_DIR); my $filepath_hash = &create_dpkg_installed_filepath("/var/lib/dpkg/info"); print "Writing package default guide to $GUIDE_FILE ...\n"; my $fh = FileHandle->new(">".$GUIDE_FILE); if ( ! defined($fh) ) { die "Can't open file: $GUIDE_FILE .\n"; } my $path; my $description_header; foreach my $initd_file ( @{$initd_files_array} ) { # print $initd_file."\n"; next if ( &check_unselect($initd_file, \@unselects) == 1 ); # print $initd_file."\n"; $path = $INITD_DIR."/".$initd_file; next if ( ! exists($filepath_hash->{$path}) ); $description_header = &get_description_header($filepath_hash->{$path}, $path) // ''; if ( $description_header ne "" ) { print $fh $initd_file." ".$description_header."\n"; } } undef $fh; print "Done.\n"; exit; ####################################################################### ## MODULE: get_description_header ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub get_description_header { my ($package, $path) = @_; ## if ( $package eq "" ) { die "arg(package) is null.\n"; } ## First, try to get Short-Description my $line = `$GREP_BIN '^\# Short-Description:' $path`; if ( $line ne "" ) { $line =~ /^\# Short-Description:\s*(.*)/; return $1; } if ( $package eq "tinyproxy" ) { printf "%s %s %s\n", $package, $path, $line; exit 1; } $line = `$APTCACHE_BIN show $package | $GREP_BIN '^Description:'`; $line =~ /^Description:\s*(.*)/; return $1; } ## get_description_header ####################################################################### ## MODULE: check_unselect ## DESC: Check if 'file' exists in unselects array. ## IN: ## OUT: results 0 := file is not in the array. ## 1 := file exists in the array. ## OP: ## STATUS: ## END: sub check_unselect{ my ($file, $unselects) = @_; ## return 1 if ( ! -x $INITD_DIR . "/" . $file ); my $unselect; foreach $unselect ( @{$unselects} ) { return 1 if ( $file =~ /$unselect/ ); } return 0; } ## check_unselect ####################################################################### ## MODULE: read_initd_dir ## DESC: Collect files in init.d/ directory. ## IN: ## OUT: ## OP: ## STATUS: ## END: sub read_initd_dir{ my ($initd_dir) = @_; ## if ( ( $initd_dir eq "" ) || ( ! -d $initd_dir ) ) { die "No such directory: $initd_dir .\n"; } my $dh = DirHandle->new($initd_dir); if ( ! defined($dh) ) { die "No such directory: $initd_dir .\n"; } my $file; my @dirs = (); while ( defined($file = $dh->read()) ) { push(@dirs, $file); } undef $dh; return(\@dirs); } ## read_initd_dir ####################################################################### ## MODULE: read_initd_dir ## DESC: Collect files in inet.d/ directory. ## IN: ## OUT: ## OP: ## STATUS: ## END: sub create_dpkg_installed_filepath { my ($info_dir) = @_; ## if ( ( $info_dir eq "" ) || ( ! -d $info_dir ) ) { die "No such directory: $info_dir .\n"; } my $dh = DirHandle->new($info_dir); if ( ! defined($dh) ) { die "Can't open directory: $info_dir .\n"; } my $file; my $package; my %filepath_hash = (); while ( defined($file = $dh->read()) ) { if ( $file =~ /(.*)\.list$/ ) { $package = $1; # print "$package $file\n"; &insert_filepath($info_dir."/".$file, \%filepath_hash, $package); } } undef $dh; return(\%filepath_hash); } ## create_dpkg_installed_filepath ####################################################################### ## MODULE: insert_filepath ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub insert_filepath { my ($info_filelist_file, $filepath_hash, $package) = @_; ## if ( ( $info_filelist_file eq "" ) || ( ! -f $info_filelist_file ) ) { die "No such directory: $info_filelist_file.\n"; } if ( ref($filepath_hash) ne "HASH" ) { die "arg(filepath_hash) isn't HASH ref.\n"; } if ( $package eq "" ) { die "arg(package) is null.\n"; } my $fh = FileHandle->new($info_filelist_file); if ( ! defined($fh) ) { die "Can't open $info_filelist_file.\n"; } my $line; while ( $line = <$fh> ) { ## If we check $line whether file or not, go very slowly. chomp($line); $filepath_hash->{$line} = $package; } undef $fh; } ## insert_filepath rcconf-3.1ubuntu1/Makefile0000644000000000000000000000102412240061212012464 0ustar PREFIX = /usr all: install install-man docs: pod2man --section=8 --official --center="Debian GNU/Linux" rcconf > rcconf.8 pod2man --section=8 --official --center="Debian GNU/Linux" update-rcconf-guide > update-rcconf-guide.8 clean: -rm -f rcconf.8 -rm -f update-rcconf-guide.8 install-man: docs install -m 644 rcconf.8 $(prefix)/usr/share/man/man8/ install -m 644 update-rcconf-guide.8 $(prefix)/usr/share/man/man8/ install: env install -m 755 rcconf $(PREFIX)/sbin/ install -m 755 update-rcconf-guide $(PREFIX)/sbin/ rcconf-3.1ubuntu1/rcconf0000755000000000000000000011540012240061212012230 0ustar #!/usr/bin/perl -w # rcconf # Copyright (c) 1999-2010 kamop@debian.org # =head1 NAME rcconf - Debian Runlevel configuration tool =head1 SYNOPSIS B [options] =head1 DESCRIPTION B allows you to control which services are started when the system boots up or reboots. It displays a menu of all the services which could be started at boot. The ones that are configured to do so are marked and you can toggle individual services on and off. B gets a list of services from /etc/init.d and looks in the /etc/rc?.d directories to determine whether each service is on or off. B detects ON state by existence of /etc/rc?.d/"S"NNname. If the number(NN of /etc/rc?.d/[SK]NNname) is not 20(default), B saves the service name and the number in /var/lib/rcconf/services so as to be able to restore the service to its original configuration. If you purge B package by 'dpkg --purge' or 'aptitude purge' or others, you may lose off state package due to deletion of /var/lib/rcconf/services. =head1 OPTIONS =over 3 =item B<--help> =over 2 Print out a usage message. =back =item B<--dialog> =over 2 Use dialog command to display menu =back =item B<--whiptail> =over 2 Use whiptail command to display menu =back =item B<--notermcheck> =over 2 Do not set window size by terminal property. =back =item B<--on> service[,service,...] =over 2 Set services to be on. This option enables rcconf in command line mode and no select menu will be displayed. =back =item B<--off> service[,service,...] =over 2 Set services to be off. This option enables rcconf in command line mode and no select menu will be displayed. =back =item B<--list> =over 2 List services which includes current status(on/off). This option enables rcconf in command line mode and no select menu will be displayed. Use B<--expert> option together if you want to list all services. This result can be used as I of B<--config>. =back =item B<--config> I =over 2 Set services on/off according to I. This option enables rcconf in command line mode and no select menu will be displayed. The format of this config file is "service_name on" or "service_name off" in each line. Refer to the result of B<--list>. =back =item B<--expert> =over 2 Show and select all services for experts. In default, rcconf doesn't display system default services as a candidate such as mountall.sh to hide unnecessary services for users(but very important for system). The list of which services are considered expert can be found at the line @expertonly in /usr/sbin/rcconf. =back =item B<--now> =over 2 For each service that had the links changed, call the corresponding /etc/init.d/service-name script using invoke-rc.d, so the package starts or stops immediately. If you do not use this option, the changes will only take effect the next time you reboot (or change runlevel). =back =item B<--verbose> =over 2 Output verbose messages. =back =back =head1 Guide File B can display some description(Guide) for each services with Guide File. Guide File is placed on /var/lib/rcconf/guide, and this Guide File does not exist by default. If you want to use Guide, you need to define guides for each services in this file. If you run B before B, B can use default guides derived from package description. B generates the file '/var/lib/rcconf/guide.default' from package description(only uses first line of it) using apt-cache. B refers Guides in /var/lib/rcconf/guide before /var/lib/rcconf/guide.default. If you install some packages after executed B, you need to re-create this file using B so as to refresh guide.default that includes new guides for installed new services. =head1 Updating /etc/rd?.c/ by the package(KNOWN PROBLEM) B saves /etc/rc?.d/[SK]NNname conditions into /var/lib/rcconf/services. This file is updated only when there exists /etc/rc?.d/SNNname. It means that the condition is not saved if /etc/rc?.d/SNNname doesn't exist for the package. If the old version of the package creates both /etc/rc?.d/SNNname and /etc/rc?.d/KNNname but the newer(updated) version of the package creates only /etc/rc?.d/KNNname, some stupid condition occurs. That is, B displays this package as OFF state even as the updated package doesn't have /etc/rc?.d/SNNname. That is because B can't detect disappearance of /etc/rc?.d/SNNname and previous /etc/rc?.d/SNNname condition remains in /var/lib/rcconf/services for restore. In that situation, remove the entry(corresponding package line) from /var/lib/rcconf/services. =head1 FILE =over 8 =item /var/lib/rcconf/services The service number data file. =item /var/lib/rcconf/lock Lock file. =item /var/lib/rcconf/guide.default Guide File update-rcconf-guide generates. =item /var/lib/rcconf/guide Guide File user(Administrator) can define. =back =head1 SEE ALSO update-rc.d(8) update-rcconf-guide(8) =head1 AUTHOR Atsushi KAMOSHIDA =cut use strict; use Getopt::Long; use Pod::Usage; { local ($^W) = 0; #no warnings; eval "require 'sys/ioctl.ph';"; } my $opt_now = ""; my $opt_help = ""; my $opt_dialog = ""; my $opt_whiptail = ""; my $opt_verbose = ""; my $opt_notermcheck = ""; my $opt_expertmode = ""; my $opt_onlist = ""; my $opt_offlist = ""; my $opt_showlist = ""; my $opt_showrcdf = ""; my $opt_dryrun = ""; my $opt_configfile = ""; my $opt_error = GetOptions ("help|?" => \$opt_help, "now" => \$opt_now, "verbose" => \$opt_verbose, "notermcheck" => \$opt_notermcheck, "expert" => \$opt_expertmode, "dialog" => \$opt_dialog, "on=s" => \$opt_onlist, "off=s" => \$opt_offlist, "list" => \$opt_showlist, "dump" => \$opt_showrcdf, "config=s" => \$opt_configfile, "dry-run" => \$opt_dryrun, "whiptail" => \$opt_whiptail); my $ETC_DIR = "/etc"; my $LOCK_FILE = "/var/lock/rcconf"; my $TMP_FILE = "/tmp/rc-select.$$"; my $DATA_DIR = "/var/lib/rcconf/"; my $NO_EXECUTE = ""; if ( $opt_dryrun ) { $NO_EXECUTE = "yes"; } if ( $NO_EXECUTE ne "" ) { $DATA_DIR = "/tmp/"; } my $DATA_FILE = $DATA_DIR."services"; my $UPDATE_RCD_PATH = "/usr/sbin/update-rc.d"; my $INVOKERC_BIN = "/usr/sbin/invoke-rc.d"; my $TITLE = "rcconf - Debian Runlevel Configuration tool"; my $BOX_HEIGHT = 20; my $BOX_WIDTH = 70; my $BOX_LIST_HEIGHT = 10; my $DIALOG_BIN = "/bin/whiptail"; my $DIALOG_SW_ON = "1"; my $DIALOG_SW_OFF = "0"; my $DEFAULT_RCNUM = 20; my @unselects = ("\^\\\.\$", "\^\\\.\\\.\$", "\^rc\$", "\^rcS\$", "\^README\$", "\^skeleton\$", ".*\\\.dpkg-dist\$", ".*\\\.dpkg-old\$", ".*\\\.dpkg-bak\$", ".*\\\.sh\$"); my @expertonly = ("bootmisc\.sh", "bootlogd", "checkfs-loop", "checkfs.sh", "console-screen\.sh", "checkroot\.sh", "cryptdisks-early", "dns-clean", "etc-setserial", "glibc\.sh", "halt", "hibernate", "hostname\.sh", "hwclock\.sh", "hwclockfirst\.sh", "ifupdown", "ifupdown-clean", "keymap\.sh", "killprocs", "mountall-bootclean\.sh", "mountall\.sh", "mountdevsubfs\.sh", "mountkernfs\.sh", "mountnfs-bootclean\.sh", "mountnfs\.sh", "mountoverflowtmp", "nviboot", "mtab\.sh", "networking", "rc\.local", "reboot", "rmnologin", "screen-cleanup", "sendsigs", "single", "stop-bootlogd", "stop-bootlogd-single", "udev-mtab", "umountfs", "umountroot", "urandom" ); END { &remove_lock(); if ( -f $TMP_FILE ) { unlink($TMP_FILE); } } if ( ( ! $opt_error ) || $opt_help ) { pod2usage(1); } my $DEBUG = 0; if ( ( exists($ENV{'RCCONF_DEBUG'}) ) && ( $ENV{'RCCONF_DEBUG'} ne '' ) ) { $DEBUG = 1; } if ( $opt_verbose ) { $DEBUG = 1; } my $DEBUG_STRING = ""; if ( $DEBUG == 0 ) { $DEBUG_STRING = ">/dev/null 2>&1"; } my $RUN_SCRIPTS = 0; if( ( ( exists($ENV{'RCCONF_NOW'}) ) && ( $ENV{'RCCONF_NOW'} ne '' ) ) || ($opt_now) ) { $RUN_SCRIPTS = 1; } if ( ( -r $DATA_FILE ) && ( ! -w $DATA_FILE ) ) { print STDERR "Can't write $DATA_FILE.\n"; print STDERR "Check permission of $DATA_FILE before rcconf.\n"; exit 1; } my $OUTPUT_FILE = ""; if ( ( exists($ENV{'RCCONF_SAVE'}) ) && ( $ENV{'RCCONF_SAVE'} ne '' ) ) { if ( open(SAVE, "> ".$ENV{'RCCONF_SAVE'} ) ) { $OUTPUT_FILE = $ENV{'RCCONF_SAVE'}; } } my $DEFAULT_GUIDE_FILE = $DATA_DIR."guide.default"; my $GUIDE_FILE = $DATA_DIR."guide"; if ( ( exists($ENV{'RCCONF_GUIDE'}) ) && ( $ENV{'RCCONF_GUIDE'} ne '' ) ) { $GUIDE_FILE = $ENV{'RCCONF_GUIDE'}; } ## Decide dialog command if ( ( exists($ENV{'DIALOG_BIN'}) ) && ( $ENV{'DIALOG_BIN'} ne '' ) ) { $DIALOG_BIN = $ENV{'DIALOG_BIN'}; } if ( ( exists($ENV{'DIALOG_SW_ON'}) ) && ( $ENV{'DIALOG_SW_ON'} ne '' ) ) { $DIALOG_SW_ON = $ENV{'DIALOG_SW_ON'}; } if ( ( exists($ENV{'DIALOG_SW_OFF'}) ) && ( $ENV{'DIALOG_SW_OFF'} ne '' ) ) { $DIALOG_SW_OFF = $ENV{'DIALOG_SW_OFF'}; } if ( $opt_whiptail ) { $DIALOG_BIN = "/bin/whiptail"; $DIALOG_SW_ON = "1"; $DIALOG_SW_OFF = "0"; } if ( $opt_dialog ) { $DIALOG_BIN = "/usr/bin/dialog"; $DIALOG_SW_ON = "on"; $DIALOG_SW_OFF = "off"; } if ( ! -x $DIALOG_BIN ) { $DIALOG_BIN = "/usr/bin/dialog"; $DIALOG_SW_ON = "on"; $DIALOG_SW_OFF = "off"; if ( ! -x $DIALOG_BIN ) { print "rcconf needs dialog or whiptail.\n"; exit 1; } } ## Try to get window size. If it seems good, set them if ( ( defined(&TIOCGWINSZ) ) && ( ! $opt_notermcheck ) ) { my $winsize = ""; my $retval = ioctl(STDOUT,&TIOCGWINSZ,$winsize); if ( $retval ) { my ($height, $width, $xpixel, $ypixel) = unpack('S4', $winsize); if ( ( $height > 4 ) && ( $width > 10 ) ) { # some console may return 0 such as serial console, ignore in this case $BOX_WIDTH = $width - 10; $BOX_HEIGHT = $height - 4; $BOX_LIST_HEIGHT = $BOX_HEIGHT - 10; } } } my $DIALOG_OPT = "--title \"$TITLE\" --separate-output --checklist \"\" $BOX_HEIGHT $BOX_WIDTH $BOX_LIST_HEIGHT "; if ( ( exists($ENV{'DIALOG_OPT'}) ) && ( $ENV{'DIALOG_OPT'} ne '' ) ) { $DIALOG_OPT = $ENV{'DIALOG_OPT'}; } ## Read guidefile and prepare package descriptions. my $guide = &read_guidefile(file=>$DEFAULT_GUIDE_FILE); my $guide_tmp = &read_guidefile(file=>$GUIDE_FILE); foreach my $key ( %{$guide_tmp} ) { $guide->{$key} = $guide_tmp->{$key}; } undef $guide_tmp; &make_lock(); my $rcdf = &read_rcd_default(root_dir=>$ETC_DIR); if ( $opt_showrcdf ) { dump_rcd(rcdf=>$rcdf); exit 0; } my $data = &read_data(file=>$DATA_FILE); my $cur_on = &select_default(rcdf=>$rcdf, data=>$data); my $initd = &read_initd_dir(root_dir=>$ETC_DIR); my $cur_off = &select_unlinked_initd(initd=>$initd, rcdf=>$rcdf, data=>$data, unselects=>\@unselects); &update_services_data_initd(initd=>$initd, data=>$data, root_dir=>$ETC_DIR, unselects=>\@unselects); undef $initd; if ( ! $opt_expertmode ) { $cur_on = &select_unmanaged_initd(initd=>$cur_on, unselects=>\@expertonly); $cur_off = &select_unmanaged_initd(initd=>$cur_off, unselects=>\@expertonly); } ## Calculate MENU width my $GUIDE_LENGTH = -1; my $ITEM_MAX_LENGTH = -1; &update_item_max_length(data=>$cur_on); &update_item_max_length(data=>$cur_off); ## GUIDE_LENGTH = BOX_WIDTH - FIXED_LENGTH[16] - max(keys) ## FIXED_LENGTH = left_edge[5] + mark[4] + key_list_gap[2] + right_edge[5] $GUIDE_LENGTH = $BOX_WIDTH - 16 - $ITEM_MAX_LENGTH; my $ret; my $res; my $skip_exec = 0; if ( ( $opt_configfile ne "" ) && ( -f $opt_configfile ) ) { ($ret, $res) = &read_config_file(file=>$opt_configfile); if ( $ret == 0 ) { ($ret, $res) = &set_config(on=>$cur_on, off=>$cur_off, set=>$res); } } elsif ( ( $opt_onlist ne "" ) || ( $opt_offlist ne "" ) ) { ## command line mode(set) ($ret, $res) = &read_config_list(onstr=>$opt_onlist, offstr=>$opt_offlist); if ( $ret == 0 ) { ($ret, $res) = &set_config(on=>$cur_on, off=>$cur_off, set=>$res); } } elsif ( $opt_showlist ) { ## command line mode(list) &show_config(on=>$cur_on, off=>$cur_off); $skip_exec = 1; $ret = 0; } else { ## TUI mode ($ret, $res) = &output_dialog(on=>$cur_on, off=>$cur_off, info=>$guide); } if ( ( $skip_exec == 0 ) && ( $ret == 0 ) ) { my($res_on, $res_off) = &diff_result(on=>$cur_on, off=>$cur_off, res=>$res); &exec_update(on=>$res_on, off=>$res_off, data=>$data); &write_data(file=>$DATA_FILE, data=>$data); } &remove_lock(); if ( $OUTPUT_FILE ne "" ) { close(SAVE); } exit $ret; ####################################################################### ####################################################################### ####################################################################### ####################################################################### ## MODULE: read_rcd_default ## DESC: Read files in rc?.d(?:=0..6) directory and generate %rcdf. ## %rcdf->{'package'} -> [0] service num in rc0.d/S??package ## [1] ## [2] ## [3] ## [4] ## [5] ## [6] ## [7] rcS.d/S??package ## [10] service num in rc0.d/K??package ## [11] rc1.d/K??package ## [12] rc2.d/K??package ## [13] rc3.d/K??package ## [14] rc4.d/K??package ## [15] rc5.d/K??package ## [16] rc6.d/K??package ## [17] rcS.d/K??package ## IN: ## OUT: ## OP: ## STATUS: ## END: sub read_rcd_default { my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $root_dir = $ref{'root_dir'}; my %rcdf = (); my $dir; ## rc?.d my($start, $end); for ( my $i = 0; $i <= 6; $i++ ) { $dir = $root_dir."/rc".$i.".d"; ($start, $end) = &read_rc_dir(dir=>$dir); &setup_rcd(rcdf=>\%rcdf, rcfile=>$start, dirnum=>$i, margin=>0); &setup_rcd(rcdf=>\%rcdf, rcfile=>$end, dirnum=>$i, margin=>10); } ## rcS.d $dir = $root_dir."/rcS.d"; ($start, $end) = &read_rc_dir(dir=>$dir); &setup_rcd(rcdf=>\%rcdf, rcfile=>$start, dirnum=>7, margin=>0); &setup_rcd(rcdf=>\%rcdf, rcfile=>$end, dirnum=>7, margin=>10); return \%rcdf; } ## read_rcd_default ####################################################################### ## MODULE: read_rc_dir ## DESC: Open directory specified in $dir, and list Start/Stop service ## @start [0] -> {file} -+- 'num' service number ## [1] +- 'name' file name ## IN: ## OUT: ## OP: ## STATUS: ## END: sub read_rc_dir{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $dir = $ref{'dir'}; ## opendir(DIR, $dir) || die "No such directory: $!"; ## my @starts = (); my @stops = (); my @dirs = readdir(DIR); foreach ( @dirs ) { if(/^S([0-9][0-9])(.*)$/){ push(@starts, &new_file(num=>$1, name=>$2)); next; } ## if if(/^K([0-9][0-9])(.*)$/){ push(@stops, &new_file(num=>$1, name=>$2)); next; } ## if } ## while() closedir(DIR); return(\@starts, \@stops); } ## read_rc_dir ####################################################################### ## MODULE: read_initd_dir ## DESC: Collect files in init.d/ directory. ## IN: ## OUT: ## OP: ## STATUS: ## END: sub read_initd_dir{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $root_dir = $ref{'root_dir'}; ## my $dir = $root_dir."/init.d"; opendir(DIR, $dir) || die "No such directory: $!"; my(@dirs) = readdir(DIR); close(DIR); ## return \@dirs; } ## read_initd_dir ####################################################################### ## MODULE: select_unlinked_initd ## DESC: Compare between %rcdf and @initd, and list file in init.d/ ## directory which is not linked to rc?.d. ## Listed files are not serviced packages. ## We creates /etc/rc*.d/KNNname when it changes to off, so we ## also need it. ## IN: ## OUT: \@new_initd := not serviced packages ## OP: ## STATUS: ## END: sub select_unlinked_initd{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $initd = $ref{'initd'}; my $rcdf = $ref{'rcdf'}; my $data = $ref{'data'}; my $unselects = $ref{'unselects'}; ## my @new_initd = (); ## foreach my $key (@{$initd}){ next if ( &check_unselect(file=>$key, unselects=>$unselects) ); if ( ! exists($rcdf->{$key}) ) { push(@new_initd, $key); } elsif ( ( $rcdf->{$key}->[0] == -1 ) && ( $rcdf->{$key}->[1] == -1 ) && ( $rcdf->{$key}->[2] == -1 ) && ( $rcdf->{$key}->[3] == -1 ) && ( $rcdf->{$key}->[4] == -1 ) && ( $rcdf->{$key}->[5] == -1 ) && ( $rcdf->{$key}->[6] == -1 ) && ( $rcdf->{$key}->[7] == -1 ) ) { if ( ( exists($data->{$key}) ) && ( $data->{$key}->{'start'} ne "x" ) ) { ## non-defaults and defaults-number packages push(@new_initd, $key); } elsif ( ( $rcdf->{$key}->[10] == $rcdf->{$key}->[11] ) && ( $rcdf->{$key}->[10] == $rcdf->{$key}->[12] ) && ( $rcdf->{$key}->[10] == $rcdf->{$key}->[13] ) && ( $rcdf->{$key}->[10] == $rcdf->{$key}->[14] ) && ( $rcdf->{$key}->[10] == $rcdf->{$key}->[15] ) && ( $rcdf->{$key}->[10] == $rcdf->{$key}->[16] ) && ( $rcdf->{$key}->[10] == 0 ) ) { ## defaults packages push(@new_initd, $key); } elsif ( ( $rcdf->{$key}->[10] == $rcdf->{$key}->[11] ) && ( $rcdf->{$key}->[10] == $rcdf->{$key}->[12] ) && ( $rcdf->{$key}->[10] == $rcdf->{$key}->[13] ) && ( $rcdf->{$key}->[10] == $rcdf->{$key}->[14] ) && ( $rcdf->{$key}->[10] == $rcdf->{$key}->[15] ) && ( $rcdf->{$key}->[10] == $rcdf->{$key}->[16] ) ) { ## off state packages by 'update-rc.d disable' push(@new_initd, $key); } } } return \@new_initd; } ## select_unlinked_initd() ####################################################################### ## MODULE: check_unselect ## DESC: Check if 'file' exists in unselects array. ## IN: ## OUT: results 0 := file is not in the array. ## 1 := file exists in the array. ## OP: ## STATUS: ## END: sub check_unselect{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $file = $ref{'file'}; my $unselects = $ref{'unselects'}; return 1 if ( ! -x $ETC_DIR . "/init.d/" . $file ); foreach my $unselect (@{$unselects}){ return 1 if($file =~ /$unselect/); } return 0; } ## check_unselect() ####################################################################### ## MODULE: select_unmanaged_initd ## DESC: Remove unmanaged initd from @initd compared with unselects list. ## IN: ## OUT: \@new_initd := not serviced packages ## OP: ## STATUS: ## END: sub select_unmanaged_initd { my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $initd = $ref{'initd'}; my $unselects = $ref{'unselects'}; ## my @new_initd = (); my $unselect; ## foreach my $key ( @{$initd} ) { next if ( &check_unselect(file=>$key, unselects=>$unselects) ); push(@new_initd, $key); } return \@new_initd; } ## select_unmanaged_initd() ####################################################################### ## MODULE: new_file ## DESC: Generate new package file ## 'num' => service number ## 'name' => package name(filename) ## IN: ## OUT: ## OP: ## STATUS: ## END: sub new_file{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my %new = (); $new{'num'} = $ref{'num'}; $new{'name'} = $ref{'name'}; return \%new; } ## new_file() ####################################################################### ## MODULE: new_rcd ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub new_rcd{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my @rcd = (); for ( my $i = 0; $i <= 7; $i++ ) { $rcd[$i] = -1; ## start $rcd[$i + 10] = -1; ## end } return \@rcd; } ## new_rc() ####################################################################### ## MODULE: setup_rcd ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub setup_rcd{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $rcdf = $ref{'rcdf'}; my $rcfile = $ref{'rcfile'}; my $dirnum = $ref{'dirnum'}; my $margin = $ref{'margin'}; ## my $package; my $num; foreach my $file ( @{$rcfile} ) { $package = $file->{'name'}; $num = $file->{'num'}; if ( $DEBUG == 1 ) { print $package." ".$num." $margin $dirnum\n"; } if(! exists($rcdf->{$package})){ $rcdf->{$package} = &new_rcd(); if ( $DEBUG == 1 ) { print "Generate ".$package."\n"; } } $rcdf->{$package}->[$dirnum+ $margin] = $num; } ## foreach } ## setup_rcd() ####################################################################### ## MODULE: dump_rcd ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub dump_rcd{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $rcdf = $ref{'rcdf'}; ## my $i; printf " Start Stop\n"; printf "%-20s ","Package Name"; print " 0 1 2 3 4 5 6 S 0 1 2 3 4 5 6 S\n"; print '-' x 71 ."\n"; foreach my $package (keys(%{$rcdf})){ printf "%-20s ", $package; for ( $i = 0; $i <= 7; $i++ ) { printf "%2d ", $rcdf->{$package}->[$i]; } print " "; for ( $i = 0; $i <= 7; $i++ ) { printf "%2d ", $rcdf->{$package}->[$i + 10]; } print "\n"; } ## foreach $package } ## dump_rcd() ####################################################################### ## MODULE: select_default ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub select_default{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $rcdf = $ref{'rcdf'}; my $data = $ref{'data'}; ## my $link ; my @select = (); my $start_num; my $stop_num; foreach my $package ( keys(%{$rcdf}) ) { $link = $rcdf->{$package}; $start_num = $link->[2]; $stop_num = $link->[10]; if ( ( $start_num != -1 ) && ( $stop_num != -1 ) && ( $link->[3] == $start_num ) && ( $link->[4] == $start_num ) && ( $link->[5] == $start_num ) && ( $link->[11] == $stop_num ) && ( $link->[16] == $stop_num ) ) { push(@select, $package); if ( ( $start_num != $DEFAULT_RCNUM ) || ( $stop_num != $DEFAULT_RCNUM ) ) { ## defaults-number packages $data->{$package}->{'start'} = $start_num; $data->{$package}->{'stop'} = $stop_num; } } else { ## check for non-defaults packages my $start_str = ""; my $stop_str = ""; my $symbol; my $num_str; my %start_hash = (); my %stop_hash = (); for ( my $i = 0; $i < 8; $i++ ) { $symbol = ($i == 7) ? "S" : $i; ## check for S:start numbers if ( $link->[$i] != -1 ) { $num_str = sprintf("%02d", $link->[$i]); if ( ( ! exists($start_hash{$num_str}) ) || ( $start_hash{$num_str} eq "" ) ) { $start_hash{$num_str} = $num_str; } $start_hash{$num_str} .= ":" . $symbol; } ## check for K:kill(stop) numbers if ( $link->[$i + 10] != -1 ) { $num_str = sprintf("%02d", $link->[$i + 10]); if ( ( ! exists($stop_hash{$num_str}) ) || ( $stop_hash{$num_str} eq "" ) ) { $stop_hash{$num_str} = $num_str; } $stop_hash{$num_str} .= ":" . $symbol; } } ## for $start_str = services_string(hash=>\%start_hash); $stop_str = services_string(hash=>\%stop_hash); if ( $start_str ne "" ) { $data->{$package}->{'start'} = $start_str; $data->{$package}->{'stop'} = ( $stop_str ne "" ) ? $stop_str : "x"; push(@select, $package); } } ## if } ## foreach return \@select; } ## select_default() ####################################################################### ## MODULE: services_string ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub services_string { my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $str = ""; my $hash = $ref{'hash'}; foreach my $key ( keys(%{$hash}) ) { $str .= "," if ( $str ne "" ); $str .= $hash->{$key}; } ## foreach return $str; ## } ## services_string() ####################################################################### ## MODULE: output_dialog ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub output_dialog{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $on = $ref{'on'}; my $off = $ref{'off'}; my $info = $ref{'info'}; ## my @res = (); my $list = " ".&generate_dialoglist(package=>$on, sw=>$DIALOG_SW_ON, info=>$info); $list .= " ".&generate_dialoglist(package=>$off, sw=>$DIALOG_SW_OFF, info=>$info); my $exec = $DIALOG_BIN." ".$DIALOG_OPT.$list; ## my $ret = system($exec." 2>$TMP_FILE"); if ( ( $ret != 0 ) && ( $ret != 1 ) ) { print STDERR "Cancelled or $DIALOG_BIN execution error($ret)\n"; return($ret, \@res); } ## 'dialog' return 0 if exit by pressing 'OK' if ( $ret == 0 ) { open(RES, $TMP_FILE) || die "Exec error:$!"; while(){ chomp; ## strip quoted string "package" or 'package' if ( /^\"(.*)\"$/ ) { $_ = $1; } elsif ( /^\'(.*)\'$/ ) { $_ = $1; } push(@res, $_); } close(RES); } unlink $TMP_FILE; return($ret, \@res); } ## output_dialog() ####################################################################### ## MODULE: generate_dialoglist ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub generate_dialoglist { my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $package = $ref{'package'}; my $sw = $ref{'sw'}; my $info = $ref{'info'}; ## my $list = ""; my $str; for my $key ( sort(@{$package}) ) { $str = ""; if ( exists($info->{$key}) ) { $str = ( $GUIDE_LENGTH > 0 ) ? substr($info->{$key}, 0, $GUIDE_LENGTH) : $info->{$key}; } $key =~ s/\'/\"/g; $str =~ s/\'/\"/g; $list .= "'".$key."' "." '".$str."' '".$sw."' "; } return $list; } ## generate_dialoglist() ####################################################################### ## MODULE: read_guidefile ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub read_guidefile{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $file = $ref{'file'}; ## my %guide = (); my $key; my $guideline; open(IN, $file) || return \%guide; while(){ chomp; /^(\S+)\s+(.*)/; $key = $1; $guideline = $2; $guide{$key} = $guideline; } ## while() return \%guide; } # read_guidefile() ####################################################################### ## MODULE: diff_result ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub diff_result{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $on = $ref{'on'}; my $off = $ref{'off'}; my $res = $ref{'res'}; ## my %hash = (); my @res_on = (); my @res_off = (); my $key; foreach $key (@{$res}){ $hash{$key} = "OK"; } foreach $key ( @{$on} ) { if ( ! exists($hash{$key}) ) { push(@res_off, $key); } else { $hash{$key} = "ON"; } } foreach $key ( @{$off} ) { if ( exists($hash{$key}) ) { push(@res_on, $key); $hash{$key} = "OFF"; } } foreach $key ( keys(%hash) ) { if ( $hash{$key} eq "OK" ) { ## ERROR print STDERR "Illegal string(".$key.") received from $DIALOG_BIN\n"; exit 1; } } return(\@res_on, \@res_off); } ## diff_result() ####################################################################### ## MODULE: exec_update ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub exec_update{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $on = $ref{'on'}; my $off = $ref{'off'}; my $data = $ref{'data'}; ## my $key; my $command; my $pn; foreach $key ( @{$on} ) { if ( ( exists($data->{$key}) ) && ( $data->{$key}->{'start'} eq "z" ) && ( $data->{$key}->{'stop'} eq "z" ) ) { $command .= $UPDATE_RCD_PATH . " " . $key . " enable "; } else { $command = $UPDATE_RCD_PATH." -f ".$key." remove $DEBUG_STRING "; if ( ( exists($data->{$key}) ) && ( ( $data->{$key}->{'start'} =~ /[:x]/ ) || ( $data->{$key}->{'stop'} =~ /[:x]/ ) ) ) { $command .= " ; " . $UPDATE_RCD_PATH." ".$key; if ( $data->{$key}->{'start'} ne "x" ) { $command .= extract_services_data(str=>$data->{$key}->{'start'}, head=>'start'); } if ( $data->{$key}->{'stop'} ne "x" ) { $command .= extract_services_data(str=>$data->{$key}->{'stop'}, head=>'stop'); } } else { $command .= " ; " . $UPDATE_RCD_PATH." ".$key." defaults"; if ( exists($data->{$key}) ) { $command .= " ".$data->{$key}->{'start'}." ".$data->{$key}->{'stop'}; } } } $command .= " $DEBUG_STRING"; if ( $NO_EXECUTE eq '' ) { if ( $DEBUG == 1 ) { print STDERR $command."\n"; } print SAVE "$key on\n" if($OUTPUT_FILE ne ''); system($command); if ( $RUN_SCRIPTS == 1 ) { system($INVOKERC_BIN." ".$key." start"); } }else{ print STDERR "DRYRUN: ".$command."\n"; } } foreach $key ( @{$off} ) { if ( exists($data->{$key}) ) { ## non-defaults and defaults-number packages if ( $data->{$key}->{'stop'} ne "x" ) { my @array = split(/:/, $data->{$key}->{'stop'}); $pn = $array[0]; } else { $pn = ""; } } else { ## defaults packages $pn = "00"; } if ( $data->{$key}->{'stop'} eq "z" ) { $command .= $UPDATE_RCD_PATH . " " . $key . " disable $DEBUG_STRING "; } else { $command = $UPDATE_RCD_PATH." -f ".$key." remove $DEBUG_STRING "; if ( $pn ne "" ) { $command .= " ; " . $UPDATE_RCD_PATH." ".$key." stop " . $pn . " 0 1 2 3 4 5 6 . $DEBUG_STRING "; } } # $command .= " $DEBUG_STRING"; if ( $NO_EXECUTE eq '' ) { if ( $DEBUG == 1 ) { print STDERR $command."\n"; } print SAVE "$key off\n" if($OUTPUT_FILE ne ''); system($command); if ( $RUN_SCRIPTS == 1 ) { system($INVOKERC_BIN." ".$key." stop"); } }else{ print STDERR "DRYRUN: ".$command."\n"; } } } ## exec_update() ####################################################################### ## MODULE: extract_services_data ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub extract_services_data { my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $str = $ref{'str'}; my $head = $ref{'head'}; $str =~ s/:/ /g; $str =~ s/,/ \. $head /g; return " " . $head . " " . $str . " . "; } ## extract_services_data() ####################################################################### ## MODULE: update_services_data_initd ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub update_services_data_initd { my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $root_dir = $ref{'root_dir'}; my $initd = $ref{'initd'}; my $data = $ref{'data'}; ## my $dir = $root_dir."/init.d"; foreach my $key (@{$initd}){ next if ( ! exists($data->{$key}) ); next if ( ! -f $dir."/".$key ); $data->{$key}->{'exists'} = 1; open(IN,$dir."/".$key) || next; while(){ if ( /\#\s*Default-Start:/ ) { if ( exists($data->{$key}->{'start'}) ) { $data->{$key}->{'start'} = 'z'; } next; } if ( /\#\s*Default-Stop:/ ) { if ( exists($data->{$key}->{'stop'}) ) { $data->{$key}->{'stop'} = 'z'; } next; } } ## while close(IN); } ## foreach $key } ## extract_services_data() ####################################################################### ## MODULE: read_data ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub read_data{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my %data = (); ## open(IN, $ref{'file'}) || return \%data; ## while(){ next if ( /^\#/ ); if ( /^([0-9,:xzS]+)\s+([0-9,:xzS]+)\s+(\S+)/ ) { $data{$3}->{'start'} = $1; $data{$3}->{'stop'} = $2; } elsif ( /^([0-9][0-9])\s+([0-9][0-9])\s+(\S+)/ ) { $data{$3}->{'start'} = $1; $data{$3}->{'stop'} = $2; } elsif ( /^([0-9][0-9])\s+(\S+)/ ) { $data{$2}->{'start'} = $1; $data{$2}->{'stop'} = $1; } else { print STDERR $ref{'file'}.": skipping unrecognized line: \"$_\"\n"; } } ## while() close(IN); return \%data; } ## read_data() ####################################################################### ## MODULE: read_config_file ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub read_config_file{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $tag; my $value; my $ret = 0; my %data = (); use FileHandle; my $rfh = FileHandle->new($ref{'file'}); if ( ! defined($rfh) ) { print STDERR "File open error".$ref{'file'}."\n"; return(1, 0); } my $lineno = 0; while(<$rfh>){ $lineno ++; s/\r?\n$//; next if(/^$/ || /^\#/); ($tag, $value) = split(/\s+/); if ( $value =~ /^on$/i ) { $value = 1; } elsif ( $value =~ /^off$/i ) { $value = 0; } else { print STDERR $ref{'file'}.": format error in line $lineno.\n"; $ret = 1; } $data{$tag} = $value; } $rfh->close(); undef($rfh); return($ret, \%data); } ## read_config_file() ####################################################################### ## MODULE: read_config_list ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub read_config_list { my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $onstr = $ref{'onstr'}; my $offstr = $ref{'offstr'}; ## my %set_hash = (); my $service; my $ret = 0; foreach $service ( split(',', $onstr) ) { if ( exists($set_hash{$service}) ) { print STDERR "service '$service' is already set on on-list.\n"; } $set_hash{$service} = 1; } foreach $service ( split(',', $offstr) ) { if ( exists($set_hash{$service}) ) { print STDERR "service '$service' is already set on on-list or off-list.\n"; } $set_hash{$service} = 0; } return($ret, \%set_hash); } ## read_config_list() ####################################################################### ## MODULE: set_config ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub set_config{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $on = $ref{'on'}; my $off = $ref{'off'}; my $set = $ref{'set'}; ## my $on_hash = &array2hash(array=>$on, value=>'1'); my $off_hash = &array2hash(array=>$off, value=>'0'); ## my $key; my $ret = 0; foreach $key ( keys(%{$set}) ) { if ( ( ! exists($off_hash->{$key}) ) && ( ! exists($on_hash->{$key}) ) ) { print STDERR "Service '$key' doesn't exist.\n"; $ret = 1; next; } if ( $set->{$key} == 1 ) { if ( exists($off_hash->{$key}) ) { $on_hash->{$key} = '1'; } else { print STDERR "Service '$key' is already on. Skipping...\n"; } } elsif ( $set->{$key} == 0 ) { if ( exists($on_hash->{$key}) ) { $on_hash->{$key} = '0'; } else { print STDERR "Service '$key' is already off. Skipping...\n"; } } } my @res = (); foreach $key ( keys(%{$on_hash}) ) { push(@res, $key) if($on_hash->{$key} == 1); } return($ret, \@res); } ## set_config() ####################################################################### ## MODULE: show_config ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub show_config { my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $on = $ref{'on'}; my $off = $ref{'off'}; my $set = $ref{'set'}; ## foreach my $key ( @{$on} ) { print $key." on\n"; } foreach my $key ( @{$off} ) { print $key." off\n"; } } ## show_config() ####################################################################### ## MODULE: array2hash ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub array2hash{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $array = $ref{'array'}; my $value = $ref{'value'}; ## my %hash = (); foreach my $key (@{$array}){ $hash{$key} = $value; } return \%hash; } ## array2hash() ####################################################################### ## MODULE: write_data ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub write_data{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $file = $ref{'file'}; my $data = $ref{'data'}; open(OUT, "> ".$file) || die "Cannot write file $file: $!"; foreach my $key (keys(%{$data})){ next if ( ! exists($data->{$key}->{'exists'}) ); print OUT $data->{$key}->{'start'}." ". $data->{$key}->{'stop'}." ". $key."\n"; } close(OUT); } ## write_data() ####################################################################### ## MODULE: update_itme_max_length ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub update_item_max_length { my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## my $package = $ref{'data'}; ## for my $key ( @{$package} ) { if ( length($key) > $ITEM_MAX_LENGTH ) { $ITEM_MAX_LENGTH = length($key); } } } ## update_item_max_length() ####################################################################### ## MODULE: make_lock ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub make_lock{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## if ( -f $LOCK_FILE ) { die "Another rcconf is running, or still remain lock file($LOCK_FILE)."; } open(LOCK, "> ".$LOCK_FILE) || die "Can't create lock($LOCK_FILE)."; close(LOCK); } ## make_lock() ####################################################################### ## MODULE: remove_lock ## DESC: ## IN: ## OUT: ## OP: ## STATUS: ## END: sub remove_lock{ my($self) = shift if(defined($_[0]) && (ref($_[0]) ne '')); my(%ref) = @_; ## unlink($LOCK_FILE); } ## remove_lock rcconf-3.1ubuntu1/debian/0000755000000000000000000000000012240061370012256 5ustar rcconf-3.1ubuntu1/debian/rules0000755000000000000000000000303012240061212013325 0ustar #!/usr/bin/make -f # -*- makefile -*- # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 configure: configure-stamp configure-stamp: dh_testdir # Add here commands to configure the package. touch configure-stamp build: build-stamp build-stamp: configure-stamp dh_testdir pod2man --section=8 --official --center="Debian GNU/Linux" rcconf \ > rcconf.8 pod2man --section=8 --official --center="Debian GNU/Linux" \ update-rcconf-guide > update-rcconf-guide.8 touch $@ clean: dh_testdir dh_testroot rm -f build-stamp configure-stamp -rm -f rcconf.8 -rm -f update-rcconf-guide.8 dh_clean install: build dh_testdir dh_testroot dh_clean -k dh_installdirs install -m 755 rcconf `pwd`/debian/rcconf/usr/sbin install -m 755 update-rcconf-guide `pwd`/debian/rcconf/usr/sbin # Build architecture-independent files here. binary-indep: build install # We have nothing to do by default. # Build architecture-dependent files here. binary-arch: build install dh_testdir dh_testroot dh_installchangelogs dh_installdocs dh_installexamples # dh_install # dh_installmenu # dh_installdebconf # dh_installlogrotate # dh_installemacsen # dh_installpam # dh_installmime # dh_python # dh_installinit # dh_installcron # dh_installinfo dh_installman rcconf.8 update-rcconf-guide.8 dh_link dh_strip dh_compress dh_fixperms dh_perl # dh_makeshlibs dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install configure rcconf-3.1ubuntu1/debian/changelog0000644000000000000000000002705712240061357014150 0ustar rcconf (3.1ubuntu1) trusty; urgency=low * Merge from Debian unstable. Remaining changes: - debian/rcconf.postinst: Add update-rcconf-guide. - rcconf: Update whiptail path. - update-rcconf-guide: Fix perl warnings. -- Logan Rosen Sun, 10 Nov 2013 23:52:57 -0500 rcconf (3.1) unstable; urgency=low * Re-packaged. -- Atsushi KAMOSHIDA Sun, 26 Oct 2013 10:11:00 +0900 rcconf (3.0) unstable; urgency=low * Fixed lintian warnings. * If LSB comment header is used in init.d files, use only enable/disable. -- Atsushi KAMOSHIDA Mon, 29 Mar 2010 00:11:00 +0900 rcconf (2.5ubuntu3) saucy; urgency=low * Fix perl warnings in update-rcconf-guide (LP: #295663) -- Andreas Moog Wed, 24 Jul 2013 13:59:14 +0200 rcconf (2.5ubuntu2) raring; urgency=low * Update whiptail path (LP #1089724) -- Javier P.L. Fri, 14 Dec 2012 11:24:45 -0500 rcconf (2.5ubuntu1) lucid; urgency=low * Add update-rcconf-guide to postinst (LP: #13332) -- Mackenzie Morgan Wed, 16 Dec 2009 16:02:00 -0500 rcconf (2.5) unstable; urgency=low * Improved finding off state services(Closes: #556180). * Add information for --expert(Closes: #556590). -- Atsushi KAMOSHIDA Tue, 17 Nov 2009 10:30:05 +0900 rcconf (2.4) unstable; urgency=low * Fixed in calling update-rc.d to improve previous fix. -- Atsushi KAMOSHIDA Sat, 07 Nov 2009 00:12:53 +0900 rcconf (2.3) unstable; urgency=low * Tentative fixed in calling update-rc.d for stop service because newer update-rc.d changed its behavior(Closes: #554701). This fix will be changed when we can find the method to check whether update-rc.d has enable/disable options. * Changed in finding off state services, detects no 'S' in /etc/rc*.d as off state. Rcconf detected any 'K' in /etc/rc*.d as off state previously. -- Atsushi KAMOSHIDA Fri, 06 Nov 2009 23:16:27 +0900 rcconf (2.2) unstable; urgency=low * Rcconf sets stop /etc/rc?.d/"K"NNname files with wrong number when off in case mysql-server package is installed(Closes: #519555). If you've already have missing packages on rcconf which was turned off by rcconf, remove incorrect link as follows: # update-rc.d -f remove * Fixed wrong messages when you use '--on' and '--off' options. -- Atsushi KAMOSHIDA Sun, 05 Apr 2009 01:58:38 +0900 rcconf (2.1) unstable; urgency=low * Incorrect installed path. Rcconf was installed to /usr/bin. -- Atsushi KAMOSHIDA Sat, 14 Mar 2009 22:14:45 +0900 rcconf (2.0) unstable; urgency=low * Changed rcconf path from /usr/bin to /usr/sbin. To avoid confusion of this change, remain /usr/bin/rcconf as symbolic link to /usr/sbin/rcconf for a while(Closes: #510082). * Introduce expert mode so as to hide unnecessary services for users (but very important for system). Use --expert if we want to display all. * Added option '--on' and '--off' to select services in command line (Closes: #296937,#375738,#488068). * Added option '--list' to show current status(on/off) of each services. * Added option '--config ' to set services from config file. * Return exit status of whiptail/dialog(Closes: #510079). * First try Short-Description in update-rcconf-guide(Closes: #510077). -- Atsushi KAMOSHIDA Wed, 21 Jan 2009 23:47:01 +0900 rcconf (1.24) unstable; urgency=low * Added dialog support to package dependency again. The dialog problem(original problem was fixed in dialog 1.1-20080819-1) and some avoidance from rcconf has already been done in 1.23. -- Atsushi KAMOSHIDA Tue, 26 Aug 2008 23:01:10 +0900 rcconf (1.23) unstable; urgency=low * Added irregular dialog output handling, strip quote when dialog outputs quoted package name. * Exit if rcconf receives nonexistent package name from dialog or whiptail. * Handling NULL string of update-rcconf-guide(Closes: #495143). * Added .dpkg-bak as unselect init.d scripts. * Fixed to show unselected defaults package item. In prior version, when we unselect defaults package that rcconf uses 'update-rc.d name defaults', we never see this item on rcconf next time. -- Atsushi KAMOSHIDA Fri, 15 Aug 2008 21:38:54 +0900 rcconf (1.22) unstable; urgency=low * We supports whiptail only(dialog won't be used) now due to strange results with current dialog. Dialog support will be available when we fix the problem. -- Atsushi KAMOSHIDA Fri, 15 Aug 2008 11:11:26 +0900 rcconf (1.21) unstable; urgency=low * Enhanced /var/lib/rcconf/services to handle the packages which have multiple sequence numbers in /etc/rc?.d/ (Closes: #483009,#230748). -- Atsushi KAMOSHIDA Sat, 14 Jun 2008 21:43:33 +0900 rcconf (1.20) unstable; urgency=low * Fixed typo in man page (Closes: #355605). -- Atsushi KAMOSHIDA Sat, 22 Mar 2008 00:45:30 +0900 rcconf (1.19) unstable; urgency=low * Fixed the incomplete fix for #335534 (Closes: #357902). -- Atsushi KAMOSHIDA Thu, 23 Mar 2006 10:33:37 +0900 rcconf (1.18) unstable; urgency=low * Do not output verbose warnings in requiring sys/ioctl.ph(Closes: #354912). -- Atsushi KAMOSHIDA Sat, 4 Mar 2006 22:57:06 +0900 rcconf (1.17) unstable; urgency=low * Do not set illegal window size by getting terminal property (Closes: #341339). * Add new option '--notermcheck' to avoid some problem by TIOCGWINSZ. * Immediately exit as error if rcconf can't write status to the file (/var/lib/rcconf/services) (Closes: #341233). -- Atsushi KAMOSHIDA Sat, 3 Dec 2005 01:23:13 +0900 rcconf (1.16) unstable; urgency=low * This may avoid an error in 'require sys/ioctl.ph'(Closes: #333079). -- Atsushi KAMOSHIDA Sun, 6 Nov 2005 23:22:40 +0900 rcconf (1.15) unstable; urgency=low * Fixed internal whiptail/dialog argument so as not to include "'" in each strings (Closes: #335534). -- Atsushi KAMOSHIDA Sun, 30 Oct 2005 22:42:22 +0900 rcconf (1.14) unstable; urgency=low * Missd Closes information. (Closes #317401) -- Atsushi KAMOSHIDA Thu, 25 Aug 2005 21:43:39 +0900 rcconf (1.13) unstable; urgency=low * Fixed missing close FileHandle (Closes: #31741) -- Atsushi KAMOSHIDA Thu, 25 Aug 2005 20:44:25 +0900 rcconf (1.12) unstable; urgency=low * Initialize each variable before they are used.(Closes: #290223) Some variables are used in END block, but END block is called before their initialization if the option --help is stated. -- Atsushi KAMOSHIDA Fri, 14 Jan 2005 22:49:28 +0900 rcconf (1.11) unstable; urgency=low * Fixed to check if &TIOCGWINSZ is defined before calling ioctl. If TIOCGWINSZ termio isn't prepared, rcconf doesn't fit the screen size.(Closes: #287269) -- Atsushi KAMOSHIDA Mon, 27 Dec 2004 00:33:41 +0900 rcconf (1.10) unstable; urgency=low * Added Guide feature to man page which shows the description of each services.(Closes: #257353) * update-rcconf-guide: a support tool for Guide which creates default Guide File(guide.default) derived from the description of packages. * Modified the screen size to be able to use variable screen size. * Added perl-modules dependancy. (Closes: #284242) * Added --dialog and --whiptail commnd options which select display behavior. Rcconf uses whiptail method by default. * Turn off showing update-rc.d command result. * Added --verbose command option to show verious messages including update-rc.d command result. -- Atsushi KAMOSHIDA Tue, 7 Dec 2004 15:57:54 +0900 rcconf (1.9) unstable; urgency=low * Thanks to Fabio Tranchitella , this version could resolve many bugs. * Modified rcconf to *really* set the services "off". Before this, the symlinks in /etc/rc?.d have been deleted when disabling a service. (Closes: #271293, #237220) * Old NMU acknowledge (thanks Daniel). (Closes: #190514) * Fixed minor typo in man page. * Added a warning in README.Debian about false positives (Closes: #150865). * Removed from the list of the services found in /etc/init.d the ones which ends with .sh. They should be handled specially, as they are for the S runlevel. (Closes: #245947) * Removed from the list of the services found in /etc/init.d the ones which haven't execute permission. (Closes: #237223) * Applied the patch from Jeronimo Pellegrini to add the --now option that start/stop the services immediatly. Thanks Jeronimo! (Closes: #151488) -- Atsushi KAMOSHIDA Wed, 10 Nov 2004 10:11:52 +0900 rcconf (1.8) unstable; urgency=low * Fix Depends field(Closes: #218951). -- Atsushi KAMOSHIDA Wed, 10 Mar 2004 02:13:46 +0900 rcconf (1.7) unstable; urgency=low * closes: #230761, #229464, #151824, #205468. * rcconf mainly use whpitail(closes: #69217). -- Atsushi KAMOSHIDA Mon, 8 Mar 2004 01:00:42 +0900 rcconf (1.6) unstable; urgency=low * Fixed remaing lock file problem(Close #144053). * Fixed description(Close #144560,#166518,#168414). * Add whiptail-privider dependancy(Close #141179). * Fixed copyright(Close #151968). * Close #67852 and #60405. * Delete /var/lib/rcconf/services if purged(Close #205468). -- Atsushi KAMOSHIDA Mon, 22 Sep 2003 01:41:31 +0900 rcconf (1.5.1) unstable; urgency=low * NMU. * Add Build-Depends-Indep on debhelper. Closes: #190514. -- Daniel Schepler Mon, 18 Aug 2003 00:39:55 -0700 rcconf (1.5) unstable; urgency=low * Fixed missing switch flag for selecting whiptail/dialog. -- Atsushi Kamoshida Fri, 20 Jun 2003 23:55:56 +0900 rcconf (1.4) unstable; urgency=low * Support whiptail and dialog. -- Atsushi KAMOSHIDA Thu, 19 Jun 2003 00:21:42 +0900 rcconf (1.3) unstable; urgency=low * Added file-rc in Conflits(#68828,#123845) -- Atsushi KAMOSHIDA Fri, 25 Jan 2002 02:37:23 +0900 rcconf (1.2) unstable; urgency=low * Modified control description(Thanks Joey!) -- Atsushi KAMOSHIDA Mon, 8 Jan 2001 17:40:05 +0900 rcconf (1.1) unstable; urgency=low * File Format of /var/lib/rcconf/services is changed. Of course, earlier version of file format can be read. * Rcconf can handle the services which have different numbers between start and stop. -- Atsushi KAMOSHIDA Fri, 24 Mar 2000 14:52:22 +0900 rcconf (1.0) unstable; urgency=low * Stable Release. * Change Architecture to all * Add 'whiptail' to Depends. -- Atsushi KAMOSHIDA Thu, 16 Mar 2000 15:43:03 +0900 rcconf (0.5) unstable; urgency=low * Commented out debug option. -- Atsushi KAMOSHIDA Thu, 9 Mar 2000 17:34:06 +0900 rcconf (0.4) unstable; urgency=low * Added config-file feature. -- Atsushi KAMOSHIDA Tue, 29 Feb 2000 13:44:26 +0900 rcconf (0.3) unstable; urgency=low * Added guideline feature. -- Atsushi KAMOSHIDA Wed, 2 Feb 2000 16:01:54 +0900 rcconf (0.2) unstable; urgency=low * Fixed copyright statement. -- Atsushi KAMOSHIDA Sun, 9 Jan 2000 23:11:29 +0900 rcconf (0.1) unstable; urgency=low * Initial Release. -- Atsushi KAMOSHIDA Sat, 1 Jan 2000 01:50:16 +0900 rcconf-3.1ubuntu1/debian/copyright.old0000644000000000000000000000343312240061212014764 0ustar This work was packaged for Debian by: Atsushi KAMOSHIDA on Wed, 10 Mar 2010 13:34:33 +0900 It was downloaded from: Upstream Author(s): Copyright: License: This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . On Debian systems, the complete text of the GNU General Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". The Debian packaging is: Copyright (C) 2010 Atsushi KAMOSHIDA # Please chose a license for your packaging work. If the program you package # uses a mainstream license, using the same license is the safest choice. # Please avoid to pick license terms that are more restrictive than the # packaged work, as it may make Debian's contributions unacceptable upstream. # If you just want it to be GPL version 3, leave the following line in. and is licensed under the GPL version 3, see above. # Please also look if there are files or directories which have a # different copyright/license attached and list them here. rcconf-3.1ubuntu1/debian/compat0000644000000000000000000000000212240061212013447 0ustar 7 rcconf-3.1ubuntu1/debian/rules.old0000755000000000000000000000067212240061212014113 0ustar #!/usr/bin/make -f # -*- makefile -*- # Sample debian/rules that uses debhelper. # This file was originally written by Joey Hess and Craig Small. # As a special exception, when this file is copied by dh-make into a # dh-make output file, you may use that output file without restriction. # This special exception was added by Craig Small in version 0.37 of dh-make. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 %: dh $@ rcconf-3.1ubuntu1/debian/copyright0000644000000000000000000000050512240061212014204 0ustar This package was debianized by Atsushi KAMOSHIDA on Sat, 1 Jan 2000 01:50:16 +0900. Copyright: Copyright 2010 Atsushi Kamoshida Atsushi KAMOSHIDA License: This software is distributed under the GNU GPL Ver.2 . Please reference to the file '/usr/share/common-licenses/GPL'. rcconf-3.1ubuntu1/debian/README.Debian0000644000000000000000000000173312240061175014326 0ustar rcconf for Debian ---------------------- rcconf is a front-end to the update-rc.d command, which configures the System-V style init script links. Please refer to the manapge of update-rc.d for more information on these links and what they do. -- Atsushi KAMOSHIDA , Sat, 1 Jan 2000 01:50:16 +0900 NOTE: Be aware that rcconf only deals with the symlinks in the rc?.d directories, and packages may have other ways of being disabled, like: - Some files in /etc/init.d may be marked as conffiles, and someone may have changed the init script so it does not start; - Some init scripts read a variable in /etc/default/ and use it to decide if it'll start or not (spamassassin/spamd and fetchmail, for example). That means even though rcconf says package X is running, it may be not (because although the symlink is present, the package was configured not to start). -- Atsushi KAMOSHIDA , Sat, 09 Nov 2004 15:17:01 +0200 rcconf-3.1ubuntu1/debian/rcconf.postrm0000755000000000000000000000047412240061175015011 0ustar #!/bin/sh # # This is the postrm script for the Debian GNU/Linux rcconf package # Written by Atsushi Kamoshida # set -e case "$1" in remove) ;; purge) # if [ -f /var/lib/rcconf/services ]; then # rm /var/lib/rcconf/services # fi rm -rf /var/lib/rcconf ;; esac exit 0 rcconf-3.1ubuntu1/debian/rcconf.prerm0000755000000000000000000000045612240061175014612 0ustar #!/bin/sh # # This is the rerm script for the Debian GNU/Linux rcconf package # Written by Atsushi Kamoshida # set -e case "$1" in remove|upgrade|purge) if [ -e /usr/bin/rcconf ]; then rm /usr/bin/rcconf fi ;; *) ;; esac exit 0 rcconf-3.1ubuntu1/debian/rcconf.postinst0000755000000000000000000000055612240061175015351 0ustar #!/bin/sh # # This is the postinst script for the Debian GNU/Linux rcconf package # Written by Atsushi Kamoshida # set -e case "$1" in configure) if [ -f /usr/sbin/rcconf ] && [ ! -f /usr/bin/rcconf ]; then ln -s /usr/sbin/rcconf /usr/bin/rcconf fi update-rcconf-guide ;; *) ;; esac exit 0 rcconf-3.1ubuntu1/debian/control0000644000000000000000000000130712240061212013655 0ustar Source: rcconf Section: admin Priority: optional Maintainer: Ubuntu Developers XSBC-Original-Maintainer: Atsushi KAMOSHIDA Build-Depends-Indep: perl Build-Depends: debhelper (>= 7) Standards-Version: 3.8.4 Package: rcconf Architecture: all Depends: whiptail | whiptail-provider | dialog, sysv-rc, perl, perl-modules Conflicts: file-rc Description: Debian Runlevel configuration tool This tool configures system services in connection with system runlevels. It turns on/off services using the scripts in /etc/init.d/. Rcconf works with System-V style runlevel configuration. It is a TUI(Text User Interface) frontend to the update-rc.d command. rcconf-3.1ubuntu1/debian/docs0000644000000000000000000000000012240061175013122 0ustar rcconf-3.1ubuntu1/debian/dirs0000644000000000000000000000004012240061175013137 0ustar usr/bin usr/sbin var/lib/rcconf