From e65d700a486e8bc26549c91ca795efb08f3047ec Mon Sep 17 00:00:00 2001 From: allan Date: Wed, 28 May 2025 09:28:04 +0200 Subject: [PATCH] minor changes --- giteainstall | 2 +- postinstall | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/giteainstall b/giteainstall index c76d90d..dc416fd 100755 --- a/giteainstall +++ b/giteainstall @@ -91,7 +91,7 @@ inputcheck "$hostname" "$giteapwd" # Check if a Nginx conf file with the hostname allready exists # hostcheck=$(grep -r --exclude="giteainstall" --exclude="postinstall" --exclude="README.md" $hostname /etc/nginx/ *) -if [ ! -z "$hostcheck" ]; then printf "Found a configuration file already containing $hostname in /ect/nginx/* going to abort...\n" ; exit ; fi +if [ ! -z "$hostcheck" ]; then printf "Found a configuration file already containing " ; printf "%s" "$hostname" ; printf " in /ect/nginx/* going to abort...\n" ; exit ; fi # # Download gitea only if gitea does not allready exists in /etc/gitea # diff --git a/postinstall b/postinstall index afe543f..c9425e7 100755 --- a/postinstall +++ b/postinstall @@ -12,23 +12,23 @@ if [[ $(id -u) -ne 0 ]]; then echo "" && echo "Must be root or use sudo" && echo # Are we in the right directory # scriptdir="gitea-multi-install" && whereami=$(pwd |awk -F'/' '{print $NF}') -if [ $whereami != $scriptdir ]; then printf "\nWrong directory! Script must be run from $scriptdir\n\n"; exit 1; fi +if [ "$whereami" != "$scriptdir" ]; then printf "\nWrong directory! Script must be run from %s\n\n" "$scriptdir"; exit 1; fi # # Define variables and functions # -line (){ for i in {1..50}; do echo -n "$1"; done && printf "\n"; } +line () { printf -- '-%.0s' {1..50}; printf '\n'; } giteauser=$(head -1 giteainfo) giteaport=$(head -2 giteainfo |sed '1d') hostname=$(tail -1 giteainfo) # # Function to check if a service is already running or not # -serviceno () { printf "\n$service is not running cannot continue...\n\n"; } +serviceno () { printf "\n%s" $service ; printf " is not running cannot continue...\n\n"; } servicedead () { status=$(systemctl is-active $service); if [[ "$status" != "active" ]]; then serviceno ; exit; fi; } # # Function title # -title () { printf "\nGitea postinstall script V1.0${normal}\n\n"; } +title () { printf "\nGitea postinstall script V1.0\n\n"; } # # If Gitea is not running then die # @@ -36,17 +36,17 @@ service="$giteauser" ; servicedead # # Change the port Gitea is using in the Nginx configuration and minor tweaks # -sed -s -i "s/3000/$giteaport/" /etc/nginx/conf.d/$hostname -sed -i 's/# Optional //' /etc/nginx/conf.d/$hostname +sed -s -i "s/3000/$giteaport/" /etc/nginx/conf.d/"$hostname" +sed -i 's/# Optional //' /etc/nginx/conf.d/"$hostname" # # Adjusting Gitea configuration parameters # -cp -Rp /etc/$giteauser/app.ini /etc/$giteauser/app.ini.orig -sed -s -i "s/HTTP_PORT = 3000/HTTP_PORT = $giteaport/" /etc/$giteauser/app.ini -sed -i '/gitea-repositories/a MAX_FILES = 500' /etc/$giteauser/app.ini -sed -i '/gitea-repositories/a FILE_MAX_SIZE = 200' /etc/$giteauser/app.ini -sed -i 's/LEVEL = info/LEVEL = warn/' /etc/$giteauser/app.ini -sed -i 's/MODE = console/MODE = file/' /etc/$giteauser/app.ini +cp -Rp /etc/"$giteauser"/app.ini /etc/"$giteauser"/app.ini.orig +sed -s -i "s/HTTP_PORT = 3000/HTTP_PORT = $giteaport/" /etc/"$giteauser"/app.ini +sed -i '/gitea-repositories/a MAX_FILES = 500' /etc/"$giteauser"/app.ini +sed -i '/gitea-repositories/a FILE_MAX_SIZE = 200' /etc/"$giteauser"/app.ini +sed -i 's/LEVEL = info/LEVEL = warn/' /etc/"$giteauser"/app.ini +sed -i 's/MODE = console/MODE = file/' /etc/"$giteauser"/app.ini # # Gitea post configuration values # @@ -72,11 +72,11 @@ SHOW_FOOTER_VERSION = false SHOW_FOOTER_TEMPLATE_LOAD_TIME = false ENABLE_FEED = false " -printf '%s\n' "${giteaconfig[@]}" |sed '$d' >> /etc/$giteauser/app.ini +printf '%s\n' "${giteaconfig[@]}" |sed '$d' >> /etc/"$giteauser"/app.ini # # Restart Nginx and Gitea in order for changes to take effect # -systemctl restart nginx ; systemctl restart $giteauser +systemctl restart nginx ; systemctl restart "$giteauser" # # Cleaning up # @@ -84,7 +84,7 @@ rm -Rf giteainfo # # All done # -clear ; printf "\n" ; line '-' ; printf "All Done...\n" ; line '-' ; printf "\n" +clear ; printf "\n" ; line ; printf "All Done...\n" ; line ; printf "\n" # # End of script #