# **********************************************************************# Description of the Linux shell self-startup script #: # When we are doing the system, writing from the startup script is often the case, the following is a sample analysis. ## .-1-TenShenzhen Nanshan Ping Shan Village Zengjianfeng #**********************************************************************#!/bin/SH# The script runs shell## sshd starts sshd. # description # # Then there are some conditions that need to be met before running the script, mainly to do some checking of the nature of the content, # to prevent subsequent programs from running, some environmental problems, or other follow-up procedures need to run the prerequisite for checking. # Make sure theSsh-keygenprogam exists[-f/usr/bin/Ssh-keygen] || Exit0# Create any missing keys/usr/bin/Ssh-keygen-a# If a file needs to be generated, some permissions want to be given by default, so that you don't have to give permission every time. Umask077# When the system starts, the function start () {printf"starting sshd:"/usr/sbin/sshdTouch/var/lock/sshdEcho "OK"}# When the system starts to stop, run the function stop () {printf"stopping sshd:" KillallsshdRM-f/var/lock/sshdEcho "OK"}# function Restart () {Stop start}# is considered to be a branch call to the above three functions when the system starts to restart Case " $" inchstart) Start # Call the start function;; STOP) Stop # calls the Stop function;; Restart|Reload) Restart # call restart function;; *) Echo "Usage: $ {Start|stop|restart}"Exit1Esac# Exit and return execution result exit $?
Linux Shell Self-priming script notation