You've already forked gitea-ubuntu-multi
logic changes
This commit is contained in:
47
giteainstall
47
giteainstall
@@ -16,22 +16,40 @@ if [[ $(id -u) -ne 0 ]]; then printf "\nMust be root or use sudo.\n\n" ; exit 1
|
|||||||
giteaport=3000
|
giteaport=3000
|
||||||
if ss -tuln | grep -q ":${giteaport}\b"; then
|
if ss -tuln | grep -q ":${giteaport}\b"; then
|
||||||
printf "\nPort %s appears to be in use.\n" "$giteaport"
|
printf "\nPort %s appears to be in use.\n" "$giteaport"
|
||||||
listener=$(ss -tulpn 2>/dev/null | awk '/:3000\b/ && /LISTEN/ {print $7}' | sed 's/users:(("//; s/",.*//')
|
listener=$(ss -tulpn 2>/dev/null | awk -v port=":${giteaport}\\b" '$0 ~ port && /LISTEN/ {print $7}' | sed 's/users:(("//; s/",.*//')
|
||||||
if [[ "$listener" == gitea* ]]; then
|
if [[ "$listener" == gitea* ]]; then
|
||||||
printf "Detected a running Gitea-related process: %s\n" "$listener"
|
printf "Detected a running Gitea-related process: %s\n" "$listener"
|
||||||
printf "It looks like another Gitea multi-instance installation has not yet completed.\n"
|
printf "It looks like another Gitea multi-instance installation has not yet completed.\n"
|
||||||
printf "Please finish its web installer and run its postinstall script before continuing.\n\n"
|
printf "Please finish its web installer and run its postinstall script before continuing.\n\n"
|
||||||
elif [[ -n "$listener" ]]; then
|
elif [[ -n "$listener" ]]; then
|
||||||
printf "Process using port 3000 : %s\n" "$listener"
|
printf "Process using port %s : %s\n" "$giteaport" "$listener"
|
||||||
printf "This port is required temporarily by the Gitea web installer.\n"
|
printf "This port is required temporarily by the Gitea web installer.\n"
|
||||||
printf "Please stop or reconfigure that application before running this installer.\n\n"
|
printf "Please stop or reconfigure that application before running this installer.\n\n"
|
||||||
else
|
else
|
||||||
printf "Port 3000 is in use by an unknown process.\n"
|
printf "Port %s is in use by an unknown process.\n" "$giteaport"
|
||||||
printf "Please ensure it is free before running this installer.\n\n"
|
printf "Please ensure it is free before running this installer.\n\n"
|
||||||
fi
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check if required services are running or not
|
||||||
|
#
|
||||||
|
for svc in nginx mariadb; do systemctl is-active --quiet "$svc" || { printf "\n%s is not running, cannot continue...\n\n" "${svc^}" ; exit 1 ; }; done
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check MariaDB authentication method (socket or not)
|
||||||
|
#
|
||||||
|
if mysql -u root -e ";" 2>/dev/null; then
|
||||||
|
socket="SOCKET DETECTED — no need for -a or -m"
|
||||||
|
socketusage="SOCKET DETECTED — this flag is not needed"
|
||||||
|
socketauth="yes"
|
||||||
|
else
|
||||||
|
socket="NO SOCKET DETECTED — you must use -a and -m"
|
||||||
|
socketusage="NO SOCKET DETECTED — these flags are required"
|
||||||
|
socketauth="no"
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Define variables and functions
|
# Define variables and functions
|
||||||
#
|
#
|
||||||
@@ -54,21 +72,18 @@ usage () {
|
|||||||
printf -- " sudo ./giteainstall -n git3.example.com -p gitea3dbpwd -a admin -m adminpwd\n\n"
|
printf -- " sudo ./giteainstall -n git3.example.com -p gitea3dbpwd -a admin -m adminpwd\n\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceno () { printf "\n%s is not running cannot continue...\n\n" "$service"; }
|
#
|
||||||
servicedead () { status=$(systemctl is-active "$service"); if [[ "$status" != "active" ]]; then serviceno ; exit ; fi ; }
|
# Function inputcheck
|
||||||
inputcheck () { [[ -z "$hostname" ]] && { usage ; printf "\nError! Hostname empty.\n\n" ; exit 1 ; } ; [[ -z "$dbpass" ]] && { usage ; printf "\nError! Database password empty.\n\n" ; exit 1 ; } ; }
|
#
|
||||||
|
inputcheck () {
|
||||||
|
[[ -z "$hostname" ]] && { usage; echo "ERROR: DOMAIN CANNOT BE EMPTY!"; exit 1; }
|
||||||
|
[[ "$hostname" =~ [[:space:]/] ]] && { echo "ERROR: DOMAIN INVALID (no spaces or slashes allowed)"; exit 1; }
|
||||||
|
[[ -z "$dbpass" ]] && { usage; echo "ERROR: DATABASE PASSWORD CANNOT BE EMPTY!"; exit 1; }
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# If Nginx and MariaDB are not running then die
|
# Let's go
|
||||||
#
|
#
|
||||||
service="mariadb" ; servicedead ; service="nginx" ; servicedead
|
|
||||||
|
|
||||||
#
|
|
||||||
# Check MariaDB authentication method (socket or not)
|
|
||||||
#
|
|
||||||
if mysql -u root -e ";" 2>/dev/null; then socket="SOCKET DETECTED — no need for -a or -m" ; socketusage="SOCKET DETECTED — these flags are not needed" ; socketauth="yes"
|
|
||||||
else socket="NO SOCKET DETECTED — you must use -a and -m" ; socketusage="NO SOCKET DETECTED — these flags are required" ; socketauth="no" ; fi
|
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -164,7 +179,7 @@ esac
|
|||||||
# Create Gitea temporary Nginx configuration file using port 3000 for web installer
|
# Create Gitea temporary Nginx configuration file using port 3000 for web installer
|
||||||
#
|
#
|
||||||
cp "$nginxsnippets/hostfiles/gitea-multi.80.conf" /etc/nginx/conf.d/"$hostname".conf
|
cp "$nginxsnippets/hostfiles/gitea-multi.80.conf" /etc/nginx/conf.d/"$hostname".conf
|
||||||
sed -i "s/DOMAIN/$hostname/g" /etc/nginx/conf.d/"$hostname".conf
|
sed -i -- "s/DOMAIN/$hostname/g" /etc/nginx/conf.d/"$hostname".conf
|
||||||
sed -i "s/GITEAPORT/3000/g" /etc/nginx/conf.d/"$hostname".conf
|
sed -i "s/GITEAPORT/3000/g" /etc/nginx/conf.d/"$hostname".conf
|
||||||
systemctl restart nginx
|
systemctl restart nginx
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user