Hi, In the Solaris world and most SYSV systems like it, there was a very simple startup system; it was not systemd, nor is it the "modern day" sysvinit. It was much simpler and worked very, very well and extremely reliably. How can we get that back on modern Debian?
I mean simple, just like this: - when entering a run level (start passed to each script) - run all S scripts in alphanumeric order S02xxx before S03xxx and S02aaa before S02aab ... - when exiting a run level (stop passed to each script) - run all K scripts in alphanumeric order K02xxx before K03xxx and K02aaa before K02aab ... The order of the scripts alone allowed for everything to be very, very simple and no script relied upon any other; they were self dependent. If you wanted something to be available before your script, you made sure your numeric number after the S in the script name (or rather the symlink name back to the /etc/init.d directory file) was higher. It was simple, it worked perfectly, it worked like a standard program would, sequentially... as I understand it, each script ran in order and the next script didn't run until the prior one was finished. This doesn't allow for streamlining, unless you backgrounded procesess in scripts, but it was extremely simple and reliable just the same, it got the job done (even if more slowly than some might like) -- the simpleness and reliability were the major trump card featuress of the system. Now I have sysvinit isntalled on wheezy, it is failing to run a simple script during system boot (as part of a planed reboot) and I cannot work out why. # ls -l /etc/{init.d,rc*.d}/*archive* -rwxr-xr-x 1 root root 1453 Jun 8 04:12 /etc/init.d/archive-system-mail lrwxrwxrwx 1 root root 29 Jun 3 23:30 /etc/rc2.d/S02archive-system-mail -> ../init.d/archive-system-mail lrwxrwxrwx 1 root root 29 Jun 4 03:06 /etc/rc3.d/S02archive-system-mail -> ../init.d/archive-system-mail lrwxrwxrwx 1 root root 29 Jun 4 03:07 /etc/rc4.d/S02archive-system-mail -> ../init.d/archive-system-mail lrwxrwxrwx 1 root root 29 Jun 4 03:08 /etc/rc5.d/S02archive-system-mail -> ../init.d/archive-system-mail Now, I want the archiving script to run on system startup, I don't want dovecot or exim4 to be running when the script starts, it simply needs to have the /backup and /var file systems mounted to do it's required job. My script is meant to create a log file in the /var/log directory. If I run the script manually, it works perfectly. There are some generic parts in the script, it is a fairly simple script, even if a little bit over complicated. What do I need to do to fix it? Here is the script: # cat /etc/init.d/archive-system-mail #! /bin/sh ### BEGIN INIT INFO # Provides: mailarchive # Required-Start: $syslog # Required-Stop: $syslog # Default-Start: 2 3 4 5 # Default-Stop: # Short-Description: Save exim4 system_filter archive ### END INIT INFO # Author: Andrew McGlashan <andrew.mcglas...@affinityvision.com.au> set -x NAME=archive-system-mail SCRIPTNAME=/etc/init.d/$NAME do_cleanup() { # Cleanup echo -e "\a\a\aPerforming cleanup" exit $1 } error_exit() { # Display error message and exit echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2 do_cleanup 1 } get_archivedir() { for x in a b c d e f g h i j k l m n o p q r s t u v w x y z do ARCHIVE_DIR=/backup/mail/system_filter_all_mail/archive/${DATEX}${x} if [ ! -d $ARCHIVE_DIR ]; then VER=$x; return 0; fi done return 1 } do_main() { ( get_archivedir || error_exit "Cannot get archive dir" if [ ! -d ${ARCHIVE_DIR} ];then /bin/mkdir $ARCHIVE_DIR;fi #/bin/mv /backup/mail/system_filter_all_mail/log--lots $ARCHIVE_DIR/ #/bin/mv /backup/mail/system_filter_all_mail/Maildir $ARCHIVE_DIR/ /usr/bin/touch $ARCHIVE_DIR/log--lots.$$ /bin/mkdir $ARCHIVE_DIR/Maildir.$$ ) 2>&1 | /usr/bin/tee /var/log/${PROGNAME}--$(date +%Y%m%d%H%M%S).log } # main trap "do_cleanup 99" HUP INT TERM # Global Variables ARCHIVE_DIR= DATEX=$(/bin/date +%Y%m%d) PROGNAME=$(/usr/bin/basename $0) case "$1" in start) do_main ;; *) echo "Usage: $SCRIPTNAME {start}" >&2 exit 3 ;; esac : Thanks AndrewM
signature.asc
Description: OpenPGP digital signature