From 5072778fe89ee846f0b3459268aa44a3274c0778 Mon Sep 17 00:00:00 2001 From: Theo Julienne Date: Sun, 8 Feb 2015 23:48:56 -0800 Subject: [PATCH] Add data migration between versions, and make redis persist. --- Makefile | 2 +- template/bin/migrate-snappy-data | 26 ++++++++++++++++++++++++++ template/bin/redis-server-wrap | 4 +++- template/bin/sphere-client-wrap | 2 ++ template/meta/mqtt-bridgeify.profile | 9 ++++++--- template/meta/package.yaml | 2 +- template/meta/sphere-client.profile | 9 ++++++--- 7 files changed, 45 insertions(+), 9 deletions(-) create mode 100755 template/bin/migrate-snappy-data diff --git a/Makefile b/Makefile index 928af3d..410cc2a 100644 --- a/Makefile +++ b/Makefile @@ -28,4 +28,4 @@ snap: staging snappy build staging-snappy remote: snap - snappy-remote --url=ssh://10.0.1.14 install ./ninjasphere_0.0.5_multi.snap + snappy-remote --url=ssh://10.0.1.14 install ./ninjasphere_0.0.6_multi.snap diff --git a/template/bin/migrate-snappy-data b/template/bin/migrate-snappy-data new file mode 100755 index 0000000..f062d4b --- /dev/null +++ b/template/bin/migrate-snappy-data @@ -0,0 +1,26 @@ +#!/bin/bash + +migrate-data() { + local datapath="$1" + local all_versions="$(dirname ${SNAPP_APP_DATA_PATH})" + local current_version="$(basename ${SNAPP_APP_DATA_PATH})" + local data_base="/var/lib/apps/ninjasphere" + + if [ -e "${SNAPP_APP_DATA_PATH}/${datapath}" ]; then + return 0 + fi + + echo "Migrating data from any available version..." + pushd $data_base + for ver in $(ls -r -1v | grep -v ${current_version}); do + if [ -e "${ver}/${datapath}" ]; then + echo " -> '${ver}'' provides data '${datapath}'" + cp -R ${ver}/${datapath} ${current_version}/${datapath} + return 0 + fi + done + popd +} + +mkdir -p ${SNAPP_APP_DATA_PATH} +migrate-data $1 diff --git a/template/bin/redis-server-wrap b/template/bin/redis-server-wrap index d4bc424..0e3c983 100755 --- a/template/bin/redis-server-wrap +++ b/template/bin/redis-server-wrap @@ -1,4 +1,6 @@ #!/bin/sh +$(dirname $0)/migrate-snappy-data redis + mkdir -p ${SNAPP_APP_DATA_PATH}/redis -${SNAPP_APP_PATH}/bin/redis-server --dir ${SNAPP_APP_DATA_PATH}/redis --pidfile ${SNAPP_APP_DATA_PATH}/redis-server.pid +${SNAPP_APP_PATH}/bin/redis-server --dir ${SNAPP_APP_DATA_PATH}/redis --pidfile ${SNAPP_APP_DATA_PATH}/redis-server.pid --appendonly yes diff --git a/template/bin/sphere-client-wrap b/template/bin/sphere-client-wrap index e351da2..36cdfe1 100755 --- a/template/bin/sphere-client-wrap +++ b/template/bin/sphere-client-wrap @@ -1,5 +1,7 @@ #!/bin/bash +$(dirname $0)/migrate-snappy-data etc + mkdir -p ${SNAPP_APP_DATA_PATH}/etc/opt/ninja export DEBUG=t diff --git a/template/meta/mqtt-bridgeify.profile b/template/meta/mqtt-bridgeify.profile index 5abbfc1..8603cc1 100644 --- a/template/meta/mqtt-bridgeify.profile +++ b/template/meta/mqtt-bridgeify.profile @@ -4,13 +4,13 @@ # Specified profile variables @{APP_APPNAME}="mqtt-bridgeify" -@{APP_ID_DBUS}="ninjasphere_5fmqtt_2dbridgeify_5f0_2e0_2e5" +@{APP_ID_DBUS}="ninjasphere_5fmqtt_2dbridgeify_5f0_2e0_2e6" @{APP_PKGNAME_DBUS}="ninjasphere" @{APP_PKGNAME}="ninjasphere" -@{APP_VERSION}="0.0.5" +@{APP_VERSION}="0.0.6" @{CLICK_DIR}="{/apps,/custom/click,/oem,/usr/share/click/preinstalled}" -profile "ninjasphere_mqtt-bridgeify_0.0.5" { +profile "ninjasphere_mqtt-bridgeify_0.0.6" { #include #include #include @@ -195,4 +195,7 @@ profile "ninjasphere_mqtt-bridgeify_0.0.5" { # Ninja /{,usr/}bin/xxd ixr, + /sys/class/net/[a-z0-9]*/address rk, + /sys/devices/*/*/net/[a-z0-9]*/address rk, + /proc/cmdline rk, } diff --git a/template/meta/package.yaml b/template/meta/package.yaml index 9675c17..36933d8 100644 --- a/template/meta/package.yaml +++ b/template/meta/package.yaml @@ -1,7 +1,7 @@ name: ninjasphere vendor: Theo Julienne architecture: [amd64, armhf] -version: 0.0.5 +version: 0.0.6 icon: meta/nina.svg services: - name: mosquitto diff --git a/template/meta/sphere-client.profile b/template/meta/sphere-client.profile index 9f6f119..4cf20e0 100644 --- a/template/meta/sphere-client.profile +++ b/template/meta/sphere-client.profile @@ -4,13 +4,13 @@ # Specified profile variables @{APP_APPNAME}="sphere-client" -@{APP_ID_DBUS}="ninjasphere_5fsphere_2dclient_5f0_2e0_2e5" +@{APP_ID_DBUS}="ninjasphere_5fsphere_2dclient_5f0_2e0_2e6" @{APP_PKGNAME_DBUS}="ninjasphere" @{APP_PKGNAME}="ninjasphere" -@{APP_VERSION}="0.0.5" +@{APP_VERSION}="0.0.6" @{CLICK_DIR}="{/apps,/custom/click,/oem,/usr/share/click/preinstalled}" -profile "ninjasphere_sphere-client_0.0.5" { +profile "ninjasphere_sphere-client_0.0.6" { #include #include #include @@ -195,4 +195,7 @@ profile "ninjasphere_sphere-client_0.0.5" { # Ninja /{,usr/}bin/xxd ixr, + /sys/class/net/[a-z0-9]*/address rk, + /sys/devices/*/*/net/[a-z0-9]*/address rk, + /proc/cmdline rk, }