mirror of
https://github.com/webmin/webmin.git
synced 2025-08-22 18:11:38 +00:00
fix for usermin, some optimisations
This commit is contained in:
@ -7,7 +7,7 @@
|
|||||||
#
|
#
|
||||||
# Kay Marquardt, kay@rrr.de, https://github.com/gandelwartz
|
# Kay Marquardt, kay@rrr.de, https://github.com/gandelwartz
|
||||||
#############################################################################
|
#############################################################################
|
||||||
IAM=`basename $0`
|
|
||||||
# don't ask -y given
|
# don't ask -y given
|
||||||
ASK="YES"
|
ASK="YES"
|
||||||
if [[ "$1" == "-y" || "$1" == "-yes" || "$1" == "-f" || "$1" == "-force" ]] ; then
|
if [[ "$1" == "-y" || "$1" == "-yes" || "$1" == "-f" || "$1" == "-force" ]] ; then
|
||||||
@ -33,6 +33,9 @@ if [[ -t 1 && "${NCOLOR}" != "YES" ]] ; then
|
|||||||
NC='\e[0m'
|
NC='\e[0m'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Clear screen for better readability
|
||||||
|
[[ "${ASK}" == "YES" ]] && clear
|
||||||
|
|
||||||
# Get webmin/usermin dir based on script's location
|
# Get webmin/usermin dir based on script's location
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
PROD="webmin" # default
|
PROD="webmin" # default
|
||||||
@ -56,7 +59,7 @@ LTEMP="${DIR}/.~lang"
|
|||||||
# help requested output usage
|
# help requested output usage
|
||||||
if [[ "$1" == "-h" || "$1" == "--help" ]] ; then
|
if [[ "$1" == "-h" || "$1" == "--help" ]] ; then
|
||||||
echo -e "${NC}${ORANGE}This is the unofficial webmin update script${NC}"
|
echo -e "${NC}${ORANGE}This is the unofficial webmin update script${NC}"
|
||||||
echo "Usage: ${IAM} [-force] [-repo:username/xxxmin] [-release[:number]] [-file file ...]"
|
echo "Usage: ./`basename $0` [-force] [-repo:username/xxxmin] [-release[:number]] [-file file ...]"
|
||||||
[[ "$1" == "--help" ]] && cat <<EOF
|
[[ "$1" == "--help" ]] && cat <<EOF
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
@ -66,32 +69,13 @@ Parameters:
|
|||||||
do not output colors
|
do not output colors
|
||||||
-repo
|
-repo
|
||||||
pull from alternative github repo, format: -repo:username/reponame
|
pull from alternative github repo, format: -repo:username/reponame
|
||||||
reponame must "webmin" or "usermin"
|
reponame can be "webmin" or "usermin"
|
||||||
default github repo: webmin/webmin
|
default github repo: webmin/webmin
|
||||||
-release
|
-release
|
||||||
pull a released version, default: -release:latest
|
pull a released version, default release: -release:latest
|
||||||
-file
|
-file
|
||||||
pull only the given file(s) or dir(s) from repo
|
pull only the given file(s) or dir(s) from repo
|
||||||
|
|
||||||
Examples:
|
|
||||||
${IAM}
|
|
||||||
uodate everthing from default webmin repository
|
|
||||||
${IAM} -force or ${IAM} -yes
|
|
||||||
same but without asking,
|
|
||||||
${IAM} -fore -repo:qooob/webmin
|
|
||||||
updadte from qooobs repository without asking
|
|
||||||
${IAM} -file module/module.info
|
|
||||||
pull module.info for given module
|
|
||||||
${IAM} -file cpan
|
|
||||||
pull everything in cpan
|
|
||||||
${IAM} -file cpan/*
|
|
||||||
pull only existing files / dirs in cpan
|
|
||||||
${IAM} -file module/lang
|
|
||||||
pull all lang files of a module
|
|
||||||
${IAM} -fore -repo:qooob/webmin -file */lang
|
|
||||||
pull lang files for all existing */lang from qooobs
|
|
||||||
repository without asking
|
|
||||||
|
|
||||||
Exit codes:
|
Exit codes:
|
||||||
0 - success
|
0 - success
|
||||||
1 - abort on error or user request, nothing changed
|
1 - abort on error or user request, nothing changed
|
||||||
@ -107,7 +91,7 @@ fi
|
|||||||
|
|
||||||
# check for required webmin / usermin files in current dir
|
# check for required webmin / usermin files in current dir
|
||||||
if [[ ! -r "${DIR}/setup.sh" || ! -r "${DIR}/miniserv.pl" ]] ; then
|
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}"
|
echo -e "${NC}${RED}Error: the current dir does not contain a webmin installation, aborting ...${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -117,19 +101,29 @@ if [[ $EUID -ne 0 ]]; then
|
|||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# git has to be installed
|
# search for config location
|
||||||
echo -en "${CYAN}Search for minserv.conf ... ${NC}"
|
echo -en "${CYAN}Search for ${RPOD^} configuration ... ${NC}"
|
||||||
if [[ -r "/etc/webmin/miniserv.conf" ]] ; then
|
for conf in /etc/${PROD} /var/packages/${PROD}/target/etc
|
||||||
# default location
|
do
|
||||||
MINICONF="/etc/webmin/miniserv.conf"
|
if [[ -r "${conf}/miniserv.conf" ]] ; then
|
||||||
echo -e "${ORANGE}found: ${MINICONF}${NC}"
|
MINICONF="${conf}/miniserv.conf"
|
||||||
else
|
echo -e "${ORANGE}found: ${MINICONF}${NC}"
|
||||||
# possible other locations
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# check for other locations if not in default
|
||||||
|
if [[ "${MINICONF}" == "" ]] ; then
|
||||||
MINICONF=`find /* -maxdepth 6 -name miniserv.conf 2>/dev/null | grep ${PROD} | head -n 1`
|
MINICONF=`find /* -maxdepth 6 -name miniserv.conf 2>/dev/null | grep ${PROD} | head -n 1`
|
||||||
echo -e "${ORANGE}found: ${MINICONF}${NC} (alternative location)"
|
echo -e "${ORANGE}found: ${MINICONF}${NC} (alternative location)"
|
||||||
fi
|
fi
|
||||||
[[ "${MINICONF}" != "" ]] && export PATH="${PATH}:`grep path= ${MINICONF}| sed 's/^path=//'`"
|
|
||||||
|
|
||||||
|
# add PATH from config to system PATH
|
||||||
|
if [[ "${MINICONF}" != "" ]] ; then
|
||||||
|
export PATH="${PATH}:`grep path= ${MINICONF} | sed 's/^path=//'`"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if git is availible
|
||||||
if type ${GIT} >/dev/null 2>&1 ; then
|
if type ${GIT} >/dev/null 2>&1 ; then
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
@ -140,23 +134,21 @@ fi
|
|||||||
|
|
||||||
################
|
################
|
||||||
# lets start
|
# lets start
|
||||||
# Clear screen for better readability
|
|
||||||
[[ "${ASK}" == "YES" ]] && clear
|
|
||||||
|
|
||||||
# alternative repo given
|
# alternative repo given
|
||||||
if [[ "$1" == *"-repo"* ]]; then
|
if [[ "$1" == *"-repo"* ]]; then
|
||||||
if [[ "$1" == *":"* ]] ; then
|
if [[ "$1" == *":"* ]] ; then
|
||||||
REPO=${1##*:}
|
REPO=${1##*:}
|
||||||
[[ "${REPO##*/}" != "webmin" && "${REPO##*/}" != "usermin" ]] && echo -e "${RED}error: ${ORANGE} ${REPO} is not a valid repo name!${NC}" && exit 1
|
[[ "${REPO##*/}" != "webmin" && "${REPO##*/}" != "usermin" ]] && echo -e "${RED}Error: ${REPO} is not a valid repo name!${NC}" && exit 1
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
echo -e "${ORANGE}./`basename $0`:${NC} Argument -repo needs parameter"
|
echo -e "${ORANGE}./`basename $0`:${NC} Missing argument for parameter -repo. aborting ..."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# warn about possible side effects because webmins makedist.pl try cd to /usr/local/webmin (and more)
|
# warn about possible side effects because webmins makedist.pl try cd to /usr/local/webmin (and more)
|
||||||
[[ -d "/usr/local/webadmin" ]] && echo -e "${RED}Warning:${NC} /usr/local/webadmin ${ORANGE}exist, update may fail!${NC}"
|
[[ -d "/usr/local/webadmin" ]] && echo -e "${ORANGE}Warning: Develop dir /usr/local/webadmin exist, update may fail!${NC}"
|
||||||
|
|
||||||
################
|
################
|
||||||
# really update?
|
# really update?
|
||||||
@ -307,7 +299,7 @@ fi
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# something went wrong
|
# something went wrong
|
||||||
echo -e "${RED}${ERROR}Error: updating files, failed.${NC}"
|
echo -e "${RED}${ERROR} Error: updating files, failed.${NC}"
|
||||||
exit 4
|
exit 4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user