mirror of
https://github.com/sbopkg/sbopkg
synced 2025-02-10 20:47:56 +01:00
recombine the sanity check and config check, but separate out the pid file check.
This commit is contained in:
parent
1620caf654
commit
2e8790b07c
1 changed files with 27 additions and 26 deletions
|
@ -41,7 +41,7 @@ CWD="$(pwd)"
|
||||||
SBOVER=SVN
|
SBOVER=SVN
|
||||||
UPDATE_DEBUG="1" # This will be uncommented in SVN and RC releases
|
UPDATE_DEBUG="1" # This will be uncommented in SVN and RC releases
|
||||||
|
|
||||||
config_check () {
|
sanity_checks () {
|
||||||
# Check if config file is there and if so check that it has all
|
# Check if config file is there and if so check that it has all
|
||||||
# needed variables with any value, and set them.
|
# needed variables with any value, and set them.
|
||||||
if [ ! -e $SBOPKG_CONF ]; then
|
if [ ! -e $SBOPKG_CONF ]; then
|
||||||
|
@ -64,25 +64,6 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
sanity_checks () {
|
|
||||||
# Set and check for pid file; check and see if local repository,
|
|
||||||
# $SRCDIR, and $TMPDIR exist and if not, offer to create them.
|
|
||||||
PIDFILE=$TMP/sbopkg.pid
|
|
||||||
trap 'rm -rf $PIDFILE; exit 1' TERM INT
|
|
||||||
if [ -e $PIDFILE ]; then
|
|
||||||
echo
|
|
||||||
echo "Another instance of sbopkg appears to be running"
|
|
||||||
echo "with process id $(cat $PIDFILE). Running more than"
|
|
||||||
echo "one instance of sbopkg is not recommended."
|
|
||||||
echo
|
|
||||||
echo "If this is incorrect, you can delete the lockfile"
|
|
||||||
echo "'${PIDFILE}' and restart. Exiting now."
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo $$ > $PIDFILE
|
|
||||||
fi
|
|
||||||
if [ ! -d "$LOCALREPO/$SLACKVER" ]; then
|
if [ ! -d "$LOCALREPO/$SLACKVER" ]; then
|
||||||
echo
|
echo
|
||||||
echo "Creating local repo directory $LOCALREPO/$SLACKVER"
|
echo "Creating local repo directory $LOCALREPO/$SLACKVER"
|
||||||
|
@ -117,6 +98,25 @@ if [ ! -d "$TMP" ]; then
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pid_check () {
|
||||||
|
# Set and check for pid file.
|
||||||
|
PIDFILE=$TMP/sbopkg.pid
|
||||||
|
trap 'rm -rf $PIDFILE; exit 1' TERM INT
|
||||||
|
if [ -e $PIDFILE ]; then
|
||||||
|
echo
|
||||||
|
echo "Another instance of sbopkg appears to be running"
|
||||||
|
echo "with process id $(cat $PIDFILE). Running more than"
|
||||||
|
echo "one instance of sbopkg is not recommended."
|
||||||
|
echo
|
||||||
|
echo "If this is incorrect, you can delete the lockfile"
|
||||||
|
echo "'${PIDFILE}' and restart. Exiting now."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
cleanup
|
||||||
|
echo $$ > $PIDFILE
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
check_root () {
|
check_root () {
|
||||||
# Check to see whether the user is root or not.
|
# Check to see whether the user is root or not.
|
||||||
if [ ! $(id -u) = "0" ]; then
|
if [ ! $(id -u) = "0" ]; then
|
||||||
|
@ -912,7 +912,9 @@ if [ $WRITE = "false" ]; then
|
||||||
echo "it appears that you do not have sufficient permissions to"
|
echo "it appears that you do not have sufficient permissions to"
|
||||||
echo "do so. Please check your \$TMP setting in sbopkg.conf,"
|
echo "do so. Please check your \$TMP setting in sbopkg.conf,"
|
||||||
echo "verify that your permissions are correct, or manually"
|
echo "verify that your permissions are correct, or manually"
|
||||||
echo "delete any leftover files in \$TMP. Exiting."
|
echo "delete any leftover files in \$TMP. Some features of"
|
||||||
|
echo "sbopkg are generally available only to the root user,"
|
||||||
|
echo "so running sbopkg as root may be advisable. Exiting."
|
||||||
echo
|
echo
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
|
@ -1011,13 +1013,14 @@ done
|
||||||
# If there are no command line options then we will use the dialog
|
# If there are no command line options then we will use the dialog
|
||||||
# version of sbopkg.
|
# version of sbopkg.
|
||||||
|
|
||||||
cleanup # Do this first just in case there is cruft left over.
|
sanity_checks # Do this first to make sure we have a valid config.
|
||||||
|
|
||||||
config_check # Next, check to make sure we have a valid config.
|
pid_check
|
||||||
|
|
||||||
|
#cleanup # Do this next just in case there is cruft left over.
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
DIAG=1
|
DIAG=1
|
||||||
sanity_checks
|
|
||||||
main_menu
|
main_menu
|
||||||
cleanup
|
cleanup
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -1086,8 +1089,6 @@ if [ -n "$VERSION" ]; then
|
||||||
SLACKVER=$CUSTOMVER
|
SLACKVER=$CUSTOMVER
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sanity_checks
|
|
||||||
|
|
||||||
if [ -n "$BUILD" ]; then
|
if [ -n "$BUILD" ]; then
|
||||||
check_root
|
check_root
|
||||||
if [ $ROOT = "false" ]; then
|
if [ $ROOT = "false" ]; then
|
||||||
|
|
Loading…
Add table
Reference in a new issue