Bash script to create links to Web UI 1.5.0 repositories

Here’s a bash script to create symlinks to the repositories managed by the Web UI (version 1.5.0). These are handy for running CLI commands. The script uses jq to parse the duplicacy.json file, and the symlinks are created in a repositories directory in the current directory.

#!/usr/bin/env bash
set -e
# Set DUPWEB to the Web UI .duplicacy-web directory, e.g.:
DUPWEB="/usr/bin/Duplicacy/.duplicacy-web"
REPOS="$DUPWEB/repositories/localhost"
mkdir repositories
index=(`jq 'if .computers[].name == "localhost" then .computers[0].repositories[].index else . end' "$DUPWEB/duplicacy.json"`)
id=(`jq -r 'if .computers[].name == "localhost" then .computers[0].repositories[].id else . end' "$DUPWEB/duplicacy.json"`)
for ((i = 0 ; i < ${#index[@]} ; i++)); do
	ln -s "$REPOS/${index[$i]}" repositories/${id[$i]}
done
ln -s "$REPOS/all" "repositories/all"
ln -s "$REPOS/restore" "repositories/restore"		
3 Likes