From 7da80f22f96276f7499932ac6fae74286df39adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Wed, 7 Jul 2021 12:42:13 +0200 Subject: [PATCH] app's scripts: try to use long options --- app/check.discord.update | 4 ++-- app/check.pihole.update | 2 +- app/jenkins_check_update | 4 ++-- app/jenkins_update_plugins | 10 +++++----- app/reprepro.import.sh | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/check.discord.update b/app/check.discord.update index dbc2dd3..d76b447 100755 --- a/app/check.discord.update +++ b/app/check.discord.update @@ -48,11 +48,11 @@ else discord_current_version=$(dpkg --list -- discord | awk '/^ii *discord/ {print $3}' | sed 's/.:\(.*\)-.*/\1/') fi -discord_new_version=$(curl -s 'https://discord.com/api/download?platform=linux&format=deb' --header 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36' | grep " href=\"https" | sed -e 's;.*.deb">.*/apps/linux/\(.*\)/discord.*.deb.*;\1;') +discord_new_version=$(curl --silent 'https://discord.com/api/download?platform=linux&format=deb' --header 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36' | grep " href=\"https" | sed -e 's;.*.deb">.*/apps/linux/\(.*\)/discord.*.deb.*;\1;') discord_new_version_file="/tmp/.discord.upgrade" -discord_new_pkg_url=$(curl -s 'https://discord.com/api/download?platform=linux&format=deb' --header 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36' | grep " href=\"https" | sed -e 's;.*href="\(.*.deb\)">.*;\1;') +discord_new_pkg_url=$(curl --silent 'https://discord.com/api/download?platform=linux&format=deb' --header 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36' | grep " href=\"https" | sed -e 's;.*href="\(.*.deb\)">.*;\1;') discord_new_pkg_path="/tmp/discord-${discord_new_version}.deb" # }}} diff --git a/app/check.pihole.update b/app/check.pihole.update index c5f1e4e..9ecc6dd 100755 --- a/app/check.pihole.update +++ b/app/check.pihole.update @@ -42,7 +42,7 @@ pihole_new_version_file="/tmp/.pihole.upgrade" # }}} # Check the current status with pihole subcommand {{{ -if printf -- '%s' "${pihole_current_status}" | grep -q -- "Everything is up to date"; then +if printf -- '%s' "${pihole_current_status}" | grep --quiet -- "Everything is up to date"; then [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Pi-hole seems up to date." ## Ensure to remove any temp file rm --force -- "${pihole_new_version_file}" diff --git a/app/jenkins_check_update b/app/jenkins_check_update index 96bf878..38c7df4 100755 --- a/app/jenkins_check_update +++ b/app/jenkins_check_update @@ -28,12 +28,12 @@ fi cd "$(dirname ${JENKINS_AUTH_FILE})" || exit # Verify if updates are availables for plugins -if java -jar "${JENKINS_CLI_JAR}" -s http://127.0.0.1:8080 -auth @.jenkins.auth list-plugins | grep -i -q -- "(.*)$" +if java -jar "${JENKINS_CLI_JAR}" -s http://127.0.0.1:8080 -auth @.jenkins.auth list-plugins | grep --ignore-case --quiet -- "(.*)$" then touch "${JENKINS_PLUGIN_UPDATE_LOG}" #printf '%b\n' "Please upgrade plugins" else - rm -f -- "${JENKINS_PLUGIN_UPDATE_LOG}" + rm --force -- "${JENKINS_PLUGIN_UPDATE_LOG}" #printf '%b\n' "Nothing to do" fi cd - > /dev/null || exit diff --git a/app/jenkins_update_plugins b/app/jenkins_update_plugins index 8a9f122..2faba80 100755 --- a/app/jenkins_update_plugins +++ b/app/jenkins_update_plugins @@ -27,22 +27,22 @@ if [ ! -f "${JENKINS_AUTH_FILE}" ]; then fi if [ -f "${JENKINS_PLUGIN_LIST_FILE}" ]; then - rm -f -- "${JENKINS_PLUGIN_LIST_FILE}" + rm --force -- "${JENKINS_PLUGIN_LIST_FILE}" fi # Move to the directory where authentication file is stored cd "$(dirname ${JENKINS_AUTH_FILE})" || exit # Verify if updates are available for plugins -if java -jar "${JENKINS_CLI_JAR}" -s http://127.0.0.1:8080 -auth @.jenkins.auth list-plugins | grep -i -q -- "(.*)$" +if java -jar "${JENKINS_CLI_JAR}" -s http://127.0.0.1:8080 -auth @.jenkins.auth list-plugins | grep --ignore-case --quiet -- "(.*)$" then # Store the list of plugins to upgrade in a file, one by line - java -jar "${JENKINS_CLI_JAR}" -s http://127.0.0.1:8080 -auth @.jenkins.auth list-plugins | grep -i -- "(.*)$" | cut -d" " -f1 > "${JENKINS_PLUGIN_LIST_FILE}" + java -jar "${JENKINS_CLI_JAR}" -s http://127.0.0.1:8080 -auth @.jenkins.auth list-plugins | grep --ignore-case -- "(.*)$" | cut --delimiter=" " --fields=1 > "${JENKINS_PLUGIN_LIST_FILE}" # Upgrade plugins one by one while IFS= read -r plugin; do #printf '%b\n' "Upgrading : ${plugin}" java -jar "${JENKINS_CLI_JAR}" -s http://127.0.0.1:8080 -auth @.jenkins.auth install-plugin "${plugin}" > /dev/null & # Wait for the end of the upgrade - while ps axg | grep -vw grep | grep -w "install-plugin ${plugin}" > /dev/null; do sleep 1; done + while ps axg | grep --invert-match --word-regexp grep | grep --word-regexp "install-plugin ${plugin}" > /dev/null; do sleep 1; done # With pgrep, it still runs 4~5 java commands at the same time #while pgrep -f "install-plugin ${plugin}" > /dev/null; do sleep 1; done done < "${JENKINS_PLUGIN_LIST_FILE}" @@ -55,6 +55,6 @@ cd - > /dev/null || exit # Purge "log" files older than 30 days find "${JENKINS_HOME}/updates" -iname ".plugin_list*" -mtime +30 -delete -rm -f -- "${JENKINS_PLUGIN_UPDATE_LOG}" +rm --force -- "${JENKINS_PLUGIN_UPDATE_LOG}" exit 0 diff --git a/app/reprepro.import.sh b/app/reprepro.import.sh index f05b1fc..652bf0e 100755 --- a/app/reprepro.import.sh +++ b/app/reprepro.import.sh @@ -174,7 +174,7 @@ main() { # {{{ ## }}} ## Get the list of .deb files to manage {{{ - rm -f -- "${packages_list_file}" + rm --force -- "${packages_list_file}" debug_message "main − \ Get the list of .deb files to manage from ${reprepro_dir} directory and store it to ${packages_list_file} file." find "${reprepro_dir}" -maxdepth 1 -type f -iname "*.deb" > "${packages_list_file}" @@ -237,7 +237,7 @@ Regenerate index files for ${release} codename." if [ ! "${NBARGS}" -eq "0" ]; then ## If the first argument is not an option - if ! printf -- '%s' "${1}" | grep -q -E -- "^-+"; + if ! printf -- '%s' "${1}" | grep --quiet --extended-regexp -- "^-+"; then usage error_message "Unknown argument (${1}), check the help." 2 @@ -246,7 +246,7 @@ if [ ! "${NBARGS}" -eq "0" ]; then manage_arg="0" # Parse all options (start with a "-") one by one - while printf -- '%s' "${1}" | grep -q -E -- "^-+"; do + while printf -- '%s' "${1}" | grep --quiet --extended-regexp -- "^-+"; do case "${1}" in -d|--dir|--directory ) ## Set directory