aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorᴜɴᴋɴᴡᴏɴ <u@gogs.io>2020-08-23 15:17:54 +0800
committerGitHub <noreply@github.com>2020-08-23 15:17:54 +0800
commit92c5f94fe7fae17620ecb8895e287e9e66fb135c (patch)
tree71accea059544297cdeddc2bed2b6017729f1609
parenta840ae90352f932d2b77cdbc0c78078b18a469c6 (diff)
shellcheck: fix warnings (#6274)
* Remove outdated files * Fix warnings
-rw-r--r--docker/runtime/backup-init.sh4
-rw-r--r--docker/runtime/backup-rotator.sh2
-rwxr-xr-xdocker/s6/.s6-svscan/finish2
-rwxr-xr-xdocker/s6/crond/run1
-rwxr-xr-xdocker/s6/gogs/run3
-rwxr-xr-xdocker/s6/gogs/setup6
-rwxr-xr-xdocker/s6/openssh/run1
-rwxr-xr-xdocker/s6/syslogd/run1
-rwxr-xr-xdocker/start.sh19
-rwxr-xr-xscripts/autoboot.sh2
-rwxr-xr-xscripts/build.sh33
-rwxr-xr-xscripts/build_freebsd.sh27
-rwxr-xr-xscripts/build_linux64.sh27
-rwxr-xr-xscripts/init/openbsd/gogs1
14 files changed, 25 insertions, 104 deletions
diff --git a/docker/runtime/backup-init.sh b/docker/runtime/backup-init.sh
index 07298c5d..f4e21a1b 100644
--- a/docker/runtime/backup-init.sh
+++ b/docker/runtime/backup-init.sh
@@ -30,7 +30,9 @@ parse_generate_cron_expression() {
CRON_EXPR_DAYS="*"
CRON_EXPR_MONTHS="*"
+ # shellcheck disable=SC2001
TIME_INTERVAL=$(echo "${BACKUP_INTERVAL}" | sed -e 's/[hdM]$//')
+ # shellcheck disable=SC2001
TIME_UNIT=$(echo "${BACKUP_INTERVAL}" | sed -e 's/^[0-9]\+//')
if [ "${TIME_UNIT}" = "h" ]; then
@@ -74,7 +76,9 @@ parse_generate_cron_expression() {
parse_generate_retention_expression() {
FIND_TIME_EXPR='mtime'
+ # shellcheck disable=SC2001
TIME_INTERVAL=$(echo "${BACKUP_RETENTION}" | sed -e 's/[mhdM]$//')
+ # shellcheck disable=SC2001
TIME_UNIT=$(echo "${BACKUP_RETENTION}" | sed -e 's/^[0-9]\+//')
if [ "${TIME_UNIT}" = "m" ]; then
diff --git a/docker/runtime/backup-rotator.sh b/docker/runtime/backup-rotator.sh
index 51665f57..7e882fc0 100644
--- a/docker/runtime/backup-rotator.sh
+++ b/docker/runtime/backup-rotator.sh
@@ -21,7 +21,7 @@ main() {
exit 1
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 "$@"
diff --git a/docker/s6/.s6-svscan/finish b/docker/s6/.s6-svscan/finish
index 3fab7f42..518b5d9b 100755
--- a/docker/s6/.s6-svscan/finish
+++ b/docker/s6/.s6-svscan/finish
@@ -1,5 +1,5 @@
#!/bin/sh
# 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_*
diff --git a/docker/s6/crond/run b/docker/s6/crond/run
index 9aa9fb9f..ada467e1 100755
--- a/docker/s6/crond/run
+++ b/docker/s6/crond/run
@@ -3,6 +3,7 @@
# The default configuration is also calling all the scripts in /etc/periodic/${period}
if test -f ./setup; then
+ # shellcheck disable=SC2039,SC1091
source ./setup
fi
diff --git a/docker/s6/gogs/run b/docker/s6/gogs/run
index edcf49ce..72db3f05 100755
--- a/docker/s6/gogs/run
+++ b/docker/s6/gogs/run
@@ -1,7 +1,8 @@
#!/bin/sh
if test -f ./setup; then
+ # shellcheck disable=SC2039,SC1091
source ./setup
fi
-exec gosu $USER /app/gogs/gogs web
+exec gosu "$USER" /app/gogs/gogs web
diff --git a/docker/s6/gogs/setup b/docker/s6/gogs/setup
index b361495b..bb77aa70 100755
--- a/docker/s6/gogs/setup
+++ b/docker/s6/gogs/setup
@@ -1,16 +1,16 @@
#!/bin/sh
if ! test -d ~git/.ssh; then
- gosu $USER mkdir -p ~git/.ssh
+ gosu "$USER" mkdir -p ~git/.ssh
chmod 700 ~git/.ssh
fi
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
fi
-cd /app/gogs
+cd /app/gogs || exit 1
# Link volumed data with app data
ln -sfn /data/gogs/log ./log
diff --git a/docker/s6/openssh/run b/docker/s6/openssh/run
index 99172aab..d7a538dd 100755
--- a/docker/s6/openssh/run
+++ b/docker/s6/openssh/run
@@ -1,6 +1,7 @@
#!/bin/sh
if test -f ./setup; then
+ # shellcheck disable=SC2039,SC1091
source ./setup
fi
diff --git a/docker/s6/syslogd/run b/docker/s6/syslogd/run
index f7bdbe36..5c3bbefb 100755
--- a/docker/s6/syslogd/run
+++ b/docker/s6/syslogd/run
@@ -1,6 +1,7 @@
#!/bin/sh
if test -f ./setup; then
+ # shellcheck disable=SC2039,SC1091
source ./setup
fi
diff --git a/docker/start.sh b/docker/start.sh
index 77418e18..e10feb20 100755
--- a/docker/start.sh
+++ b/docker/start.sh
@@ -3,17 +3,18 @@
create_socat_links() {
# Bind linked docker container to localhost socket using socat
USED_PORT="3000:22"
- while read NAME ADDR PORT; do
+ while read -r NAME ADDR PORT; do
if test -z "$NAME$ADDR$PORT"; then
continue
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
else
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}"
- echo -e "#!/bin/sh\nexec $CMD" > ${SERV_FOLDER}/run
- chmod +x ${SERV_FOLDER}/run
+ # shellcheck disable=SC2039
+ echo -e "#!/bin/sh\nexec $CMD" > "${SERV_FOLDER}"/run
+ chmod +x "${SERV_FOLDER}"/run
USED_PORT="${USED_PORT}:${PORT}"
echo "init:socat | Linked container ${NAME} will be binded to localhost on port ${PORT}" 1>&2
fi
@@ -25,18 +26,18 @@ EOT
cleanup() {
# Cleanup SOCAT services and s6 event folder
# 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_*
}
create_volume_subfolder() {
# 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
for f in /data/gogs/data /data/gogs/conf /data/gogs/log /data/git /data/ssh; do
if ! test -d $f; then
- gosu $USER mkdir -p $f
+ gosu "$USER" mkdir -p $f
fi
done
}
@@ -54,14 +55,14 @@ cleanup
create_volume_subfolder
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
else
create_socat_links
fi
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
rm -f /app/gogs/docker/s6/crond/down
/bin/sh /app/gogs/docker/runtime/backup-init.sh "${PUID}"
diff --git a/scripts/autoboot.sh b/scripts/autoboot.sh
deleted file mode 100755
index eb16d581..00000000
--- a/scripts/autoboot.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-su git -c "/home/git/gogs/scripts/gogs_supervisord.sh restart"
diff --git a/scripts/build.sh b/scripts/build.sh
deleted file mode 100755
index 53dcdf6a..00000000
--- a/scripts/build.sh
+++ /dev/null
@@ -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/
diff --git a/scripts/build_freebsd.sh b/scripts/build_freebsd.sh
deleted file mode 100755
index 9662f776..00000000
--- a/scripts/build_freebsd.sh
+++ /dev/null
@@ -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/ \ No newline at end of file
diff --git a/scripts/build_linux64.sh b/scripts/build_linux64.sh
deleted file mode 100755
index a4e73936..00000000
--- a/scripts/build_linux64.sh
+++ /dev/null
@@ -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/ \ No newline at end of file
diff --git a/scripts/init/openbsd/gogs b/scripts/init/openbsd/gogs
index 95fcf169..7935d687 100755
--- a/scripts/init/openbsd/gogs
+++ b/scripts/init/openbsd/gogs
@@ -1,6 +1,7 @@
#!/bin/sh
#
# $OpenBSD$
+# shellcheck disable=SC2034,SC1091,SC2154,SC2086
daemon="/home/git/gogs/gogs"
daemon_user="git"