john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

Services disable startup debian ubuntu rcconf dialog init

[TOC]

Create or remove a script from running at boot or shutdown

How to make a startup script for linux/debian/ubuntu

Write a startup script and place it in /etc/init.d cd /etc/init.d/

the location of all systemd init d startup scripts (not upstart nor runit nor ?)

vi SCRIPTNAME.sh
    #/bin/sh

chmod +x SCRIPTNAME.sh

ensure your script is executable

update-rc.d SCRIPTNAME.sh defaults

install the script on run levels 2,3,4, and 5 (and stop the script on 0,1,and 6)

update-rc.d -f SCRIPTNAME.sh remove

remove the script and symlinks from /etc/rc2.d and other directories even if it does not exist

Overview

control-alt-f4 allows you to see installation messages during bootup

update-rc.d is a Debian utility to install scripts.

Also, to know which runlevel you are in, use the command: runlevel

e.g. results in N 2

Runlevel 0 is Halt.
Runlevel 1 is single user mode
Runlevel 2 Basic multi-user mode (text)
Runlevel 5 Full (GUI based) multi-user mode
Runlevel 6 is reboot

FOR FUN TRY: init 6 , this will reboot the system

update-rc.d SCRIPTNAME.sh start 0123 . stop 456 .

RCS means startup , RCK means kill

update-rc.d apache2 defaults 20 80

different priorities for startup and shutdown

update-rc.d apache2 start 20 2 3 4 . start 30 5 . stop 80 0 1 6 .

start with priority 20 for runlevel 2, 3 and 4 and priority 30 for 5 and kill with priority 80 for runlevel 0, 1 and 6

/etc/inittab

The boot process uses these parameters to identify the default runlevel and the files that will be used by that runlevel. In this example, runlevel 4 is the default and the scripts that define runlevel 4 can be found in /etc/rc.d/rc.4.

(symbolic link to it from the appropriate runlevel directory ?) (or runlevel file, if that's what your system uses)

/etc/rc.d/rc.local file.

This script file is run once, before all other scripts have run but before the logon prompt appears

e.g. modprobe -r uhcimodprobe usb-uhcieciadsl-startiptable -Fiptables -A


An example Bamboo CI startup script

:::bash #!/bin/bash # Bamboo startup script # chkconfig: 2345 90 90 # description: Atlassian Bamboo

BAMBOO_USER=bamboo
#BAMBOO_HOME=/usr/local/bin/bamboo
BAMBOO_HOME=/opt/atlassian-bamboo-5.1.1/bin

start() {
echo "Starting Bamboo: "
$BAMBOO_HOME/start-bamboo.sh start
echo "done."
}

stop() {
echo "Stopping Bamboo: "
$BAMBOO_HOME/stop-bamboo.sh stop
echo "done."
}

case "$1" in
    start)
      start
    ;;
    stop)
      stop
    ;;
    status)
      ps aux | grep bamboo | grep -v 'grep'
    ;;
    restart)
      stop
      sleep 5
      start
    ;;
    *)
      echo "Usage: $0 {start|stop|restart|status}"
esac

exit 0

Alternative ways to configure startup services

Faster boot and faster machines means less packages installed and less services starting

apt-get install -y rcconf
rcconf
    ERROR "rcconf needs dialog or whiptail"
apt-get install -y dialog

similar to chkconfig, a dialog/whiptail based UI to list and enable/disable services


apt-get purge brltty brltty-x11 ttf-indic-fonts-core ttf-kacst-one ttf-khmeros-core ttf-lao ttf-punjabi-fonts ttf-unfonts-core

I don't need: braille tty and true type fonts: indian, khmer, lao, korean

apt-get install rcconf bum
>  rcconf is a great cli, bum has a gui and better service descriptions

    # disable: openvpn (just /etc/init.d/openvpn start when needed)
    # brltty: braille tty
    # speech-dispatcher: voice command computer

sudo update-rc.d /etc/init.d/myscript.sh defaults 99

modify the priority (ordering) of when it is run during boot/shutdown

chkconfig --list        // this will show you what services are "on" at what run levels
chkconfig servicename off   //will turn it off for the runlevel that you're on...
                //generally we only care about runlevel 2 for our servers

chkconfig httpd off             //disable httpd service on boot

enabled services:

smartd
mctrans = selinux

restore cond
readahead_early

gpm = mouse

network

microcode ctl
messagebus

disabled:

firstboot = menu on boot to configure firewall, services, etc.

MIT = network services
sendmail = if using mail services?

finger = very old protocol/application

irda = infra red devices!

rpcidmapd
rpcgssd
mdmmonitor = software raid
portmap
pcscd
haldaemon
exim
nfslock
netfs = auto mount on boot network shares
lvm2-monitor = lvm
cpuspped = save electricity
bluetooth 
ncid
hidd
pand
capi = isdn
acpi = power management (e.g. turn off hard disk when not in use)
apmd = older laptops
autofs = auto mount usb sticks
avahi = alternate to the DNS services system

hplip = hp printers
iod = same as above

rcconf is great for /etc/init.d/ jobs (which are controlled by update-rc.d)


startup jobs instead of init.d = Jobs are defined in files placed in /etc/init

http://upstart.ubuntu.com/getting-started.html

BUT for "upstart" jobs (/etc/init/JOBNAME.conf ) an easy way is to just comment out the start

sudo nano /etc/init/avahi-daemon.conf

start on (filesystem and started dbus)

/etc/init/tty1.conf

start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]

respawn
# exec /sbin/getty -8 38400 tty1
exec /sbin/getty -n -l /usr/sbin/leapfileconsole.pl 38400 tty1

etc/rc.d/rc.sysinit ?


  • « pyinotify watch directory all events
  • s3 boto list keys download to file »

Published

Oct 29, 2013

Category

linux

~719 words

Tags

  • debian 10
  • dialog 1
  • disable 8
  • init 4
  • linux 249
  • rcconf 1
  • services 4
  • startup 5
  • ubuntu 30