Service starts when system boots and executes actualitzat.sh
.
If the file /root/paquets exists, its content is passed by parameter to actualitzat.sh
.
Last active
February 24, 2023 19:47
-
-
Save carlosmgv02/474352f117cde4655dcc553234e5c18f to your computer and use it in GitHub Desktop.
Custom service used to run own script when system boots
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Autor: Carlos Martínez | |
### BEGIN INIT INFO | |
# Provides: ex1 | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 | |
# Default-Stop | |
# Short-Description: Script que s'executa al bootejar i comprova si existeix un fitxer | |
# Description: ... | |
### END INIT INFO | |
PATH=/bin:/usr/bin:/sbin:/usr/sbin | |
NAME="ex1" | |
SCRIPT="/home/milax/Documents/GitHub/gsx-lab0/actualitzat.sh" | |
case "$1" in | |
start) | |
log_daemon_msg "Starting periodic command scheduler" "ex1" | |
if [ -e /root/paquets ]; then | |
PARAMS=`cat /root/paquets` | |
$SCRIPT $PARAMS | |
else | |
logger "El archivo /root/paquets no existe." | |
fi | |
log_end_msg $? | |
;; | |
stop) | |
log_daemon_msg "Stopping periodic command scheduler" "ex1" | |
;; | |
restart) | |
$0 stop | |
$0 start | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment