check for existing files to detect webmin/usermin instead of dir name

This commit is contained in:
Gnadelwartz
2018-02-11 11:45:13 +01:00
parent 3e55eb08f2
commit ecc932b2b7

View File

@@ -3,14 +3,14 @@
# Update webmin/usermin to the latest develop version from GitHub repo
# inspired by authentic-theme/theme-update.sh script, thanks qooob
#
# Version 1.4, 2018-01-31
# Version 1.4, 2018-02-11
#
# Kay Marquardt, kay@rrr.de, https://github.com/gandelwartz
#############################################################################
# Get webmin/usermin dir based on script's location
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROD=${DIR##*/} # => usermin or webmin
PROD="webmin" # default
# where to get source
HOST="https://github.com"
REPO="webmin/$PROD"
@@ -72,21 +72,21 @@ EOF
exit 0
fi
if [[ "${PROD}" != "webmin" && "${PROD}" != "usermin" ]] ; then
echo -e "${NC}${RED}error: the current dir name hast to be webmin or usermin, no update possible!${NC}"
echo -e "possible solution: ${ORANGE}ln -s ${PROD} ../webmini; cd ../webmin${NC} or ${ORANGE}ln -s ${PROD} ../usermin; cd ../webmin ${NC}"
# check for required webmin / usermin files in current dir
if [[ ! -r "${DIR}/setup.sh" || ! -r "${DIR}/miniserv.pl" ]] ; then
echo -e "${NC}${RED}error: the current dir seems not to contain a webmin installation, no update possible!${NC}"
exit 1
fi
# need to be root
if [[ $EUID -ne 0 ]]; then
echo -e "${RED}Error: This command has to be run under the root user.${NC}"
echo -e "${RED}error: This command has to be run under the root user.${NC}"
exit 2
fi
# git has to be installed
echo -en "${CYAN}search minserv.conf ... ${NC}"
if [[ -f "/etc/webmin/miniserv.conf" ]] ; then
if [[ -r "/etc/webmin/miniserv.conf" ]] ; then
# default location
MINICONF="/etc/webmin/miniserv.conf"
echo -e "${ORANGE}found: ${MINICONF}${NC}"
@@ -110,11 +110,17 @@ fi
# Clear screen for better readability
[[ "${ASK}" == "YES" ]] && clear
# determine if its usermin
if [[ -r "${DIR}/usermin-init" && -r "${DIR}/uconfig.cgi" ]] ; then
echo -e "${ORANGE}Usermin detected ...${NC}"
PROD="usermin"
fi
# alternative repo given
if [[ "$1" == *"-repo"* ]]; then
if [[ "$1" == *":"* ]] ; then
REPO=${1##*:}
[[ "${REPO##*/}" != "webmin" && "${REPO##*/}" != "usermin" ]] && echo -e "${RED}error: ${ORANGE} ${REPO} is not a valid repo name!${NC}" && exit 0
[[ "${REPO##*/}" != "webmin" && "${REPO##*/}" != "usermin" ]] && echo -e "${RED}error: ${ORANGE} ${REPO} is not a valid repo name!${NC}" && exit 1
shift
else
echo -e "${ORANGE}./`basename $0`:${NC} found -repo without parameter"