Add Snapcraft metadata and install/maintenance hooks (#666)
* Add Snapcraft metadata and install/maintenance hooks * Move set-environment script into snap/local * snap: Remove diesel-cli part. This *was* necessary as of 0.3.0, but now `plm migrations run` does the job. * snap: Add an actual description * snap: Add an 'enabled' config item. Don't try to run until enabled is set, and automatically run the migrations when we are enabled
This commit is contained in:
committed by
Igor Galić
parent
309e1200d0
commit
b5eecbf2e7
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
|
||||
db_type="$(snapctl get db.type)"
|
||||
db_url="$(snapctl get db.url)"
|
||||
if [ "${db_type}" = "sqlite" ]
|
||||
then
|
||||
if [ -n "${db_url}" ]
|
||||
then
|
||||
echo "sqlite backend does not use db.url key"
|
||||
exit 1
|
||||
fi
|
||||
elif [ "${db_type}" = "postgres" ]
|
||||
then
|
||||
if [ -z "${db_url}" ]
|
||||
then
|
||||
echo "postgres backend requires db.url to be set"
|
||||
exit 1
|
||||
fi
|
||||
elif [ -n "${db_type}" ]
|
||||
then
|
||||
echo "Invalid db.type: " ${db_type}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
base_url="$(snapctl get base-url)"
|
||||
enabled="$(snapctl get enabled)"
|
||||
|
||||
if [ -n ${enabled} -a \( "${enabled}" != "true" -a "${enabled}" != "false" \) ]
|
||||
then
|
||||
echo "Invalid 'enabled' setting: ${enabled}. Valid values are 'true' or 'false'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n ${base_url} -a \( -z "${enabled}" -o "${enabled}" = "false" \) ]
|
||||
then
|
||||
echo "All required configuration available."
|
||||
echo "Plume can now be enabled by setting 'snap set plume enabled=true' and restarting the service \
|
||||
with 'snap restart plume'"
|
||||
fi
|
||||
|
||||
if [ "${enabled}" = "true" -a ! -e ${SNAP_COMMON}/initial-migrations-run ]
|
||||
then
|
||||
cd ${SNAP}
|
||||
exec ./set-environment bin/plm migration run --path ${SNAP_DATA}
|
||||
touch ${SNAP_COMMON}/initial-migrations-run
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
openssl rand -base64 32 > ${SNAP_COMMON}/rocket-secret-key
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
db_type=$(snapctl get db.type)
|
||||
|
||||
if [ -z "${db_type}" ]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cd ${SNAP}
|
||||
exec ./set-environment bin/plm migration run --path ${SNAP_DATA}
|
||||
Reference in New Issue
Block a user