1
0
Fork 0
mirror of https://github.com/SinTan1729/random.git synced 2024-12-25 20:58:37 -06:00

Force some scripts to run as specific user

This commit is contained in:
Sayantan Santra 2022-10-04 21:44:51 -05:00
parent 157ff0a613
commit 00d05bda07
4 changed files with 20 additions and 0 deletions

View file

@ -2,6 +2,11 @@
# This script backs up some important stuff # This script backs up some important stuff
# force script to run as specific user
if [ "$(id -u)" -eq 0 ]; then
exec sudo -H -u sintan $0 "$@"
fi
# Run only one instance of this script at one time # Run only one instance of this script at one time
[ "${BKLOCKER}" != "running" ] && exec env BKLOCKER="running" flock -en "/tmp/impfilesbk.lock" "$0" "$@" || : [ "${BKLOCKER}" != "running" ] && exec env BKLOCKER="running" flock -en "/tmp/impfilesbk.lock" "$0" "$@" || :

View file

@ -3,6 +3,11 @@
# This script backs up some important stuff # This script backs up some important stuff
# This is the version for my home server # This is the version for my home server
# force script to run as specific user
if [ "$(id -u)" -eq 0 ]; then
exec sudo -H -u sintan $0 "$@"
fi
# Run only one instance of this script at one time # Run only one instance of this script at one time
[ "${BKLOCKER}" != "running" ] && exec env BKLOCKER="running" flock -en "/tmp/impfilesbk.lock" "$0" "$@" || : [ "${BKLOCKER}" != "running" ] && exec env BKLOCKER="running" flock -en "/tmp/impfilesbk.lock" "$0" "$@" || :

View file

@ -3,6 +3,11 @@
# this script lists all packages installed in my system and saves them # this script lists all packages installed in my system and saves them
# such that it's easy to install packages in case of a system reset # such that it's easy to install packages in case of a system reset
# force script to run as specific user
if [ "$(id -u)" -eq 0 ]; then
exec sudo -H -u sintan $0 "$@"
fi
# define location for output # define location for output
DIR=/home/sintan/Documents/Backup/pkglists DIR=/home/sintan/Documents/Backup/pkglists

View file

@ -5,6 +5,11 @@
# this is the server version # this is the server version
# force script to run as specific user
if [ "$(id -u)" -eq 0 ]; then
exec sudo -H -u sintan $0 "$@"
fi
# define location for output # define location for output
DIR=/mnt/storage/Documents/Backup/pkglists_server DIR=/mnt/storage/Documents/Backup/pkglists_server