mirror of
https://github.com/Ravinou/borgwarehouse
synced 2024-05-05 07:13:15 +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:
|
||||
- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
||||
rev: 3.0.0
|
||||
hooks:
|
||||
- id: shellcheck
|
||||
- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
||||
rev: 3.0.0
|
||||
hooks:
|
||||
- id: shellcheck
|
||||
files: helpers/shells/
|
||||
|
|
|
@ -36,12 +36,12 @@ fi
|
|||
# Delete the repository and the line associated in the authorized_keys file
|
||||
if [ -d "${pool}/${repositoryName}" ]; then
|
||||
# Delete the repository
|
||||
rm -rf "${pool}/${repositoryName}"
|
||||
rm -rf """${pool}""/""${repositoryName:?}"""
|
||||
# Delete the line in the authorized_keys file
|
||||
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
|
||||
# Delete the line in the authorized_keys file
|
||||
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
|
|
@ -26,9 +26,9 @@ fi
|
|||
# Default value if .env not exists
|
||||
: "${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}' \
|
||||
${home}/repos/*/integrity* |
|
||||
"${home}"/repos/*/integrity* |
|
||||
jq --slurp '[.[] | .repositoryName = (.repositoryName | split("/")[-2])]'
|
||||
else
|
||||
echo "[]"
|
||||
|
|
|
@ -23,5 +23,5 @@ fi
|
|||
: "${home:=/home/borgwarehouse}"
|
||||
|
||||
# Use jc to output a JSON format with du command
|
||||
cd ${home}/repos
|
||||
cd "${home}"/repos
|
||||
du -s -- * | jc --du
|
||||
|
|
|
@ -50,7 +50,7 @@ regex="command=\".*${repositoryName}.*\",restrict"
|
|||
while IFS= read -r line; do
|
||||
if [[ $line =~ $pattern ]]; then
|
||||
# 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)
|
||||
key2=$(echo "$2" | awk '{print $1 " " $2}')
|
||||
|
||||
|
|
Loading…
Reference in a new issue