Fix extra space and call migrate on boot

This commit is contained in:
bel
2019-12-07 14:34:42 -07:00
parent 72169206f8
commit 2bb3bee83c
5 changed files with 22 additions and 7 deletions

12
testdata/migrate.sh vendored
View File

@@ -30,7 +30,7 @@ function migrate_tasks() {
local to_addr="$2"
local from_list="$3"
local to_list=$(lookup_list "$from_addr" "$from_list" "$to_addr")
local has_tasks="$(list_tasks "$to_addr" "$to_list" | base64 --decode | jq .title)"
local has_tasks="$(list_tasks "$to_addr" "$to_list" | b64decode | jq .title)"
for task in $(list_tasks "$from_addr" "$from_list"); do
add_task "$to_addr" "$to_list" "$task" "$has_tasks"
done
@@ -70,7 +70,7 @@ function list_tasks() {
function add_task() {
local addr="$1"
local list="$2"
local task="$(echo -n "$3" | base64 --decode | jq "del(.id, .listId)")"
local task="$(echo -n "$3" | b64decode | jq "del(.id, .listId)")"
local has_tasks="$4"
local title="$(echo "$task" | jq -r .title)"
local tags="$(echo "$task" | jq -r .tags)"
@@ -105,6 +105,14 @@ function add_task() {
fi
}
function b64decode() {
if printf "" | base64 --decode 2> /dev/null; then
base64 --decode
else
base64 -d
fi
}
if [ "$0" == "$BASH_SOURCE" ]; then
echo bash migrate.sh 192.168.0.86:44112 localhost:39909
time main "$@"