dehub/cmd/http-server/start.sh
mediocregopher b565d26d1f actually set the default branch to trunk in the http-server, forgot to add the changes >_<
message: actually set the default branch to trunk in the http-server, forgot to add
  the changes >_<
change_hash: AFwqLk4zNKcxco1FPxpg6YwDlubszqfAiua4fJ8MQffU
credentials:
- type: pgp_signature
  pub_key_id: 95C46FA6A41148AC
  body: iQIzBAABAgAdFiEEJ6tQKp6olvZKJ0lwlcRvpqQRSKwFAl5Jqh0ACgkQlcRvpqQRSKz0oQ/9GsiL8sd4qsafzEg0HNT11xCEDqaNpKf/fRwE9F3BfSbiie39qyXWObdvCXfU0EcdH/PSBCPp6vXc6GR6aWvWoZX3FayMfj8mWh0X8ILGxT2f4PM47HdzLaAPpcwhGicaXOuMhcs0TuXPqeJjJVDZwsp7osCe39bnI5qk5gSERI3n3OKOT3G3eXGXHyImN8zcOmD+2zZF9RdcgsMZGiPIKp37z7GMYTjIRi+EGAgyjlJYSy2G+msUZW+4zVBSJZNT7m+2SojDn+gyoxJ9BgWEv0RqH+J5WzagwcDlXQufAztmEkTNNQyEv/V4UrIbO2SkJQ+BpdV6XsZtHVFpsU/qBntEfofzmVq4qsonEcCoC+O5IbGMupayuirSia0hvtKYjIVYKPwAS3fkIjykDrSvfQUZBG1eJNlUaW7vZbDCfx8utFrwQMjnO61+iZPFqye9lNvHcxbchTtYwVgbh57wda/HQRR1w+r1tNh9cvCSUkff0IiJMyl74STYETa3lUo6O+sFlnIQvCpOM3zN7vUrKH7LFL8WY4QZFkoeN1o0yV4gOQUXDcj/q+C+waxPsQTQHLDPiAxMlKP0e+78xAFJfoe2/4SNNGufVA0YD9Q8eLJQ3cHshKPKKTKUlP2Q/4TesFHAjRdefyhPc4xWgF4xLNK1SuXIe/pc1pMg3yHkZjE=
  account: mediocregopher
2020-02-16 13:46:21 -07:00

95 lines
2.1 KiB
Bash

#!/bin/bash
set -e
QUIET=false
#SFLOG="/start.log"
#print timestamp
timestamp() {
date +"%Y-%m-%d %T"
}
#screen/file logger
sflog() {
#if $1 is not null
if [ ! -z ${1+x} ]; then
message=$1
else
#exit function
return 1;
fi
#if $QUIET is not true
if ! $($QUIET); then
echo "${message}"
fi
#if $SFLOG is not null
if [ ! -z ${SFLOG+x} ]; then
#if $2 is regular file or does not exist
if [ -f ${SFLOG} ] || [ ! -e ${SFLOG} ]; then
echo "$(timestamp) ${message}" >> ${SFLOG}
fi
fi
}
#start services function
startc() {
sflog "Services for container are being started..."
/etc/init.d/fcgiwrap start > /dev/null
/etc/init.d/nginx start > /dev/null
sflog "The container services have started..."
}
#stop services function
stopc() {
sflog "Services for container are being stopped..."
/etc/init.d/nginx stop > /dev/null
/etc/init.d/fcgiwrap stop > /dev/null
sflog "Services for container have successfully stopped. Exiting."
exit 0
}
#trap "docker stop <container>" and shuts services down cleanly
trap "(stopc)" TERM INT
#startup
#test for ENV varibale $FQDN
if [ ! -z ${FQDN+x} ]; then
sflog "FQDN is set to ${FQDN}"
else
export FQDN=dehub
sflog "FQDN is set to ${FQDN}"
fi
#modify config files with fqdn
sed -i "s,MYSERVER,${FQDN},g" /etc/nginx/nginx.conf &> /dev/null
# create the individual repo directories
while [ ! -z "$1" ]; do
dir="/repos/$1.git";
if [ ! -d "$dir" ]; then
echo "Initializing repo $1"
mkdir "$dir"
git init --bare "$dir"
git config -f "$dir/config" http.receivepack true
git config -f "$dir/config" receive.denyNonFastForwards true
git symbolic-ref HEAD refs/heads/trunk
chown -R git:git "$dir"
fi
mkdir -p "$dir/hooks"
cp /pre-receive "$dir/hooks/"
chmod +x "$dir/hooks/pre-receive"
shift
done
#start init.d services
startc
#pause script to keep container running...
sflog "Services for container successfully started."
sflog "Dumping logs"
tail -f /var/log/nginx/*.log