check for existence of curl, requested by Qooob

This commit is contained in:
Gnadelwartz
2018-03-10 15:23:29 +01:00
parent 3e916dd16f
commit e44eaa4bb6
2 changed files with 34 additions and 12 deletions

1
.~files/webadmin Submodule

Submodule .~files/webadmin added at 8dd9b5eedc

View File

@@ -3,7 +3,7 @@
# Update webmin/usermin to the latest develop version from GitHub repo
# inspired by authentic-theme/theme-update.sh script, thanks qooob
#
VERS="1.6.1, 2018-03-09"
VERS="1.6.2, 2018-03-10"
#
COPY=" Kay Marquardt <kay@rrr.de> https://github.com/gnadelwartz"
#############################################################################
@@ -22,7 +22,7 @@ if [[ "$1" == "-nc" ]] ; then
fi
# predefined colors for echo -e on terminal
if [[ -t 1 && "${NCOLOR}" != "YES" || "$1" == "--help" ]] ; then
if [[ -t 1 && "${NCOLOR}" != "YES" ]] ; then
RED='\e[49;0;31;82m'
BLUE='\e[49;1;34;182m'
GREEN='\e[49;32;5;82m'
@@ -48,6 +48,7 @@ fi
HOST="https://github.com"
REPO="webmin/$PROD"
GIT="git"
CURL="curl"
BRANCH=""
# temporary locations for git clone
@@ -186,6 +187,14 @@ else
exit 3
fi
# check if curl is availible
if type ${CURL} >/dev/null 2>&1 ; then
true
else
# flag as not availible, not needed without -repo or -release:latest
CURL=""
fi
################
# lets start
@@ -243,8 +252,11 @@ fi
if [[ "$1" == *"-release"* ]]; then
if [[ "$1" == *":"* ]] && [[ "$1" != *"latest"* ]]; then
RRELEASE=${1##*:}
elif [[ "${CURL}" != "" ]] ; then
RRELEASE=`${CURL} -s -L https://github.com/${REPO}/blob/master/version | sed -n '/id="LC1"/s/.*">\([^<]*\).*/\1/p'`
else
RRELEASE=`curl -s -L https://github.com/${REPO}/blob/master/version | sed -n '/id="LC1"/s/.*">\([^<]*\).*/\1/p'`
echo -e "${RED}Error: Command \`curl\` is not installed or not in the \`PATH\`.${NC} try with -release:1.880"
exit 3
fi
shift
echo -e "${CYAN}Pulling in latest release of${NC} ${ORANGE}${PROD^}${NC} $RRELEASE ($HOST/$REPO)..."
@@ -269,7 +281,11 @@ fi
####################
# start processing pulled source
# add latest changeset date to original version, works with git 1.7+
version="`head -c -1 ${TEMP}/version``cd ${TEMP}; date -d @$(${GIT} log -n1 --format='%at') '+%m%d%H%M'`"
if [[ "${RRELEASE}" == "" ]] ; then
version="`head -c -1 ${TEMP}/version``cd ${TEMP}; date -d @$(${GIT} log -n1 --format='%at') '+%m%d%H%M'`"
else
version="${RRELEASE}"
fi
DOTVER=`echo ${version} | sed 's/-/./'`
TARBALL="${TEMP}/tarballs/${PROD}-${DOTVER}"
###############
@@ -298,7 +314,7 @@ fi
if [[ -f ${TEMP}/${module} && ! -f "${TARBALL}/$module" ]]; then
module=`dirname $module`
echo -e "${CYAN}Adding nonstandard${NC} ${ORANGE}$module${NC} to ${PROD^}"
cp -r -L ${TEMP}/${module} ${TARBALL}/
cp -r -L ${TEMP}/${module} ${TARBALL}/
fi
done
cp "${WTEMP}/chinese-to-utf8.pl" "${TARBALL}/"
@@ -339,8 +355,13 @@ fi
# check if alternatve repo exist
AUTHREPO=`echo ${REPO} | sed "s/\/.*min$/\/autehtic-theme/"`
if [[ "${REPO}" != "${AUTHREPO}" ]]; then
exist=`curl -s -L ${HOST}/${AUTHREPO}`
[[ "${#exist}" -lt 20 ]] && RREPO="${AUTHREPO}"
if [[ "${CURL}" != "" ]] ; then
exist=`${CURL} -s -L ${HOST}/${AUTHREPO}`
[[ "${#exist}" -lt 20 ]] && RREPO="${AUTHREPO}"
else
echo -e "${RED}Warning: Command \`curl\` is not installed or not in the \`PATH\`,${NC} using default repo ..."
WARNINGS="yes"
fi
fi
# run authenric-thme update, possible unattended
if [[ -x authentic-theme/theme-update.sh ]] ; then
@@ -360,7 +381,7 @@ fi
# check for / and ../
if [[ "${file}" == "/"* || "${file}" == *"../"* ]] ; then
echo -e "${RED}Warning: / and ../ are not allowed!${NC} skipping ${file} ..."
ERRORS="yes"
WARNINGS="yes"
continue
fi
if [[ "$file" == *"/" && -d "${TARBALL}/${file}" ]] ; then
@@ -378,12 +399,12 @@ fi
rm -rf "${file}.bak"
else
echo -e "${RED}cp ${file} failed,${NC} restore original!"
ERRORS="yes"
WARNINGS="yes"
fi
FOUND="${FOUND}${file} "
elif [[ ! -d "${TARBALL}/${file}" ]] ; then
echo -e "${RED}Warning: No such file or directory: ${file},${NC} skipping ..."
ERRORS="yes"
WARNINGS="yes"
fi
fi
done
@@ -412,8 +433,8 @@ fi
chmod +x *.pl *.cgi *.pm *.sh */*.pl */*.cgi */*.pm */*.sh
# thats all folks
[[ "${ERRORS}" != "" ]] && ERRORS="(with warnings)"
echo -e "\n${CYAN}Updating ${PROD^} ${ORANGE}${FOUND}${NC} to Version `cat version`, done ${RED}${ERRORS}${NC}"
[[ "${WARNINGS}" != "" ]] && WARNINGS="(with warnings)"
echo -e "\n${CYAN}Updating ${PROD^} ${ORANGE}${FOUND}${NC} to Version `cat version`, done ${RED}${WARNINGS}${NC}"
# update success
exit 0