Skip to content

Commit

Permalink
Add data migration between versions, and make redis persist.
Browse files Browse the repository at this point in the history
  • Loading branch information
theojulienne committed Feb 9, 2015
1 parent e2219f5 commit 5072778
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 26 additions & 0 deletions template/bin/migrate-snappy-data
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion template/bin/redis-server-wrap
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions template/bin/sphere-client-wrap
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

$(dirname $0)/migrate-snappy-data etc

mkdir -p ${SNAPP_APP_DATA_PATH}/etc/opt/ninja

export DEBUG=t
Expand Down
9 changes: 6 additions & 3 deletions template/meta/mqtt-bridgeify.profile
Original file line number Diff line number Diff line change
Expand Up @@ -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 <abstractions/base>
#include <abstractions/consoles>
#include <abstractions/openssl>
Expand Down Expand Up @@ -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,
}
2 changes: 1 addition & 1 deletion template/meta/package.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: ninjasphere
vendor: Theo Julienne <[email protected]>
architecture: [amd64, armhf]
version: 0.0.5
version: 0.0.6
icon: meta/nina.svg
services:
- name: mosquitto
Expand Down
9 changes: 6 additions & 3 deletions template/meta/sphere-client.profile
Original file line number Diff line number Diff line change
Expand Up @@ -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 <abstractions/base>
#include <abstractions/consoles>
#include <abstractions/openssl>
Expand Down Expand Up @@ -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,
}

0 comments on commit 5072778

Please sign in to comment.