Fedora Initialization Files

Discussion in 'Computing and Networks' started by Brownout, Jan 8, 2015.

  1. Brownout

    Thread Starter Well-Known Member

    Jan 10, 2012
    2,375
    998
    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 (Text):
    1. #!/bin/sh /etc/rc.common
    2. #chkconfig: 2345 20 80
    3. #description: first init script for testing
    4.  
    5. start() {
    6. echo "Hello World from myfirstinit start"
    7. mkdir /home/danny/from_init
    8. }
    9.  
    10. stop() {
    11. echo "Hello World from myfirstinit stop"
    12. }
    13.  
    14. echo -n $"MyFirstInit" > /home/danny/init
    15.  
    16. case "$1" in
    17. start)
    18.         start
    19.         ;;
    20. stop)
    21.         stop
    22.         ;;
    23. reload)
    24.         stop
    25.         start
    26.         ;;
    27. *)
    28.         echo $"usage $0 {start | stop}"
    29.         exit 2
    30. esac
    31.  
    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?
     
  2. Brownout

    Thread Starter Well-Known Member

    Jan 10, 2012
    2,375
    998
    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 (Text):
    1. [root@localhost etc]# for i in {0..6}; do cd rc$i.d; pwd; ls -l | grep myfirstinit; cd ..; done
    2. /etc/rc0.d
    3. lrwxrwxrwx  1 root root 21 Jan  7 18:43 K80myfirstinit -> ../init.d/myfirstinit
    4. /etc/rc1.d
    5. lrwxrwxrwx  1 root root 21 Jan  7 18:43 K80myfirstinit -> ../init.d/myfirstinit
    6. /etc/rc2.d
    7. lrwxrwxrwx  1 root root 21 Jan  7 18:43 S20myfirstinit -> ../init.d/myfirstinit
    8. /etc/rc3.d
    9. lrwxrwxrwx  1 root root 21 Jan  7 18:43 S20myfirstinit -> ../init.d/myfirstinit
    10. /etc/rc4.d
    11. lrwxrwxrwx  1 root root 21 Jan  7 18:43 S20myfirstinit -> ../init.d/myfirstinit
    12. /etc/rc5.d
    13. lrwxrwxrwx  1 root root 21 Jan  7 18:43 S20myfirstinit -> ../init.d/myfirstinit
    14. /etc/rc6.d
    15. lrwxrwxrwx  1 root root 21 Jan  7 18:43 K80myfirstinit -> ../init.d/myfirstinit
     
  3. harry85

    New Member

    Jan 21, 2015
    5
    1
    sometimes it will occured a problem.
     
  4. tjohnson

    Active Member

    Dec 23, 2014
    614
    121
  5. Brownout

    Thread Starter Well-Known Member

    Jan 10, 2012
    2,375
    998
    The first method is the same as described in the original post, though there remains the possibility that I've made a mistake. I'll take a look at the other methods to see if there's anything I can use. Also, I found this page by mistake:

    http://www.ibm.com/developerworks/library/l-lpic1-v3-101-3/

    Lots of good info, but I haven't digested it all yet.
     
Loading...