#!/bin/sh ###################################################################### # Gary Keen version 0.0.2 # 01/02/21 | 1/22/21 # # Description: # A script to put in place all the files,permissions,directories # needed to convert systemd startup to systemV startup. # # /root/StartupScripts -- All startup script that do not start with READ # will get executed # /usr/lib/systemd/system/mystartup.service -- Unit file # /etc/rc.d/init.d/StartUp --- Must be executable # # REDHAT DIRIVATIVE SPECIFIC # # Notes/Updates: # -- Changed the way the init script is built. Tail the bottom of this script. # I know not very elegant but the $variables and exe code wouldn't show up. # ###################################################################### # #========================= Create variables =========================# # ROOTDIR=/root/StartupScripts INITSCRPT=/etc/rc.d/init.d/StartUp UNITFILE=/usr/lib/systemd/system/mystartup.service REDME=$ROOTDIR/README.txt # #======================== Build functions ============================# # contin () { echo "Press enter to continue." read ANSW0 } # enablescript () { systemctl enable mystartup.service systemctl status mystartup.service } # readme () { echo " Directory and file location: startup script directory = $ROOTDIR Drop script here to have them executes at startup. unit file = /usr/lib/systemd/system/mystartup.service initscript = /etc/rc.d/init.d/StartUp" >$REDME } # open () { echo echo "This script creates a directory in /root call StartupScripts" echo "Anything dropped in that directory that DOSE NOT begin with" echo "the word READ. Will be executed during startup." echo echo "This script creates a systemd unit file and a script to be" echo "executed from that unit file." echo contin } # crtfiledirs () { mkdir $ROOTDIR sleep 1 touch $INITSCRPT chmod 755 $INITSCRPT touch $UNITFILE } # initscript () { cat $0 | tail -19 >$INITSCRPT } # unitfile () { echo "[Unit] Description=My startup scripts After=network.target [Service] ExecStart=/etc/rc.d/init.d/StartUp & [Install] WantedBy=multi-user.target WantedBy=graphical.target" > $UNITFILE } # crtlinks () { ln -s /etc/rc.d/init.d/StartUp $ROOTDIR/README_startup_init_script ln -s /usr/lib/systemd/system/mystartup.service $ROOTDIR/README_mystartup_unit_file echo echo "Drop executable script in the /root/StartupScripts to have them executed at startup." echo } # # #============================ Execute functions =============================# # echo echo "I'm not sure this script is ready for prime time yet." echo "Use at your own risk until I can confirm it works as it should." echo contin open crtfiledirs initscript unitfile sleep 1 enablescript crtlinks readme #------EOF--------DO NOT CHANGE ANYTHING BELOW THIS LINE-------EOF----------# #!/bin/sh ###################################################################### # Gary Keen # # # One startup to rule them all # # # # ###################################################################### SCRIPTDIR=/root/StartupScripts for A in `ls $SCRIPTDIR | grep -v READM` do echo $A $SCRIPTDIR/$A done