#!/bin/bash # ## Installation of self hosted git service Gitea toolName="gitea" giteaLatestUrl="https://api.github.com/repos/go-gitea/gitea/releases/latest" giteaVersion=$(curl --silent "$giteaLatestUrl" | grep -Po '"tag_name": "v\K.*?(?=")') giteaDownload="https://dl.gitea.io/gitea/${giteaVersion}/gitea-${giteaVersion}-linux-arm-6" giteaDir="/usr/local/bin" giteaLoc="${giteaDir}/gitea" giteaService="https://raw.githubusercontent.com/go-gitea/gitea/master/contrib/systemd/gitea.service" giteaServiceLoc="/etc/systemd/system/gitea.service" giteaConfigDir="/etc/gitea" giteaIniLoc="${giteaConfigDir}/app.ini" step_config() { if [ -z $giteaVersion ] ; then echoerr " [E] Couldn't determine latest version of $toolName" fi } step_1_info() { echo "Updating apt"; } step_1_alias() { ALIAS="install"; } step_1() { exe apt update } step_2_info() { echo "Downloading $toolName to user home from:" echoinfo "$giteaDownload" } step_2() { exe wget -O ~/gitea $giteaDownload saveReturn $? endReturn } step_3_info() { echo "Adding user for $toolName (git:git)"; } step_3() { exe adduser \ --system \ --shell /bin/bash \ --gecos 'Git Version Control' \ --group \ --disabled-password \ --home /home/git \ git saveReturn $? endReturn } step_4_info() { echo "Create required directory structure"; } step_4() { exe mkdir -p /var/lib/gitea/{custom,data,log} exe chown -R git: /var/lib/gitea/ exe chmod -R 750 /var/lib/gitea/ exe mkdir /etc/gitea exe chown root:git /etc/gitea exe chmod 770 /etc/gitea echo "Creating /var/log/gitea" exe mkdir -p /var/log/gitea exe chown root:git /var/log/gitea exe chmod 770 /var/log/gitea echo -n "Copying gitea to global location and making it executable..." exe chmod +x ~/gitea exe cp -ar ~/gitea "$giteaLoc" && echo "ok" saveReturn $? endReturn } step_5_info() { echo "Creating systemd service"; } step_5() { exe wget -O "$giteaServiceLoc" "$giteaService" echo -en "Uncomment needed services mysql (enter to continue): " exe read exe vi $giteaServiceLoc } step_6_info() { echo "Starting $toolName service"; } step_6() { exe systemctl enable gitea exe systemctl start gitea echo "Before proceeding to installation you may need to create a database first with step 10" echo echo "Goto http://[yourip]:3000/install and complete installation" echo echo "Afterwards please execute step 20 to secure configuration" } step_7_info() { echo "Show configuration notes"; } step_7_alias() { ALIAS="notes"; } step_7() { outColor green cat <