54af1ee510
--- type: change message: |- add init command This ended up being bigger than expected. I decided to make the init command also handle setting up the git config and pre-receive hook for remote-enabled repositories, which took me on a bit of a journey through how go-git handles the filesystem. In the end this greatly simplifies dehub-remote, and will make getting new people set up with a repo much more straightforward. change_hash: AHlWg77eGGr071jVIMJtv+DU3U9x+tcTUsegt4yrk/9W credentials: - type: pgp_signature pub_key_id: 95C46FA6A41148AC body: iQIzBAABAgAdFiEEJ6tQKp6olvZKJ0lwlcRvpqQRSKwFAl6I6oAACgkQlcRvpqQRSKw+dxAAjirfVfIsudnYo3TJxaR1qhQmJJg7v2aMnRQXgYKHEpy8Z1m994WyH3sGJhDQsx3Z/26XjW7fOgXUUKnqZNLp+js182yNo855Ik0vUuEHunAy+YXkBklo3AlkQSJlug9kJrYYjKH4PsJnPZ5JcHXyauxcaydFwHQP61+wiuX/y4iVP/T79ljqbe8GXVj50+rzhu1cRGEgUswnBNSVLYyecU+aEOejfb5CMoCsVtFKunHc+PyHmFJ1XVTwhF/wsCI3pxKYJ/wGqTW6urV46vZhp4SZIJFbSaQkIWuEUXg4JDp8prqgt2IdVlK/wfjxe7YXB9YpzcC4Wblc+m6tiX2lIuEogTyaRK31A2M5/f4m7f7DnPddbZ/fKQ2BBLyLJTtGSQxaFc6LzEmjgMUoUGvkGEPHcaZ1CAOOdcEYn3Y1uwwh4+BJhKPdfpHY4c10+F1Dhi86A4Pi/QmUZ0Cgr9u08wMg1efvD1VTZ6QPX9tpTKi0YqflFdDCDKlLtuA9AvTKBOGGC/XOCmCGjqFpptVRAf+Fl/7DtPG1TUVnKAs1CIw85cMYtEvTptCnMNkwnRFpwiFy856RvpR7RUiQfkWkdohwUY5psFfggOktTgydm5nULWZ4AzZW430MIeJj9XH8FKvYfTN08T9C1kYCwMtC9HYMmXuPdCJNuymQNBAWgaY= account: mediocregopher
87 lines
1.8 KiB
Bash
87 lines
1.8 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";
|
|
if [ ! -d "$dir" ]; then
|
|
echo "Initializing repo $1"
|
|
mkdir "$dir"
|
|
dehub init -path "$dir" -bare -remote
|
|
chown -R git:git "$dir"
|
|
fi
|
|
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
|