Time for action – adding the init script
We are going to use a simple shell script, as shown in the following example, which takes a single command line argument and acts accordingly:
#!/bin/bash # init script to control Squid server case "$1" in start) /opt/squid/sbin/squid ;; stop) /opt/squid/sbin/squid -k shutdown ;; reload) /opt/squid/sbin/squid -k reconfigure ;; restart) /opt/squid/sbin/squid -k shutdown sleep 2 /opt/squid/sbin/squid ;; *) echo $"Usage: $0 {start|stop|reload|restart}" exit 2 esac exit $?
Please note the absolute path to the Squid executable here and change it accordingly. We can save this shell script to a file with the name squid
and then move it to one of the directories we discussed earlier depending on our operating system.
Note
The Squid source carries an init
script located at contrib/squid.rc
, but it's installed only on a few systems by default.
What just happened?
We added an init
script to control the Squid proxy server. Using this...