91 lines
2.6 KiB
Bash
Executable File
91 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
#######################################################################################
|
|
# First Created: 25012024 Author: Allan Desc: Gitea multi instance postinstall script #
|
|
#######################################################################################
|
|
|
|
#
|
|
# Are we root
|
|
#
|
|
if [[ $(id -u) -ne 0 ]]; then echo "" && echo "Must be root or use sudo" && echo ""; exit 1; fi
|
|
#
|
|
# 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 %s\n\n" "$scriptdir"; exit 1; fi
|
|
#
|
|
# Define variables and functions
|
|
#
|
|
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%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\n\n"; }
|
|
#
|
|
# If Gitea is not running then die
|
|
#
|
|
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"
|
|
#
|
|
# 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
|
|
#
|
|
# Gitea post configuration values
|
|
#
|
|
giteaconfig="
|
|
[ui.admin]
|
|
USER_PAGING_NUM = 50
|
|
REPO_PAGING_NUM = 50
|
|
NOTICE_PAGING_NUM = 25
|
|
ORG_PAGING_NUM = 25
|
|
|
|
[ui.user]
|
|
USER_PAGING_NUM = 50
|
|
REPO_PAGING_NUM = 50
|
|
NOTICE_PAGING_NUM = 25
|
|
ORG_PAGING_NUM = 25
|
|
|
|
[ui]
|
|
THEMES = gitea,arc-green
|
|
|
|
[other]
|
|
SHOW_FOOTER_BRANDING = false
|
|
SHOW_FOOTER_VERSION = false
|
|
SHOW_FOOTER_TEMPLATE_LOAD_TIME = false
|
|
ENABLE_FEED = false
|
|
"
|
|
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"
|
|
#
|
|
# Cleaning up
|
|
#
|
|
rm -Rf giteainfo
|
|
#
|
|
# All done
|
|
#
|
|
clear ; printf "\n" ; line ; printf "All Done...\n" ; line ; printf "\n"
|
|
#
|
|
# End of script
|
|
#
|