1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-25 07:35:22 +00:00

fix linter errors: bash scripts

This commit is contained in:
catborise 2020-10-16 16:56:05 +03:00
parent 25d5df47da
commit b4430eddcc
2 changed files with 45 additions and 45 deletions

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh
# `/sbin/setuser www-data` runs the given command as the user `www-data`. # `/sbin/setuser www-data` runs the given command as the user `www-data`.
cd /srv/webvirtcloud cd /srv/webvirtcloud || exit
exec /sbin/setuser www-data /srv/webvirtcloud/venv/bin/gunicorn webvirtcloud.wsgi:application -c /srv/webvirtcloud/gunicorn.conf.py >> /var/log/webvirtcloud.log 2>&1 exec /sbin/setuser www-data /srv/webvirtcloud/venv/bin/gunicorn webvirtcloud.wsgi:application -c /srv/webvirtcloud/gunicorn.conf.py >> /var/log/webvirtcloud.log 2>&1

View file

@ -5,14 +5,14 @@
# #
# FILE: libvirt-bootstrap.sh # FILE: libvirt-bootstrap.sh
# #
# DESCRIPTION: Bootstrap webvirtmgr installation for various distributions # DESCRIPTION: Bootstrap webvirtcloud installation for various distributions
# #
# BUGS: https://github.com/retspen/webvirtmgr/issues # BUGS: https://github.com/retspen/webvirtcloud/issues
# #
# COPYRIGHT: (c) 2015 by the WebVirtMgr Team # COPYRIGHT: (c) 2015 by the WebVirtCloud Team
# #
# LICENSE: Apache 2.0 # LICENSE: Apache 2.0
# ORGANIZATION: WebVirtMgr (webvirtmgr.net) # ORGANIZATION: WebVirtCloud (webvirtcloud.net)
# CREATED: 11/11/2013 11:00:00 EET # CREATED: 11/11/2013 11:00:00 EET
#=============================================================================== #===============================================================================
@ -21,7 +21,7 @@
# DESCRIPTION: Echo errors to stderr. # DESCRIPTION: Echo errors to stderr.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
echoerror() { echoerror() {
printf "${RC} * ERROR${EC}: $@\n" 1>&2; printf "${RC} * ERROR${EC}: %s\n" "$@" 1>&2;
} }
#--- FUNCTION ---------------------------------------------------------------- #--- FUNCTION ----------------------------------------------------------------
@ -45,7 +45,7 @@ echowarn() {
# DESCRIPTION: Echo debug information to stdout. # DESCRIPTION: Echo debug information to stdout.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
echodebug() { echodebug() {
if [ $_ECHO_DEBUG -eq $BS_TRUE ]; then if [ "$_ECHO_DEBUG" -eq "$BS_TRUE" ]; then
printf "${BC} * DEBUG${EC}: %s\n" "$@"; printf "${BC} * DEBUG${EC}: %s\n" "$@";
fi fi
} }
@ -68,7 +68,7 @@ __test_distro_arch
# DESCRIPTION: Strip duplicate strings # DESCRIPTION: Strip duplicate strings
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
__strip_duplicates() { __strip_duplicates() {
echo $@ | tr -s '[:space:]' '\n' | awk '!x[$0]++' echo $@ | tr -s '[:space:]' '\n' | awk "!x[$0]++"
} }
#--- FUNCTION ---------------------------------------------------------------- #--- FUNCTION ----------------------------------------------------------------
@ -95,14 +95,14 @@ __function_defined() {
__parse_version_string() { __parse_version_string() {
VERSION_STRING="$1" VERSION_STRING="$1"
PARSED_VERSION=$( PARSED_VERSION=$(
echo $VERSION_STRING | echo "$VERSION_STRING" |
sed -e 's/^/#/' \ sed -e 's/^/#/' \
-e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\)\(\.[0-9][0-9]*\).*$/\1/' \ -e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\)\(\.[0-9][0-9]*\).*$/\1/' \
-e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \ -e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \
-e 's/^#[^0-9]*\([0-9][0-9]*\).*$/\1/' \ -e 's/^#[^0-9]*\([0-9][0-9]*\).*$/\1/' \
-e 's/^#.*$//' -e 's/^#.*$//'
) )
echo $PARSED_VERSION echo "$PARSED_VERSION"
} }
#--- FUNCTION ---------------------------------------------------------------- #--- FUNCTION ----------------------------------------------------------------
@ -118,7 +118,7 @@ __sort_release_files() {
secondary_release_files="" secondary_release_files=""
# Sort know VS un-known files first # Sort know VS un-known files first
for release_file in $(echo $@ | sed -r 's:[[:space:]]:\n:g' | sort --unique --ignore-case); do for release_file in $(echo $@ | sed -r 's:[[:space:]]:\n:g' | sort --unique --ignore-case); do
match=$(echo $release_file | egrep -i ${KNOWN_RELEASE_FILES}) match=$(echo "$release_file" | grep -E -i "${KNOWN_RELEASE_FILES}")
if [ "x${match}" != "x" ]; then if [ "x${match}" != "x" ]; then
primary_release_files="${primary_release_files} ${release_file}" primary_release_files="${primary_release_files} ${release_file}"
else else
@ -130,14 +130,14 @@ __sort_release_files() {
max_prio="redhat-release centos-release" max_prio="redhat-release centos-release"
for entry in $max_prio; do for entry in $max_prio; do
if [ "x$(echo ${primary_release_files} | grep $entry)" != "x" ]; then if [ "x$(echo ${primary_release_files} | grep $entry)" != "x" ]; then
primary_release_files=$(echo ${primary_release_files} | sed -e "s:\(.*\)\($entry\)\(.*\):\2 \1 \3:g") primary_release_files=$(echo "${primary_release_files}" | sed -e "s:\(.*\)\($entry\)\(.*\):\2 \1 \3:g")
fi fi
done done
# Now, least important goes last in the min_prio list # Now, least important goes last in the min_prio list
min_prio="lsb-release" min_prio="lsb-release"
for entry in $max_prio; do for entry in $max_prio; do
if [ "x$(echo ${primary_release_files} | grep $entry)" != "x" ]; then if [ "x$(echo ${primary_release_files} | grep $entry)" != "x" ]; then
primary_release_files=$(echo ${primary_release_files} | sed -e "s:\(.*\)\($entry\)\(.*\):\1 \3 \2:g") primary_release_files=$(echo "${primary_release_files}" | sed -e "s:\(.*\)\($entry\)\(.*\):\1 \3 \2:g")
fi fi
done done
@ -192,15 +192,15 @@ __gather_linux_system_info() {
[ -L "/etc/${rsource}" ] && continue # Don't follow symlinks [ -L "/etc/${rsource}" ] && continue # Don't follow symlinks
[ ! -f "/etc/${rsource}" ] && continue # Does not exist [ ! -f "/etc/${rsource}" ] && continue # Does not exist
n=$(echo ${rsource} | sed -e 's/[_-]release$//' -e 's/[_-]version$//') n=$(echo "${rsource}" | sed -e 's/[_-]release$//' -e 's/[_-]version$//')
rv=$( (grep VERSION /etc/${rsource}; cat /etc/${rsource}) | grep '[0-9]' | sed -e 'q' ) rv=$( (grep VERSION /etc/"${rsource}"; cat /etc/"${rsource}") | grep '[0-9]' | sed -e 'q' )
[ "${rv}x" = "x" ] && continue # There's no version information. Continue to next rsource [ "${rv}x" = "x" ] && continue # There's no version information. Continue to next rsource
v=$(__parse_version_string "$rv") v=$(__parse_version_string "$rv")
case $(echo ${n} | tr '[:upper:]' '[:lower:]') in case $(echo "${n}" | tr '[:upper:]' '[:lower:]') in
redhat ) redhat )
if [ ".$(egrep 'CentOS' /etc/${rsource})" != . ]; then if [ ".$(grep -E 'CentOS' /etc/${rsource})" != . ]; then
n="CentOS" n="CentOS"
elif [ ".$(egrep 'Red Hat Enterprise Linux' /etc/${rsource})" != . ]; then elif [ ".$(grep -E 'Red Hat Enterprise Linux' /etc/${rsource})" != . ]; then
n="<R>ed <H>at <E>nterprise <L>inux" n="<R>ed <H>at <E>nterprise <L>inux"
else else
n="<R>ed <H>at <L>inux" n="<R>ed <H>at <L>inux"
@ -220,13 +220,13 @@ __gather_linux_system_info() {
n="Amazon Linux AMI" n="Amazon Linux AMI"
break break
esac esac
done < /etc/${rsource} done < /etc/"${rsource}"
;; ;;
os ) os )
nn=$(grep '^ID=' /etc/os-release | sed -e 's/^ID=\(.*\)$/\1/g') nn=$(grep '^ID=' /etc/os-release | sed -e 's/^ID=\(.*\)$/\1/g')
rv=$(grep '^VERSION_ID=' /etc/os-release | sed -e 's/^VERSION_ID=\(.*\)$/\1/g') rv=$(grep '^VERSION_ID=' /etc/os-release | sed -e 's/^VERSION_ID=\(.*\)$/\1/g')
[ "${rv}x" != "x" ] && v=$(__parse_version_string "$rv") || v="" [ "${rv}x" != "x" ] && v=$(__parse_version_string "$rv") || v=""
case $(echo ${nn} | tr '[:upper:]' '[:lower:]') in case $(echo "${nn}" | tr '[:upper:]' '[:lower:]') in
arch ) arch )
n="Arch Linux" n="Arch Linux"
v="" # Arch Linux does not provide a version. v="" # Arch Linux does not provide a version.
@ -278,7 +278,7 @@ __check_end_of_life_versions() {
case "${DISTRO_NAME_L}" in case "${DISTRO_NAME_L}" in
debian) debian)
# Debian versions bellow 6 are not supported # Debian versions bellow 6 are not supported
if [ $DISTRO_MAJOR_VERSION -lt 6 ]; then if [ "$DISTRO_MAJOR_VERSION" -lt 6 ]; then
echoerror "End of life distributions are not supported." echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:" echoerror "Please consider upgrading to the next stable. See:"
echoerror " https://wiki.debian.org/DebianReleases" echoerror " https://wiki.debian.org/DebianReleases"
@ -293,10 +293,10 @@ __check_end_of_life_versions() {
# = 10.10 # = 10.10
# = 11.04 # = 11.04
# = 11.10 # = 11.10
if ([ $DISTRO_MAJOR_VERSION -eq 10 ] && [ $DISTRO_MINOR_VERSION -eq 10 ]) || \ if ([ "$DISTRO_MAJOR_VERSION" -eq 10 ] && [ "$DISTRO_MINOR_VERSION" -eq 10 ]) || \
([ $DISTRO_MAJOR_VERSION -eq 11 ] && [ $DISTRO_MINOR_VERSION -eq 04 ]) || \ ([ "$DISTRO_MAJOR_VERSION" -eq 11 ] && [ "$DISTRO_MINOR_VERSION" -eq 04 ]) || \
([ $DISTRO_MAJOR_VERSION -eq 11 ] && [ $DISTRO_MINOR_VERSION -eq 10 ]) || \ ([ "$DISTRO_MAJOR_VERSION" -eq 11 ] && [ "$DISTRO_MINOR_VERSION" -eq 10 ]) || \
[ $DISTRO_MAJOR_VERSION -lt 10 ]; then [ "$DISTRO_MAJOR_VERSION" -lt 10 ]; then
echoerror "End of life distributions are not supported." echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:" echoerror "Please consider upgrading to the next stable. See:"
echoerror " https://wiki.ubuntu.com/Releases" echoerror " https://wiki.ubuntu.com/Releases"
@ -308,7 +308,7 @@ __check_end_of_life_versions() {
# openSUSE versions not supported # openSUSE versions not supported
# #
# <= 12.1 # <= 12.1
if ([ $DISTRO_MAJOR_VERSION -eq 12 ] && [ $DISTRO_MINOR_VERSION -eq 1 ]) || [ $DISTRO_MAJOR_VERSION -lt 12 ]; then if ([ "$DISTRO_MAJOR_VERSION" -eq 12 ] && [ "$DISTRO_MINOR_VERSION" -eq 1 ]) || [ "$DISTRO_MAJOR_VERSION" -lt 12 ]; then
echoerror "End of life distributions are not supported." echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:" echoerror "Please consider upgrading to the next stable. See:"
echoerror " http://en.opensuse.org/Lifetime" echoerror " http://en.opensuse.org/Lifetime"
@ -324,7 +324,7 @@ __check_end_of_life_versions() {
if [ "x${SUSE_PATCHLEVEL}" = "x" ]; then if [ "x${SUSE_PATCHLEVEL}" = "x" ]; then
SUSE_PATCHLEVEL="00" SUSE_PATCHLEVEL="00"
fi fi
if ([ $DISTRO_MAJOR_VERSION -eq 11 ] && [ $SUSE_PATCHLEVEL -lt 02 ]) || [ $DISTRO_MAJOR_VERSION -lt 11 ]; then if ([ "$DISTRO_MAJOR_VERSION" -eq 11 ] && [ "$SUSE_PATCHLEVEL" -lt 02 ]) || [ "$DISTRO_MAJOR_VERSION" -lt 11 ]; then
echoerror "Versions lower than SuSE 11 SP2 are not supported." echoerror "Versions lower than SuSE 11 SP2 are not supported."
echoerror "Please consider upgrading to the next stable" echoerror "Please consider upgrading to the next stable"
exit 1 exit 1
@ -333,7 +333,7 @@ __check_end_of_life_versions() {
fedora) fedora)
# Fedora lower than 18 are no longer supported # Fedora lower than 18 are no longer supported
if [ $DISTRO_MAJOR_VERSION -lt 18 ]; then if [ "$DISTRO_MAJOR_VERSION" -lt 18 ]; then
echoerror "End of life distributions are not supported." echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:" echoerror "Please consider upgrading to the next stable. See:"
echoerror " https://fedoraproject.org/wiki/Releases" echoerror " https://fedoraproject.org/wiki/Releases"
@ -343,7 +343,7 @@ __check_end_of_life_versions() {
centos) centos)
# CentOS versions lower than 5 are no longer supported # CentOS versions lower than 5 are no longer supported
if ([ $DISTRO_MAJOR_VERSION -eq 6 ] && [ $DISTRO_MINOR_VERSION -lt 3 ]) || [ $DISTRO_MAJOR_VERSION -lt 5 ]; then if ([ "$DISTRO_MAJOR_VERSION" -eq 6 ] && [ "$DISTRO_MINOR_VERSION" -lt 3 ]) || [ "$DISTRO_MAJOR_VERSION" -lt 5 ]; then
echoerror "End of life distributions are not supported." echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:" echoerror "Please consider upgrading to the next stable. See:"
echoerror " http://wiki.centos.org/Download" echoerror " http://wiki.centos.org/Download"
@ -353,7 +353,7 @@ __check_end_of_life_versions() {
red_hat*linux) red_hat*linux)
# Red Hat (Enterprise) Linux versions lower than 5 are no longer supported # Red Hat (Enterprise) Linux versions lower than 5 are no longer supported
if ([ $DISTRO_MAJOR_VERSION -eq 6 ] && [ $DISTRO_MINOR_VERSION -lt 3 ]) || [ $DISTRO_MAJOR_VERSION -lt 5 ]; then if ([ "$DISTRO_MAJOR_VERSION" -eq 6 ] && [ "$DISTRO_MINOR_VERSION" -lt 3 ]) || [ "$DISTRO_MAJOR_VERSION" -lt 5 ]; then
echoerror "End of life distributions are not supported." echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:" echoerror "Please consider upgrading to the next stable. See:"
echoerror " https://access.redhat.com/support/policy/updates/errata/" echoerror " https://access.redhat.com/support/policy/updates/errata/"
@ -374,7 +374,7 @@ __check_end_of_life_versions
# CentOS Install Functions # CentOS Install Functions
# #
install_centos() { install_centos() {
if [ $DISTRO_MAJOR_VERSION -ge 6 ]; then if [ "$DISTRO_MAJOR_VERSION" -ge 6 ]; then
yum -y install qemu-kvm libvirt bridge-utils python-libguestfs libguestfs-tools supervisor cyrus-sasl-md5 epel-release || return 1 yum -y install qemu-kvm libvirt bridge-utils python-libguestfs libguestfs-tools supervisor cyrus-sasl-md5 epel-release || return 1
fi fi
return 0 return 0
@ -409,7 +409,7 @@ install_centos_post() {
echoerror "/etc/sasl2/libvirt.conf not found. Exiting..." echoerror "/etc/sasl2/libvirt.conf not found. Exiting..."
exit 1 exit 1
fi fi
if [ $DISTRO_MAJOR_VERSION -lt 7 ]; then if [ "$DISTRO_MAJOR_VERSION" -lt 7 ]; then
if [ -f /etc/supervisord.conf ]; then if [ -f /etc/supervisord.conf ]; then
curl https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/daemon/gstfsd > /usr/local/bin/gstfsd curl https://raw.githubusercontent.com/retspen/webvirtcloud/master/conf/daemon/gstfsd > /usr/local/bin/gstfsd
chmod +x /usr/local/bin/gstfsd chmod +x /usr/local/bin/gstfsd
@ -593,7 +593,7 @@ daemons_running_opensuse() {
# #
install_ubuntu() { install_ubuntu() {
apt-get update || return 1 apt-get update || return 1
if [ $DISTRO_MAJOR_VERSION -lt 18 ]; then if [ "$DISTRO_MAJOR_VERSION" -lt 18 ]; then
apt-get -y install kvm libvirt-bin bridge-utils sasl2-bin python-guestfs supervisor || return 1 apt-get -y install kvm libvirt-bin bridge-utils sasl2-bin python-guestfs supervisor || return 1
else else
apt install -y qemu-kvm libvirt-bin bridge-utils virt-manager sasl2-bin python3-guestfs supervisor || return 1 apt install -y qemu-kvm libvirt-bin bridge-utils virt-manager sasl2-bin python3-guestfs supervisor || return 1
@ -663,7 +663,7 @@ daemons_running_ubuntu() {
# #
install_debian() { install_debian() {
apt-get update || return 1 apt-get update || return 1
if [ $DISTRO_MAJOR_VERSION -lt 10 ]; then if [ "$DISTRO_MAJOR_VERSION" -lt 10 ]; then
apt-get -y install qemu-kvm libvirt-bin bridge-utils sasl2-bin python-guestfs supervisor || return 1 apt-get -y install qemu-kvm libvirt-bin bridge-utils sasl2-bin python-guestfs supervisor || return 1
else else
apt-get -y install qemu qemu-kvm qemu-system qemu-utils libvirt-clients libvirt-daemon-system sasl2-bin virtinst supervisor || return 1 apt-get -y install qemu qemu-kvm qemu-system qemu-utils libvirt-clients libvirt-daemon-system sasl2-bin virtinst supervisor || return 1
@ -672,7 +672,7 @@ install_debian() {
} }
install_debian_post() { install_debian_post() {
if [ $DISTRO_MAJOR_VERSION -ge 8 ]; then if [ "$DISTRO_MAJOR_VERSION" -ge 8 ]; then
LIBVIRTSVC=libvirtd LIBVIRTSVC=libvirtd
else else
LIBVIRTSVC=libvirt-bin LIBVIRTSVC=libvirt-bin
@ -723,7 +723,7 @@ install_debian_post() {
} }
daemons_running_debian() { daemons_running_debian() {
if [ $DISTRO_MAJOR_VERSION -ge 8 ]; then if [ "$DISTRO_MAJOR_VERSION" -ge 8 ]; then
LIBVIRTSVC=libvirtd LIBVIRTSVC=libvirtd
else else
LIBVIRTSVC=libvirt-bin LIBVIRTSVC=libvirt-bin
@ -750,15 +750,15 @@ daemons_running_debian() {
INSTALL_FUNC_NAMES="install_${DISTRO_NAME_L}" INSTALL_FUNC_NAMES="install_${DISTRO_NAME_L}"
INSTALL_FUNC="null" INSTALL_FUNC="null"
for FUNC_NAME in $(__strip_duplicates $INSTALL_FUNC_NAMES); do for FUNC_NAME in $(__strip_duplicates "$INSTALL_FUNC_NAMES"); do
if __function_defined $FUNC_NAME; then if __function_defined "$FUNC_NAME"; then
INSTALL_FUNC=$FUNC_NAME INSTALL_FUNC=$FUNC_NAME
break break
fi fi
done done
echodebug "INSTALL_FUNC=${INSTALL_FUNC}" echodebug "INSTALL_FUNC=${INSTALL_FUNC}"
if [ $INSTALL_FUNC = "null" ]; then if [ "$INSTALL_FUNC" = "null" ]; then
echoerror "No installation function found. Exiting..." echoerror "No installation function found. Exiting..."
exit 1 exit 1
else else
@ -774,15 +774,15 @@ fi
POST_FUNC_NAMES="install_${DISTRO_NAME_L}_post" POST_FUNC_NAMES="install_${DISTRO_NAME_L}_post"
POST_INSTALL_FUNC="null" POST_INSTALL_FUNC="null"
for FUNC_NAME in $(__strip_duplicates $POST_FUNC_NAMES); do for FUNC_NAME in $(__strip_duplicates "$POST_FUNC_NAMES"); do
if __function_defined $FUNC_NAME; then if __function_defined "$FUNC_NAME"; then
POST_INSTALL_FUNC=$FUNC_NAME POST_INSTALL_FUNC=$FUNC_NAME
break break
fi fi
done done
echodebug "POST_INSTALL_FUNC=${POST_INSTALL_FUNC}" echodebug "POST_INSTALL_FUNC=${POST_INSTALL_FUNC}"
if [ $POST_INSTALL_FUNC = "null" ]; then if [ "$POST_INSTALL_FUNC" = "null" ]; then
echoerror "No installation function found. Exiting..." echoerror "No installation function found. Exiting..."
exit 1 exit 1
else else
@ -798,15 +798,15 @@ fi
DAEMONS_RUNNING_FUNC_NAMES="daemons_running_${DISTRO_NAME_L}" DAEMONS_RUNNING_FUNC_NAMES="daemons_running_${DISTRO_NAME_L}"
DAEMONS_RUNNING_FUNC="null" DAEMONS_RUNNING_FUNC="null"
for FUNC_NAME in $(__strip_duplicates $DAEMONS_RUNNING_FUNC_NAMES); do for FUNC_NAME in $(__strip_duplicates "$DAEMONS_RUNNING_FUNC_NAMES"); do
if __function_defined $FUNC_NAME; then if __function_defined "$FUNC_NAME"; then
DAEMONS_RUNNING_FUNC=$FUNC_NAME DAEMONS_RUNNING_FUNC=$FUNC_NAME
break break
fi fi
done done
echodebug "DAEMONS_RUNNING_FUNC=${DAEMONS_RUNNING_FUNC}" echodebug "DAEMONS_RUNNING_FUNC=${DAEMONS_RUNNING_FUNC}"
if [ $DAEMONS_RUNNING_FUNC = "null" ]; then if [ "$DAEMONS_RUNNING_FUNC" = "null" ]; then
echoerror "No installation function found. Exiting..." echoerror "No installation function found. Exiting..."
exit 1 exit 1
else else