Fedora Initialization Files

Thread Starter

Brownout

Joined Jan 10, 2012
2,390
I want to define a file to be executed upon system startup in Fedora 20. I made this simple file and saved it in "/etc/init.d"

Code:
#!/bin/sh /etc/rc.common
#chkconfig: 2345 20 80
#description: first init script for testing

start() {
echo "Hello World from myfirstinit start"
mkdir /home/danny/from_init
}

stop() {
echo "Hello World from myfirstinit stop"
}

echo -n $"MyFirstInit" > /home/danny/init

case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
reload)
        stop
        start
        ;;
*)
        echo $"usage $0 {start | stop}"
        exit 2
esac
This code should output a couple messages, depending on which argument is supplied, and also create a file names "init" and a directory named "from_init" in my home directory. Everything works perfectly if I run it like this:

:source ./myfirstinit start"

However, let's say I run it like this: "systemctl start myfirstsysteminit" it doesn't appear to do anything. An entry in the system log shows : SYS ... first init script for testing, which is the description in the file. That shows that systemctrl finds the right script and tries to execute it, but none of the other things happed.

Supposedly, this old style init file should be supported in Fedora 20. Can anyone see anything I'm doing wrong?
 

Thread Starter

Brownout

Joined Jan 10, 2012
2,390
PS: In addition, I ran "chkconfig --add myfirstinit" to make the script available. And I run the following script and get the result shown:

Code:
[root@localhost etc]# for i in {0..6}; do cd rc$i.d; pwd; ls -l | grep myfirstinit; cd ..; done
/etc/rc0.d
lrwxrwxrwx  1 root root 21 Jan  7 18:43 K80myfirstinit -> ../init.d/myfirstinit
/etc/rc1.d
lrwxrwxrwx  1 root root 21 Jan  7 18:43 K80myfirstinit -> ../init.d/myfirstinit
/etc/rc2.d
lrwxrwxrwx  1 root root 21 Jan  7 18:43 S20myfirstinit -> ../init.d/myfirstinit
/etc/rc3.d
lrwxrwxrwx  1 root root 21 Jan  7 18:43 S20myfirstinit -> ../init.d/myfirstinit
/etc/rc4.d
lrwxrwxrwx  1 root root 21 Jan  7 18:43 S20myfirstinit -> ../init.d/myfirstinit
/etc/rc5.d
lrwxrwxrwx  1 root root 21 Jan  7 18:43 S20myfirstinit -> ../init.d/myfirstinit
/etc/rc6.d
lrwxrwxrwx  1 root root 21 Jan  7 18:43 K80myfirstinit -> ../init.d/myfirstinit
 
Top