Introduce versioning to sequencer and seqs Refactored sequencer option handling More robust way to include sequencer.sh to seqs
123 lines
3.1 KiB
Bash
Executable File
123 lines
3.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
#
|
|
## Installation of self hosted git service Gitea
|
|
|
|
toolName="gitea"
|
|
giteaDownload="https://dl.gitea.io/gitea/1.7.5/gitea-1.7.5-linux-arm-7"
|
|
giteaService="https://raw.githubusercontent.com/go-gitea/gitea/master/contrib/systemd/gitea.service"
|
|
giteaServiceLoc="/etc/systemd/system/gitea.service"
|
|
|
|
step_1_info() { echo "Updating apt"; }
|
|
step_1() {
|
|
apt update
|
|
}
|
|
|
|
step_2_info() { echo "Downloading $toolName to user home: $giteaDownload"; }
|
|
step_2() {
|
|
cd
|
|
wget -O gitea $giteaDownload
|
|
saveReturn $?
|
|
endReturn
|
|
}
|
|
|
|
step_3_info() { echo "Adding user for $toolName (git:git)"; }
|
|
step_3() {
|
|
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() {
|
|
mkdir -p /var/lib/gitea/{custom,data,log}
|
|
chown -R git: /var/lib/gitea/
|
|
chmod -R 750 /var/lib/gitea/
|
|
mkdir /etc/gitea
|
|
chown root:git /etc/gitea
|
|
chmod 770 /etc/gitea
|
|
echo "Copying gitea to global location and making it executable"
|
|
chmod +x ~/gitea
|
|
cp ~/gitea /usr/local/bin/gitea
|
|
saveReturn $?
|
|
endReturn
|
|
}
|
|
|
|
step_5_info() { echo "Creating systemd service"; }
|
|
step_5() {
|
|
wget -O $giteaServiceLoc $giteaService
|
|
echo -en "Uncomment needed services mysql (enter to continue): "
|
|
read
|
|
vi $giteaServiceLoc
|
|
}
|
|
|
|
step_6_info() { echo -e "Starting $toolName service\n"; }
|
|
step_6() {
|
|
systemctl enable gitea
|
|
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_10_info() { echo -e "Create mysql database for $toolName\n"; }
|
|
step_10() {
|
|
local mysqlDatabase
|
|
local mysqlUser
|
|
local mysqlPass
|
|
|
|
echo "Existing mysql databases:"
|
|
mysql -u root -e 'SHOW DATABASES;'
|
|
|
|
echo -en "Enter database name: "
|
|
read mysqlDatabase
|
|
endCheckEmpty mysqlDatabase "database name"
|
|
mysql -u root -e 'CREATE DATABASE '$mysqlDatabase' CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'
|
|
saveReturn $?
|
|
endReturn
|
|
|
|
echo "Existing mysql user:"
|
|
mysql -u root -e 'SELECT User, Host FROM mysql.user;'
|
|
echo -en "Enter mysql user name: "
|
|
read mysqlUser
|
|
endCheckEmpty mysqlDatabase "user name"
|
|
|
|
echo -en "Enter mysql user password: "
|
|
read mysqlPass
|
|
endCheckEmpty mysqlPass "password"
|
|
mysql -u root -e 'CREATE USER '"'"$mysqlUser"'"'@'"'"'localhost'"'"' IDENTIFIED BY '"'"$mysqlPass"'"';'
|
|
saveReturn $?
|
|
endReturn
|
|
|
|
mysql -u root -e 'GRANT ALL PRIVILEGES ON '$mysqlDatabase'.* TO '"'"$mysqlUser"'"'@'"'"'localhost'"'"';'
|
|
saveReturn $?
|
|
endReturn
|
|
|
|
mysql -u root -e 'FLUSH PRIVILEGES;'
|
|
}
|
|
|
|
step_20_info() { echo "Secure settings after installation"; }
|
|
step_20() {
|
|
chmod 750 /etc/gitea
|
|
chmod 644 /etc/gitea/app.ini
|
|
}
|
|
|
|
# Sequence Revision
|
|
VERSION_SEQREV=1
|
|
|
|
# Workaround when called from different directory
|
|
# Not needed when path to sequencer is absolut
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
|
|
# Path to sequencer
|
|
. ${DIR}/../sequencer/sequencer.sh
|