mirror of
https://github.com/Ravinou/borgwarehouse
synced 2024-06-17 13:15:22 +02:00
fix: shellcheck's improvement
This commit is contained in:
parent
8a366d614e
commit
eb9625a542
|
@ -1,5 +1,7 @@
|
||||||
|
# Run test against shells with "pre-commit run shellcheck --all-files"
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
||||||
rev: 3.0.0
|
rev: 3.0.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: shellcheck
|
- id: shellcheck
|
||||||
|
files: helpers/shells/
|
||||||
|
|
|
@ -36,12 +36,12 @@ fi
|
||||||
# Delete the repository and the line associated in the authorized_keys file
|
# Delete the repository and the line associated in the authorized_keys file
|
||||||
if [ -d "${pool}/${repositoryName}" ]; then
|
if [ -d "${pool}/${repositoryName}" ]; then
|
||||||
# Delete the repository
|
# Delete the repository
|
||||||
rm -rf "${pool}/${repositoryName}"
|
rm -rf """${pool}""/""${repositoryName:?}"""
|
||||||
# Delete the line in the authorized_keys file
|
# Delete the line in the authorized_keys file
|
||||||
sed -i "/${repositoryName}/d" "${authorized_keys}"
|
sed -i "/${repositoryName}/d" "${authorized_keys}"
|
||||||
echo -n "The folder "${pool}/${repositoryName}" and all its data have been deleted. The line associated in the authorized_keys file has been deleted."
|
echo -n "The folder ""${pool}"/"${repositoryName}"" and all its data have been deleted. The line associated in the authorized_keys file has been deleted."
|
||||||
else
|
else
|
||||||
# Delete the line in the authorized_keys file
|
# Delete the line in the authorized_keys file
|
||||||
sed -i "/${repositoryName}/d" "${authorized_keys}"
|
sed -i "/${repositoryName}/d" "${authorized_keys}"
|
||||||
echo -n "The folder "${pool}/${repositoryName}" did not exist (repository never initialized or used). The line associated in the authorized_keys file has been deleted."
|
echo -n "The folder ""${pool}"/"${repositoryName}"" did not exist (repository never initialized or used). The line associated in the authorized_keys file has been deleted."
|
||||||
fi
|
fi
|
|
@ -26,9 +26,9 @@ fi
|
||||||
# Default value if .env not exists
|
# Default value if .env not exists
|
||||||
: "${home:=/home/borgwarehouse}"
|
: "${home:=/home/borgwarehouse}"
|
||||||
|
|
||||||
if [ -n "$(find ${home}/repos -mindepth 1 -maxdepth 1 -type d)" ]; then
|
if [ -n "$(find "${home}"/repos -mindepth 1 -maxdepth 1 -type d)" ]; then
|
||||||
stat --format='{"repositoryName":"%n","lastSave":%Y}' \
|
stat --format='{"repositoryName":"%n","lastSave":%Y}' \
|
||||||
${home}/repos/*/integrity* |
|
"${home}"/repos/*/integrity* |
|
||||||
jq --slurp '[.[] | .repositoryName = (.repositoryName | split("/")[-2])]'
|
jq --slurp '[.[] | .repositoryName = (.repositoryName | split("/")[-2])]'
|
||||||
else
|
else
|
||||||
echo "[]"
|
echo "[]"
|
||||||
|
|
|
@ -23,5 +23,5 @@ fi
|
||||||
: "${home:=/home/borgwarehouse}"
|
: "${home:=/home/borgwarehouse}"
|
||||||
|
|
||||||
# Use jc to output a JSON format with du command
|
# Use jc to output a JSON format with du command
|
||||||
cd ${home}/repos
|
cd "${home}"/repos
|
||||||
du -s -- * | jc --du
|
du -s -- * | jc --du
|
||||||
|
|
|
@ -50,7 +50,7 @@ regex="command=\".*${repositoryName}.*\",restrict"
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
if [[ $line =~ $pattern ]]; then
|
if [[ $line =~ $pattern ]]; then
|
||||||
# Get the SSH pub key of the line (ignore the comment)
|
# Get the SSH pub key of the line (ignore the comment)
|
||||||
key1=$(echo ${BASH_REMATCH[0]} | awk '{print $1 " " $2}')
|
key1=$(echo "${BASH_REMATCH[0]}" | awk '{print $1 " " $2}')
|
||||||
# Get the SSH pub key of the new SSH pub key (ignore the comment)
|
# Get the SSH pub key of the new SSH pub key (ignore the comment)
|
||||||
key2=$(echo "$2" | awk '{print $1 " " $2}')
|
key2=$(echo "$2" | awk '{print $1 " " $2}')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue