Jelajahi Sumber

shellcheck: fix warnings (#6274)

* Remove outdated files

* Fix warnings
ᴜɴᴋɴᴡᴏɴ 4 tahun lalu
induk
melakukan
92c5f94fe7

+ 4 - 0
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

+ 1 - 1
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 "$@"

+ 1 - 1
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_*

+ 1 - 0
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
 

+ 2 - 1
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

+ 3 - 3
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

+ 1 - 0
docker/s6/openssh/run

@@ -1,6 +1,7 @@
 #!/bin/sh
 
 if test -f ./setup; then
+    # shellcheck disable=SC2039,SC1091
     source ./setup
 fi
 

+ 1 - 0
docker/s6/syslogd/run

@@ -1,6 +1,7 @@
 #!/bin/sh
 
 if test -f ./setup; then
+    # shellcheck disable=SC2039,SC1091
     source ./setup
 fi
 

+ 10 - 9
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}"

+ 0 - 2
scripts/autoboot.sh

@@ -1,2 +0,0 @@
-#!/bin/sh
-su git -c "/home/git/gogs/scripts/gogs_supervisord.sh restart"

+ 0 - 33
scripts/build.sh

@@ -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/

+ 0 - 27
scripts/build_freebsd.sh

@@ -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/

+ 0 - 27
scripts/build_linux64.sh

@@ -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 - 0
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"