change according to shellcheckm add drone.yml
continuous-integration/drone Build is failing Details

This commit is contained in:
Alexander 2023-08-15 11:15:32 +00:00
parent 4cbb477c8d
commit 14dc522141
2 changed files with 18 additions and 9 deletions

9
.drone.yml Normal file
View File

@ -0,0 +1,9 @@
---
kind: pipeline
name: shellcheck
steps:
- name: shellcheck
image: koalaman/shellcheck-alpine:stable
commands:
- shellcheck backup_cosmicvoyage

View File

@ -16,20 +16,20 @@ test -d $SHIPS || (echo "ships does not exit" ; exit 1)
test -d $BACKUP || mkdir $BACKUP
OLDBACKUP=`ls -1 $BACKUP/ships-*.tar.gz 2>/dev/null|tail -1`
OLDBACKUP=$(ls -1 $BACKUP/ships-*.tar.gz 2>/dev/null|tail -1)
cd $SHIPS
cd $SHIPS || exit
TS=`date -u +%Y-%m-%dZ%H%M`
TS=$(date -u +%Y-%m-%dZ%H%M)
TGZ="$BACKUP/ships-$TS.tar.gz"
# if you run the script more than once within 1 minute it gets
# confused
if [ -f $TGZ ]
if [ -f "$TGZ" ]
then
echo backup file $TGZ already exists, not overwriting
echo "backup file $TGZ already exists, not overwriting"
exit 1
fi
@ -38,17 +38,17 @@ echo "backing up $SHIPS/* to $TGZ"
# have to use */* since it would otherwise backup the symlinks and not
# the target, maybe we could use an option in tar otherwise
tar cvfz $TGZ */* */.??*
tar cvfz "$TGZ" ./*/* ./*/.??*
# don't keep backup file if nothing has changed
if [ -f "$OLDBACKUP" ] && cmp -s "$OLDBACKUP" $TGZ
if [ -f "$OLDBACKUP" ] && cmp -s "$OLDBACKUP" "$TGZ"
then
echo "nothing has changed, no new backup"
rm -f $TGZ
rm -f "$TGZ"
else
echo "file is different, keeping new file"
fi
test -f $TGZ && echo backup of file $TGZ was successful
test -f "$TGZ" && echo "backup of file $TGZ was successful"