mirror of https://github.com/gogs/gogs.git
parent
a840ae9035
commit
92c5f94fe7
|
@ -30,7 +30,9 @@ parse_generate_cron_expression() {
|
||||||
CRON_EXPR_DAYS="*"
|
CRON_EXPR_DAYS="*"
|
||||||
CRON_EXPR_MONTHS="*"
|
CRON_EXPR_MONTHS="*"
|
||||||
|
|
||||||
|
# shellcheck disable=SC2001
|
||||||
TIME_INTERVAL=$(echo "${BACKUP_INTERVAL}" | sed -e 's/[hdM]$//')
|
TIME_INTERVAL=$(echo "${BACKUP_INTERVAL}" | sed -e 's/[hdM]$//')
|
||||||
|
# shellcheck disable=SC2001
|
||||||
TIME_UNIT=$(echo "${BACKUP_INTERVAL}" | sed -e 's/^[0-9]\+//')
|
TIME_UNIT=$(echo "${BACKUP_INTERVAL}" | sed -e 's/^[0-9]\+//')
|
||||||
|
|
||||||
if [ "${TIME_UNIT}" = "h" ]; then
|
if [ "${TIME_UNIT}" = "h" ]; then
|
||||||
|
@ -74,7 +76,9 @@ parse_generate_cron_expression() {
|
||||||
parse_generate_retention_expression() {
|
parse_generate_retention_expression() {
|
||||||
FIND_TIME_EXPR='mtime'
|
FIND_TIME_EXPR='mtime'
|
||||||
|
|
||||||
|
# shellcheck disable=SC2001
|
||||||
TIME_INTERVAL=$(echo "${BACKUP_RETENTION}" | sed -e 's/[mhdM]$//')
|
TIME_INTERVAL=$(echo "${BACKUP_RETENTION}" | sed -e 's/[mhdM]$//')
|
||||||
|
# shellcheck disable=SC2001
|
||||||
TIME_UNIT=$(echo "${BACKUP_RETENTION}" | sed -e 's/^[0-9]\+//')
|
TIME_UNIT=$(echo "${BACKUP_RETENTION}" | sed -e 's/^[0-9]\+//')
|
||||||
|
|
||||||
if [ "${TIME_UNIT}" = "m" ]; then
|
if [ "${TIME_UNIT}" = "m" ]; then
|
||||||
|
|
|
@ -21,7 +21,7 @@ main() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
find "${BACKUP_PATH}/" -type f -name "gogs-backup-*.zip" -${FIND_EXPRESSION} -print -exec rm "{}" +
|
find "${BACKUP_PATH}/" -type f -name "gogs-backup-*.zip" "-${FIND_EXPRESSION}" -print -exec rm "{}" +
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Cleanup SOCAT services and s6 event folder
|
# Cleanup SOCAT services and s6 event folder
|
||||||
rm -rf $(find /app/gogs/docker/s6/ -name 'event')
|
rm -rf "$(find /app/gogs/docker/s6/ -name 'event')"
|
||||||
rm -rf /app/gogs/docker/s6/SOCAT_*
|
rm -rf /app/gogs/docker/s6/SOCAT_*
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
# The default configuration is also calling all the scripts in /etc/periodic/${period}
|
# The default configuration is also calling all the scripts in /etc/periodic/${period}
|
||||||
|
|
||||||
if test -f ./setup; then
|
if test -f ./setup; then
|
||||||
|
# shellcheck disable=SC2039,SC1091
|
||||||
source ./setup
|
source ./setup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if test -f ./setup; then
|
if test -f ./setup; then
|
||||||
|
# shellcheck disable=SC2039,SC1091
|
||||||
source ./setup
|
source ./setup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec gosu $USER /app/gogs/gogs web
|
exec gosu "$USER" /app/gogs/gogs web
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if ! test -d ~git/.ssh; then
|
if ! test -d ~git/.ssh; then
|
||||||
gosu $USER mkdir -p ~git/.ssh
|
gosu "$USER" mkdir -p ~git/.ssh
|
||||||
chmod 700 ~git/.ssh
|
chmod 700 ~git/.ssh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! test -f ~git/.ssh/environment; then
|
if ! test -f ~git/.ssh/environment; then
|
||||||
gosu $USER echo "GOGS_CUSTOM=${GOGS_CUSTOM}" > ~git/.ssh/environment
|
gosu "$USER" echo "GOGS_CUSTOM=${GOGS_CUSTOM}" > ~git/.ssh/environment
|
||||||
chmod 600 ~git/.ssh/environment
|
chmod 600 ~git/.ssh/environment
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd /app/gogs
|
cd /app/gogs || exit 1
|
||||||
|
|
||||||
# Link volumed data with app data
|
# Link volumed data with app data
|
||||||
ln -sfn /data/gogs/log ./log
|
ln -sfn /data/gogs/log ./log
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if test -f ./setup; then
|
if test -f ./setup; then
|
||||||
|
# shellcheck disable=SC2039,SC1091
|
||||||
source ./setup
|
source ./setup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if test -f ./setup; then
|
if test -f ./setup; then
|
||||||
|
# shellcheck disable=SC2039,SC1091
|
||||||
source ./setup
|
source ./setup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -3,17 +3,18 @@
|
||||||
create_socat_links() {
|
create_socat_links() {
|
||||||
# Bind linked docker container to localhost socket using socat
|
# Bind linked docker container to localhost socket using socat
|
||||||
USED_PORT="3000:22"
|
USED_PORT="3000:22"
|
||||||
while read NAME ADDR PORT; do
|
while read -r NAME ADDR PORT; do
|
||||||
if test -z "$NAME$ADDR$PORT"; then
|
if test -z "$NAME$ADDR$PORT"; then
|
||||||
continue
|
continue
|
||||||
elif echo $USED_PORT | grep -E "(^|:)$PORT($|:)" > /dev/null; then
|
elif echo $USED_PORT | grep -E "(^|:)$PORT($|:)" > /dev/null; then
|
||||||
echo "init:socat | Can't bind linked container ${NAME} to localhost, port ${PORT} already in use" 1>&2
|
echo "init:socat | Can't bind linked container ${NAME} to localhost, port ${PORT} already in use" 1>&2
|
||||||
else
|
else
|
||||||
SERV_FOLDER=/app/gogs/docker/s6/SOCAT_${NAME}_${PORT}
|
SERV_FOLDER=/app/gogs/docker/s6/SOCAT_${NAME}_${PORT}
|
||||||
mkdir -p ${SERV_FOLDER}
|
mkdir -p "${SERV_FOLDER}"
|
||||||
CMD="socat -ls TCP4-LISTEN:${PORT},fork,reuseaddr TCP4:${ADDR}:${PORT}"
|
CMD="socat -ls TCP4-LISTEN:${PORT},fork,reuseaddr TCP4:${ADDR}:${PORT}"
|
||||||
echo -e "#!/bin/sh\nexec $CMD" > ${SERV_FOLDER}/run
|
# shellcheck disable=SC2039
|
||||||
chmod +x ${SERV_FOLDER}/run
|
echo -e "#!/bin/sh\nexec $CMD" > "${SERV_FOLDER}"/run
|
||||||
|
chmod +x "${SERV_FOLDER}"/run
|
||||||
USED_PORT="${USED_PORT}:${PORT}"
|
USED_PORT="${USED_PORT}:${PORT}"
|
||||||
echo "init:socat | Linked container ${NAME} will be binded to localhost on port ${PORT}" 1>&2
|
echo "init:socat | Linked container ${NAME} will be binded to localhost on port ${PORT}" 1>&2
|
||||||
fi
|
fi
|
||||||
|
@ -25,18 +26,18 @@ EOT
|
||||||
cleanup() {
|
cleanup() {
|
||||||
# Cleanup SOCAT services and s6 event folder
|
# Cleanup SOCAT services and s6 event folder
|
||||||
# On start and on shutdown in case container has been killed
|
# On start and on shutdown in case container has been killed
|
||||||
rm -rf $(find /app/gogs/docker/s6/ -name 'event')
|
rm -rf "$(find /app/gogs/docker/s6/ -name 'event')"
|
||||||
rm -rf /app/gogs/docker/s6/SOCAT_*
|
rm -rf /app/gogs/docker/s6/SOCAT_*
|
||||||
}
|
}
|
||||||
|
|
||||||
create_volume_subfolder() {
|
create_volume_subfolder() {
|
||||||
# Modify the owner of /data dir, make $USER(git) user have permission to create sub-dir in /data.
|
# Modify the owner of /data dir, make $USER(git) user have permission to create sub-dir in /data.
|
||||||
chown -R $USER:$USER /data
|
chown -R "$USER:$USER" /data
|
||||||
|
|
||||||
# Create VOLUME subfolder
|
# Create VOLUME subfolder
|
||||||
for f in /data/gogs/data /data/gogs/conf /data/gogs/log /data/git /data/ssh; do
|
for f in /data/gogs/data /data/gogs/conf /data/gogs/log /data/git /data/ssh; do
|
||||||
if ! test -d $f; then
|
if ! test -d $f; then
|
||||||
gosu $USER mkdir -p $f
|
gosu "$USER" mkdir -p $f
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -54,14 +55,14 @@ cleanup
|
||||||
create_volume_subfolder
|
create_volume_subfolder
|
||||||
|
|
||||||
LINK=$(echo "$SOCAT_LINK" | tr '[:upper:]' '[:lower:]')
|
LINK=$(echo "$SOCAT_LINK" | tr '[:upper:]' '[:lower:]')
|
||||||
if [ "$LINK" = "false" -o "$LINK" = "0" ]; then
|
if [ "$LINK" = "false" ] || [ "$LINK" = "0" ]; then
|
||||||
echo "init:socat | Will not try to create socat links as requested" 1>&2
|
echo "init:socat | Will not try to create socat links as requested" 1>&2
|
||||||
else
|
else
|
||||||
create_socat_links
|
create_socat_links
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CROND=$(echo "$RUN_CROND" | tr '[:upper:]' '[:lower:]')
|
CROND=$(echo "$RUN_CROND" | tr '[:upper:]' '[:lower:]')
|
||||||
if [ "$CROND" = "true" -o "$CROND" = "1" ]; then
|
if [ "$CROND" = "true" ] || [ "$CROND" = "1" ]; then
|
||||||
echo "init:crond | Cron Daemon (crond) will be run as requested by s6" 1>&2
|
echo "init:crond | Cron Daemon (crond) will be run as requested by s6" 1>&2
|
||||||
rm -f /app/gogs/docker/s6/crond/down
|
rm -f /app/gogs/docker/s6/crond/down
|
||||||
/bin/sh /app/gogs/docker/runtime/backup-init.sh "${PUID}"
|
/bin/sh /app/gogs/docker/runtime/backup-init.sh "${PUID}"
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
su git -c "/home/git/gogs/scripts/gogs_supervisord.sh restart"
|
|
|
@ -1,33 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
outPath=./output
|
|
||||||
|
|
||||||
rm -rf $outPath
|
|
||||||
mkdir $outPath
|
|
||||||
|
|
||||||
go build ../gogs.go
|
|
||||||
PLATFORM=$(uname | cut -d _ -f 1)
|
|
||||||
if [ "$PLATFORM" = "MINGW32" ] || [ "$PLATFORM" = "MINGW64" ] || [ "$PLATFORM" = "CYGWIN" ]; then
|
|
||||||
GOGS_EXE=gogs.exe
|
|
||||||
else
|
|
||||||
GOGS_EXE=gogs
|
|
||||||
fi
|
|
||||||
chmod +x $GOGS_EXE
|
|
||||||
mv $GOGS_EXE $outPath/
|
|
||||||
|
|
||||||
cp -r ../conf/ $outPath/conf/
|
|
||||||
cp -r ../custom/ $outPath/custom/
|
|
||||||
cp -r dockerfiles/ $outPath/dockerfiles/
|
|
||||||
cp -r ../public/ $outPath/public/
|
|
||||||
cp -r ../templates/ $outPath/templates/
|
|
||||||
cp ../cert.pem $outPath/
|
|
||||||
cp ../CONTRIBUTING.md $outPath/
|
|
||||||
cp gogs_supervisord.sh $outPath/
|
|
||||||
cp ../key.pem $outPath/
|
|
||||||
cp ../LICENSE $outPath/
|
|
||||||
cp ../README.md $outPath/
|
|
||||||
cp ../README_ZH.md $outPath/
|
|
||||||
cp start.bat $outPath/
|
|
||||||
cp start.sh $outPath/
|
|
||||||
cp ../wercker.yml $outPath/
|
|
||||||
cp mysql.sql $outPath/
|
|
|
@ -1,27 +0,0 @@
|
||||||
outPlattform=freebsd
|
|
||||||
outArch=amd64
|
|
||||||
outPath=./output_${outPlattform}_$outArch
|
|
||||||
|
|
||||||
rm -rf $outPath
|
|
||||||
mkdir $outPath
|
|
||||||
|
|
||||||
CGO_ENABLED=0 GOOS=$outPlattform GOARCH=$outArch go build ../gogs.go
|
|
||||||
chmod +x gogs
|
|
||||||
mv gogs $outPath/
|
|
||||||
|
|
||||||
cp -r ../conf/ $outPath/conf/
|
|
||||||
cp -r ../custom/ $outPath/custom/
|
|
||||||
cp -r dockerfiles/ $outPath/dockerfiles/
|
|
||||||
cp -r ../public/ $outPath/public/
|
|
||||||
cp -r ../templates/ $outPath/templates/
|
|
||||||
cp ../cert.pem $outPath/
|
|
||||||
cp ../CONTRIBUTING.md $outPath/
|
|
||||||
cp gogs_supervisord.sh $outPath/
|
|
||||||
cp ../key.pem $outPath/
|
|
||||||
cp ../LICENSE $outPath/
|
|
||||||
cp ../README.md $outPath/
|
|
||||||
cp ../README_ZH.md $outPath/
|
|
||||||
cp start.bat $outPath/
|
|
||||||
cp start.sh $outPath/
|
|
||||||
cp ../wercker.yml $outPath/
|
|
||||||
cp mysql.sql $outPath/
|
|
|
@ -1,27 +0,0 @@
|
||||||
outPlattform=linux
|
|
||||||
outArch=amd64
|
|
||||||
outPath=./output_${outPlattform}_$outArch
|
|
||||||
|
|
||||||
rm -rf $outPath
|
|
||||||
mkdir $outPath
|
|
||||||
|
|
||||||
CGO_ENABLED=0 GOOS=$outPlattform GOARCH=$outArch go build -buildmode=pie ../gogs.go
|
|
||||||
chmod +x gogs
|
|
||||||
mv gogs $outPath/
|
|
||||||
|
|
||||||
cp -r ../conf/ $outPath/conf/
|
|
||||||
cp -r ../custom/ $outPath/custom/
|
|
||||||
cp -r dockerfiles/ $outPath/dockerfiles/
|
|
||||||
cp -r ../public/ $outPath/public/
|
|
||||||
cp -r ../templates/ $outPath/templates/
|
|
||||||
cp ../cert.pem $outPath/
|
|
||||||
cp ../CONTRIBUTING.md $outPath/
|
|
||||||
cp gogs_supervisord.sh $outPath/
|
|
||||||
cp ../key.pem $outPath/
|
|
||||||
cp ../LICENSE $outPath/
|
|
||||||
cp ../README.md $outPath/
|
|
||||||
cp ../README_ZH.md $outPath/
|
|
||||||
cp start.bat $outPath/
|
|
||||||
cp start.sh $outPath/
|
|
||||||
cp ../wercker.yml $outPath/
|
|
||||||
cp mysql.sql $outPath/
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# $OpenBSD$
|
# $OpenBSD$
|
||||||
|
# shellcheck disable=SC2034,SC1091,SC2154,SC2086
|
||||||
|
|
||||||
daemon="/home/git/gogs/gogs"
|
daemon="/home/git/gogs/gogs"
|
||||||
daemon_user="git"
|
daemon_user="git"
|
||||||
|
|
Loading…
Reference in New Issue