86 lines
2.4 KiB
Plaintext
86 lines
2.4 KiB
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
########################################################################
|
||
|
# First Created: 12032021 Author: Allan Desc: Gitea 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-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
|
||
|
|
||
|
#
|
||
|
# Define variables and functions
|
||
|
#
|
||
|
nginxconfig=$(ls -la |grep "conf" |awk '{print $9}')
|
||
|
line (){ for i in {1..50}; do echo -n "$1"; done && printf "\n"; }
|
||
|
#
|
||
|
# Function to check if a service is already running or not
|
||
|
#
|
||
|
serviceno () { printf "\n$service 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"; }
|
||
|
#
|
||
|
# If Gitea is not running then die
|
||
|
#
|
||
|
service="gitea" ; servicedead
|
||
|
#
|
||
|
# Adjusting Gitea configuration parameters
|
||
|
#
|
||
|
cp -Rp /etc/gitea/app.ini /etc/gitea/app.ini.orig
|
||
|
sed -i '/gitea-repositories/a MAX_FILES = 500' /etc/gitea/app.ini
|
||
|
sed -i '/gitea-repositories/a FILE_MAX_SIZE = 200' /etc/gitea/app.ini
|
||
|
sed -i 's/LEVEL = info/LEVEL = warn/' /etc/gitea/app.ini
|
||
|
sed -i 's/MODE = console/MODE = file/' /etc/gitea/app.ini
|
||
|
sed -i 's/DISABLE_SSH = false/DISABLE_SSH = true/' /etc/gitea/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/gitea/app.ini
|
||
|
#
|
||
|
# Adjusting gitea nginx configuration and cleaning up
|
||
|
#
|
||
|
sed -i 's/# Optional //' /etc/nginx/conf.d/$nginxconfig ; rm $nginxconfig
|
||
|
#
|
||
|
# Restart Gitea and Nginx in order for changes to take effect
|
||
|
#
|
||
|
systemctl restart gitea ; systemctl restart nginx
|
||
|
#
|
||
|
# All done
|
||
|
#
|
||
|
clear ; printf "\n" ; line '-' ; printf "All Done...\n" ; line '-' ; printf "\n"
|
||
|
#
|
||
|
# End of script
|
||
|
#
|