Fix shellcheck issue #3

This commit is contained in:
joglomedia
2019-07-31 21:55:18 +07:00
parent 680d8f2f1a
commit 162e56899a
6 changed files with 48 additions and 44 deletions

View File

@@ -17,6 +17,7 @@ env:
#script:
# Run the source through ShellCheck (http://www.shellcheck.net).
# - shellcheck -s bash -x scripts/helper.sh
# - shellcheck -s bash scripts/install_*.sh
# - shellcheck -s bash -x lemper.sh
# - shellcheck -s bash -x bin/lemper-cli.sh
# Run the source through ShUnit2
@@ -29,9 +30,9 @@ matrix:
script:
# Run the source through ShellCheck (http://www.shellcheck.net).
- shellcheck -s bash -x scripts/helper.sh
- #shellcheck -s bash scripts/install_*.sh
- shellcheck -s bash -x lemper.sh
- shellcheck -s bash -x bin/lemper-cli.sh
- shellcheck -s bash lib/lemper-create.sh
- shellcheck -s bash lib/lemper-manage.sh
- shellcheck -s bash bin/lemper-cli.sh
- shellcheck -s bash lib/lemper-*.sh
# Run the source through ShUnit2
- bash shunit2/run_test.sh

View File

@@ -35,10 +35,16 @@ if [ -z "${PATH}" ] ; then
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
fi
# Unset existing variables.
# shellcheck source=.env
# shellcheck disable=SC2046
unset $(grep -v '^#' .env | grep -v '^\[' | sed -E 's/(.*)=.*/\1/' | xargs)
# Export environment variables.
if [ -f .env ]; then
# shellcheck source=.env
# shellcheck disable=SC1094
source <(grep -v '^#' .env | grep -v '^\[' | sed -E 's|^(.+)=(.*)$|: ${\1=\2}; export \1|g')
#unset $(grep -v '^#' .env | grep -v '^\[' | sed -E 's/(.*)=.*/\1/' | xargs)
else
echo "Environment variables required, but not found."
exit 1
@@ -58,11 +64,8 @@ if [ "$(id -u)" -ne 0 ]; then
exit 1
fi
# Init log.
run init_log
# Make sure this script only run on supported distribution.
export DISTRIB_REPO \
export DISTRIB_REPO && \
DISTRIB_REPO=$(get_release_name)
if [[ "${DISTRIB_REPO}" == "unsupported" ]]; then
warning "This installer only work on Ubuntu 16.04 & 18.04 and LinuxMint 18 & 19..."
@@ -76,7 +79,7 @@ else
fi
### Main ###
case ${1} in
case "${1}" in
--install)
header_msg
echo ""
@@ -85,6 +88,9 @@ case ${1} in
echo ""
read -t 10 -rp "Press [Enter] to continue..." </dev/tty
# Init log.
run init_log
### Clean-up server ###
if [ -f scripts/cleanup_server.sh ]; then
. scripts/cleanup_server.sh
@@ -193,6 +199,9 @@ Now, you can reboot your server and enjoy it!
echo ""
read -rt 10 -p "Press [Enter] to continue..." </dev/tty
# Init log.
run init_log
# Fix broken install, first?
run apt-get --fix-broken install >> lemper.log 2>&1

View File

@@ -6,18 +6,6 @@
# Author : ESLabs.ID (eslabs.id@gmail.com)
# Since Version : 1.0.0
set -e
unset GREP_OPTIONS LEMPHOMEDIR CURRENTTRAP
# Export environment variables.
if [ -f .env ]; then
source <(grep -v '^#' .env | grep -v '^\[' | sed -E 's|^(.+)=(.*)$|: ${\1=\2}; export \1|g')
#unset $(grep -v '^#' .env | grep -v '^\[' | sed -E 's/(.*)=.*/\1/' | xargs)
else
echo "Environment variables required, but not found."
exit 0
fi
# Make sure only root can run this installer script.
function requires_root() {
if [ "$(/usr/bin/id -u)" -ne 0 ]; then

View File

@@ -9,7 +9,9 @@
# Include helper functions.
if [ "$(type -t run)" != "function" ]; then
BASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )
. ${BASEDIR}/helper.sh
# shellchechk source=scripts/helper.sh
# shellcheck disable=SC1090
. "${BASEDIR}/helper.sh"
fi
# Make sure only root can run this installer script
@@ -32,9 +34,9 @@ run rm -fr ImageMagick-7*
if "${DRYRUN}"; then
status "ImageMagic installed in dryrun mode."
else
if [ -n "$(magick -version |grep -o 'Version: ImageMagic *')" ]; then
if magick -version |grep -qo 'Version: ImageMagic *'; then
status "ImageMagic version $(magick -version |grep ^Version | cut -d' ' -f3) has been installed."
elif [ -n "$(identify -version |grep -o 'Version: ImageMagic *')" ]; then
elif identify -version |grep -qo 'Version: ImageMagic *'; then
status "ImageMagic version $(identify -version |grep ^Version | cut -d' ' -f3) has been installed."
fi
fi

View File

@@ -9,7 +9,8 @@
# Include helper functions.
if [ "$(type -t run)" != "function" ]; then
BASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )
. ${BASEDIR}/helper.sh
# shellchechk source=scripts/helper.sh
. "${BASEDIR}/helper.sh"
fi
# Make sure only root can run this installer script
@@ -23,8 +24,8 @@ echo "Welcome to Certbot Let's Encrypt Installation..."
echo ""
function init_certbotle_install() {
while [[ $INSTALL_CERTBOT != "y" && $INSTALL_CERTBOT != "n" ]]; do
read -p "Do you want to install Certbot Let's Encrypt? [y/n]: " -e INSTALL_CERTBOT
while [[ ${INSTALL_CERTBOT} != "y" && ${INSTALL_CERTBOT} != "n" ]]; do
read -rp "Do you want to install Certbot Let's Encrypt? [y/n]: " -e INSTALL_CERTBOT
done
if [[ "${INSTALL_CERTBOT}" == Y* || "${INSTALL_CERTBOT}" == y* ]]; then
echo -e "\nInstalling Certbot Let's Encrypt client..."

View File

@@ -9,7 +9,8 @@
# Include helper functions.
if [ "$(type -t run)" != "function" ]; then
BASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )
. ${BASEDIR}/helper.sh
# shellchechk source=scripts/helper.sh
. "${BASEDIR}/helper.sh"
fi
# Make sure only root can run this installer script.
@@ -28,7 +29,7 @@ function install_php() {
fi
# Checking if php already installed.
if [[ -n $(command -v php${PHPv}) ]]; then
if [[ -n $(command -v "php${PHPv}") ]]; then
warning "PHP${PHPv} & FPM package already installed..."
else
echo "Installing PHP${PHPv} & FPM..."
@@ -438,22 +439,24 @@ EOL
# Add custom php extension (ex .php70, .php71)
PHPExt=".php${PHPv//.}"
run sed -i "s/;\(security\.limit_extensions\s*=\s*\).*$/\1\.php\ $PHPExt/" /etc/php/${PHPv}/fpm/pool.d/www.conf
run sed -i "s/;\(security\.limit_extensions\s*=\s*\).*$/\1\.php\ $PHPExt/" \
"/etc/php/${PHPv}/fpm/pool.d/www.conf"
# Enable FPM ping service
run sed -i "/^;ping.path\ =.*/a ping.path\ =\ \/ping" /etc/php/${PHPv}/fpm/pool.d/www.conf
run sed -i "/^;ping.path\ =.*/a ping.path\ =\ \/ping" "/etc/php/${PHPv}/fpm/pool.d/www.conf"
# Enable FPM status
run sed -i "/^;pm.status_path\ =.*/a pm.status_path\ =\ \/status" /etc/php/${PHPv}/fpm/pool.d/www.conf
run sed -i "/^;pm.status_path\ =.*/a pm.status_path\ =\ \/status" \
"/etc/php/${PHPv}/fpm/pool.d/www.conf"
# Restart PHP-fpm server
if [[ $(ps -ef | grep -v grep | grep php-fpm | wc -l) > 0 ]]; then
run service php${PHPv}-fpm reload
if [[ $(pgrep -c "php-fpm${PHPv}") -gt 0 ]]; then
run service "php${PHPv}-fpm" reload
status "PHP${PHPv}-FPM restarted successfully."
elif [[ -n $(command -v php${PHPv}) ]]; then
run service php${PHPv}-fpm start
elif [[ -n $(command -v "php${PHPv}") ]]; then
run service "php${PHPv}-fpm" start
if [[ $(ps -ef | grep -v grep | grep php-fpm | wc -l) > 0 ]]; then
if [[ $(pgrep -c "php-fpm${PHPv}") -gt 0 ]]; then
status "PHP${PHPv}-FPM started successfully."
else
warning "Something wrong with PHP installation."
@@ -480,15 +483,15 @@ function init_php_install() {
echo " 6). All available versions"
echo "---------------------------------"
while [[ $SELECTED_PHP != "1" && $SELECTED_PHP != "2" \
&& $SELECTED_PHP != "3" && $SELECTED_PHP != "4" \
&& $SELECTED_PHP != "5" && $SELECTED_PHP != "6" ]]; do
read -p "Select an option [1-6]: " SELECTED_PHP
while [[ ${SELECTED_PHP} != "1" && ${SELECTED_PHP} != "2" \
&& ${SELECTED_PHP} != "3" && ${SELECTED_PHP} != "4" \
&& ${SELECTED_PHP} != "5" && ${SELECTED_PHP} != "6" ]]; do
read -rp "Select an option [1-6]: " -i 5 -e SELECTED_PHP
done
echo ""
case $SELECTED_PHP in
case ${SELECTED_PHP} in
1)
PHP_VER="5.6"
install_php ${PHP_VER}
@@ -529,7 +532,7 @@ function init_php_install() {
# Menu Install PHP loader
echo ""
while [[ ${INSTALL_PHPLOADER} != "y" && ${INSTALL_PHPLOADER} != "n" ]]; do
read -p "Do you want to install PHP Loaders? [y/n]: " -e INSTALL_PHPLOADER
read -rp "Do you want to install PHP Loaders? [y/n]: " -e INSTALL_PHPLOADER
done
if [[ "${INSTALL_PHPLOADER}" == Y* || "${INSTALL_PHPLOADER}" == y* ]]; then
@@ -542,7 +545,7 @@ function init_php_install() {
while [[ ${SELECTED_PHPLOADER} != "1" && ${SELECTED_PHPLOADER} != "2" \
&& ${SELECTED_PHPLOADER} != "3" ]]; do
read -p "Select an option [1-3]: " SELECTED_PHPLOADER
read -rp "Select an option [1-3]: " SELECTED_PHPLOADER
done
echo ""