From 3d8f36b5d2bed00edf5bb4fdf9e8e00ae8d39031 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Thu, 13 Aug 2020 01:35:38 +0800 Subject: [PATCH 1/7] add snap package support. --- snap/local/launcher.sh | 21 ++++++++++++ snap/snapcraft.yaml | 76 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100755 snap/local/launcher.sh create mode 100644 snap/snapcraft.yaml diff --git a/snap/local/launcher.sh b/snap/local/launcher.sh new file mode 100755 index 0000000000..5986114931 --- /dev/null +++ b/snap/local/launcher.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# Wrapper to check for custom config in $SNAP_USER_COMMON or $SNAP_COMMON and +# use it otherwise fall back to the included basic config which will at least +# allow mosquitto to run and do something. +# This script will also copy the full example config in to SNAP_USER_COMMON or +# SNAP_COMMON so that people can refer to it. +# +# The decision about whether to use SNAP_USER_COMMON or SNAP_COMMON is taken +# based on the user that runs the command. If the user is root, it is assumed +# that mosquitto is being run as a system daemon, and SNAP_COMMON will be used. +# If a non-root user runs the command, then SNAP_USER_COMMON will be used. + +case "$SNAP_USER_COMMON" in + */root/snap/tdengine/common*) COMMON=$SNAP_COMMON ;; + *) COMMON=$SNAP_USER_COMMON ;; +esac + +CONFIG_FILE="$SNAP/etc/taos" + +# Launch the snap +$SNAP/usr/bin/taosd -c $CONFIG_FILE $@ diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 0000000000..031704393f --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,76 @@ +name: tdengine +base: core18 # the base snap is the execution environment for this snap +version: '2.0.0.6' # just for humans, typically '1.2+git' or '1.3.2' +summary: Single-line elevator pitch for your amazing snap # 79 char long summary +description: | + TDengine is an open-source big data platform designed and optimized for Internet of Things (IoT), Connected Vehicles, and Industrial IoT. Besides the 10x faster time-series database, it provides caching, stream computing, message queuing and other functionalities to reduce the complexity and costs of development and operations. + +grade: stable +confinement: strict + +apps: + tdengine: + command: launcher.sh + daemon: simple + restart-condition: always + plugs: + - network + - network-bind + - systemfiles + + taos: + command: usr/bin/taos + plugs: + - network + - systemfiles + +plugs: + systemfiles: + interface: system-files + read: + - /etc/taos + - /var/lib/taos + write: + - /var/log/taos + - /var/lib/taos + +parts: + script: + plugin: dump + source: snap/local/ + prime: + - launcher.sh + + tdengine: + source: . + source-type: local + plugin: cmake + build-packages: + - gcc + - g++ + - make + - cmake + override-build: | + snapcraftctl build + if [ ! -d $SNAPCRAFT_STAGE/usr ]; then + mkdir $SNAPCRAFT_STAGE/usr + fi + if [ ! -d $SNAPCRAFT_STAGE/etc/taos ]; then + mkdir -p $SNAPCRAFT_STAGE/etc/taos + fi + cp $SNAPCRAFT_PART_BUILD/build/* -rf $SNAPCRAFT_STAGE/usr/ + cp $SNAPCRAFT_PART_SRC/packaging/cfg/taos.cfg -rf $SNAPCRAFT_STAGE/etc/taos/ + + prime: + - etc/taos/taos.cfg + - usr/bin/taosd + - usr/bin/taos + - usr/bin/taosdemo + - usr/lib/libtaos.so.2.0.0.6 + - usr/lib/libtaos.so.1 + - usr/lib/libtaos.so + + + #layout: + # usr/bin/taosd: + #bind-file: debug/build/bin/taosd From fbce7be9f952a4fcea84dfa38e8265d684f0b16e Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 14 Aug 2020 10:01:36 +0800 Subject: [PATCH 2/7] add /tmp directory for accessing and change confinement to classic. --- snap/snapcraft.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 031704393f..dfa68a9347 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -6,7 +6,7 @@ description: | TDengine is an open-source big data platform designed and optimized for Internet of Things (IoT), Connected Vehicles, and Industrial IoT. Besides the 10x faster time-series database, it provides caching, stream computing, message queuing and other functionalities to reduce the complexity and costs of development and operations. grade: stable -confinement: strict +confinement: classic apps: tdengine: @@ -30,9 +30,11 @@ plugs: read: - /etc/taos - /var/lib/taos + - /tmp write: - /var/log/taos - /var/lib/taos + - /tmp parts: script: From 8a9ebd8a21eb214dba9a3d57212ec6715cdf1c95 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Thu, 13 Aug 2020 01:35:38 +0800 Subject: [PATCH 3/7] add snap package support. --- snap/local/launcher.sh | 21 ++++++++++++ snap/snapcraft.yaml | 76 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100755 snap/local/launcher.sh create mode 100644 snap/snapcraft.yaml diff --git a/snap/local/launcher.sh b/snap/local/launcher.sh new file mode 100755 index 0000000000..5986114931 --- /dev/null +++ b/snap/local/launcher.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# Wrapper to check for custom config in $SNAP_USER_COMMON or $SNAP_COMMON and +# use it otherwise fall back to the included basic config which will at least +# allow mosquitto to run and do something. +# This script will also copy the full example config in to SNAP_USER_COMMON or +# SNAP_COMMON so that people can refer to it. +# +# The decision about whether to use SNAP_USER_COMMON or SNAP_COMMON is taken +# based on the user that runs the command. If the user is root, it is assumed +# that mosquitto is being run as a system daemon, and SNAP_COMMON will be used. +# If a non-root user runs the command, then SNAP_USER_COMMON will be used. + +case "$SNAP_USER_COMMON" in + */root/snap/tdengine/common*) COMMON=$SNAP_COMMON ;; + *) COMMON=$SNAP_USER_COMMON ;; +esac + +CONFIG_FILE="$SNAP/etc/taos" + +# Launch the snap +$SNAP/usr/bin/taosd -c $CONFIG_FILE $@ diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 0000000000..031704393f --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,76 @@ +name: tdengine +base: core18 # the base snap is the execution environment for this snap +version: '2.0.0.6' # just for humans, typically '1.2+git' or '1.3.2' +summary: Single-line elevator pitch for your amazing snap # 79 char long summary +description: | + TDengine is an open-source big data platform designed and optimized for Internet of Things (IoT), Connected Vehicles, and Industrial IoT. Besides the 10x faster time-series database, it provides caching, stream computing, message queuing and other functionalities to reduce the complexity and costs of development and operations. + +grade: stable +confinement: strict + +apps: + tdengine: + command: launcher.sh + daemon: simple + restart-condition: always + plugs: + - network + - network-bind + - systemfiles + + taos: + command: usr/bin/taos + plugs: + - network + - systemfiles + +plugs: + systemfiles: + interface: system-files + read: + - /etc/taos + - /var/lib/taos + write: + - /var/log/taos + - /var/lib/taos + +parts: + script: + plugin: dump + source: snap/local/ + prime: + - launcher.sh + + tdengine: + source: . + source-type: local + plugin: cmake + build-packages: + - gcc + - g++ + - make + - cmake + override-build: | + snapcraftctl build + if [ ! -d $SNAPCRAFT_STAGE/usr ]; then + mkdir $SNAPCRAFT_STAGE/usr + fi + if [ ! -d $SNAPCRAFT_STAGE/etc/taos ]; then + mkdir -p $SNAPCRAFT_STAGE/etc/taos + fi + cp $SNAPCRAFT_PART_BUILD/build/* -rf $SNAPCRAFT_STAGE/usr/ + cp $SNAPCRAFT_PART_SRC/packaging/cfg/taos.cfg -rf $SNAPCRAFT_STAGE/etc/taos/ + + prime: + - etc/taos/taos.cfg + - usr/bin/taosd + - usr/bin/taos + - usr/bin/taosdemo + - usr/lib/libtaos.so.2.0.0.6 + - usr/lib/libtaos.so.1 + - usr/lib/libtaos.so + + + #layout: + # usr/bin/taosd: + #bind-file: debug/build/bin/taosd From f1bd15fa40527ada3ba8eb563fec63ef85608343 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 14 Aug 2020 10:01:36 +0800 Subject: [PATCH 4/7] add /tmp directory for accessing and change confinement to classic. --- snap/snapcraft.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 031704393f..dfa68a9347 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -6,7 +6,7 @@ description: | TDengine is an open-source big data platform designed and optimized for Internet of Things (IoT), Connected Vehicles, and Industrial IoT. Besides the 10x faster time-series database, it provides caching, stream computing, message queuing and other functionalities to reduce the complexity and costs of development and operations. grade: stable -confinement: strict +confinement: classic apps: tdengine: @@ -30,9 +30,11 @@ plugs: read: - /etc/taos - /var/lib/taos + - /tmp write: - /var/log/taos - /var/lib/taos + - /tmp parts: script: From e62bf8fc1ad15ee0bb88e05fb4e85beb01bc9684 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Sat, 15 Aug 2020 16:44:17 +0800 Subject: [PATCH 5/7] add taoswrapper and install hook. now it works. --- snap/hooks/install | 17 +++++++++++++++ snap/local/launcher.sh | 6 +++++- snap/local/taoswrapper.sh | 25 ++++++++++++++++++++++ snap/snapcraft.yaml | 45 +++++++++++++++++++++++++++++++++------ 4 files changed, 86 insertions(+), 7 deletions(-) create mode 100755 snap/hooks/install create mode 100755 snap/local/taoswrapper.sh diff --git a/snap/hooks/install b/snap/hooks/install new file mode 100755 index 0000000000..e58918d2c3 --- /dev/null +++ b/snap/hooks/install @@ -0,0 +1,17 @@ +#!/bin/sh + +if [ ! -d /var/lib/taos ]; then + mkdir -p /var/lib/taos +fi + +if [ ! -d /var/log/taos ]; then + mkdir -p -m777 /var/log/taos +fi + +if [ ! -d /etc/taos ]; then + mkdir -p /etc/taos +fi + +if [ ! -f /etc/taos/taos.cfg ]; then + cp $SNAP/etc/taos/taos.cfg /etc/taos/taos.cfg +fi diff --git a/snap/local/launcher.sh b/snap/local/launcher.sh index 5986114931..52b3e4ce5c 100755 --- a/snap/local/launcher.sh +++ b/snap/local/launcher.sh @@ -15,7 +15,11 @@ case "$SNAP_USER_COMMON" in *) COMMON=$SNAP_USER_COMMON ;; esac -CONFIG_FILE="$SNAP/etc/taos" +if [ -d /etc/taos ]; then + CONFIG_FILE="/etc/taos" +else + CONFIG_FILE="$SNAP/etc/taos" +fi # Launch the snap $SNAP/usr/bin/taosd -c $CONFIG_FILE $@ diff --git a/snap/local/taoswrapper.sh b/snap/local/taoswrapper.sh new file mode 100755 index 0000000000..c7e5c1b856 --- /dev/null +++ b/snap/local/taoswrapper.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# Wrapper to check for custom config in $SNAP_USER_COMMON or $SNAP_COMMON and +# use it otherwise fall back to the included basic config which will at least +# allow mosquitto to run and do something. +# This script will also copy the full example config in to SNAP_USER_COMMON or +# SNAP_COMMON so that people can refer to it. +# +# The decision about whether to use SNAP_USER_COMMON or SNAP_COMMON is taken +# based on the user that runs the command. If the user is root, it is assumed +# that mosquitto is being run as a system daemon, and SNAP_COMMON will be used. +# If a non-root user runs the command, then SNAP_USER_COMMON will be used. + +case "$SNAP_USER_COMMON" in + */root/snap/tdengine/common*) COMMON=$SNAP_COMMON ;; + *) COMMON=$SNAP_USER_COMMON ;; +esac + +if [ -d /etc/taos ]; then + CONFIG_FILE="/etc/taos" +else + CONFIG_FILE="$SNAP/etc/taos" +fi + +# Launch the snap +$SNAP/usr/bin/taos -c $CONFIG_FILE $@ diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index dfa68a9347..b49298e828 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,7 +1,7 @@ name: tdengine base: core18 # the base snap is the execution environment for this snap version: '2.0.0.6' # just for humans, typically '1.2+git' or '1.3.2' -summary: Single-line elevator pitch for your amazing snap # 79 char long summary +summary: an open-source big data platform designed and optimized for IoT. description: | TDengine is an open-source big data platform designed and optimized for Internet of Things (IoT), Connected Vehicles, and Industrial IoT. Besides the 10x faster time-series database, it provides caching, stream computing, message queuing and other functionalities to reduce the complexity and costs of development and operations. @@ -16,19 +16,25 @@ apps: plugs: - network - network-bind + - system-observe - systemfiles taos: - command: usr/bin/taos + command: taoswrapper.sh plugs: - network - systemfiles + taosdemo: + command: usr/bin/taosdemo + plugs: + - network + plugs: systemfiles: interface: system-files read: - - /etc/taos + - /etc - /var/lib/taos - /tmp write: @@ -42,6 +48,7 @@ parts: source: snap/local/ prime: - launcher.sh + - taoswrapper.sh tdengine: source: . @@ -57,12 +64,21 @@ parts: if [ ! -d $SNAPCRAFT_STAGE/usr ]; then mkdir $SNAPCRAFT_STAGE/usr fi + if [ ! -d $SNAPCRAFT_STAGE/etc/taos ]; then mkdir -p $SNAPCRAFT_STAGE/etc/taos fi + cp $SNAPCRAFT_PART_BUILD/build/* -rf $SNAPCRAFT_STAGE/usr/ cp $SNAPCRAFT_PART_SRC/packaging/cfg/taos.cfg -rf $SNAPCRAFT_STAGE/etc/taos/ + if [ ! -d $SNAPCRAFT_STAGE/var/lib/taos ]; then + mkdir -p $SNAPCRAFT_STAGE/var/lib/taos + fi + if [ ! -d $SNAPCRAFT_STAGE/var/log/taos ]; then + mkdir -p $SNAPCRAFT_STAGE/var/log/taos + fi + prime: - etc/taos/taos.cfg - usr/bin/taosd @@ -72,7 +88,24 @@ parts: - usr/lib/libtaos.so.1 - usr/lib/libtaos.so + override-prime: | + snapcraftctl prime + if [ ! -d $SNAPCRAFT_STAGE/var/lib/taos ]; then + cp -rf $SNAPCRAFT_STAGE/var/lib/taos $SNAPCRAFT_PRIME + fi + if [ ! -d $SNAPCRAFT_STAGE/var/log/taos ]; then + cp -rf $SNAPCRAFT_STAGE/var/log/taos $SNAPCRAFT_PRIME + fi - #layout: - # usr/bin/taosd: - #bind-file: debug/build/bin/taosd +layout: + /var/lib/taos: + bind: $SNAP_DATA/var/lib/taos + /var/log/taos: + bind: $SNAP_DATA/var/log/taos + /etc/taos/taos.cfg: + bind-file: $SNAP_DATA/etc/taos/taos.cfg + + +hooks: + install: + plugs: [systemfiles] From af768fb57ee070445972e04180b3e5bf1ca3e93e Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Sat, 15 Aug 2020 16:53:16 +0800 Subject: [PATCH 6/7] add logo. --- snap/local/t-dengine.svg | 1 + snap/snapcraft.yaml | 1 + 2 files changed, 2 insertions(+) create mode 100644 snap/local/t-dengine.svg diff --git a/snap/local/t-dengine.svg b/snap/local/t-dengine.svg new file mode 100644 index 0000000000..e5f29a860b --- /dev/null +++ b/snap/local/t-dengine.svg @@ -0,0 +1 @@ +TDengine logo \ No newline at end of file diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index b49298e828..2c67e5d1a0 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,6 +1,7 @@ name: tdengine base: core18 # the base snap is the execution environment for this snap version: '2.0.0.6' # just for humans, typically '1.2+git' or '1.3.2' +icon: snap/local/t-dengine.svg summary: an open-source big data platform designed and optimized for IoT. description: | TDengine is an open-source big data platform designed and optimized for Internet of Things (IoT), Connected Vehicles, and Industrial IoT. Besides the 10x faster time-series database, it provides caching, stream computing, message queuing and other functionalities to reduce the complexity and costs of development and operations. From 255c0c3ccc8177b80844e0cd43e613bd1dd4f34d Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Mon, 17 Aug 2020 23:16:35 +0800 Subject: [PATCH 7/7] change icon path. --- snap/{local => gui}/t-dengine.svg | 0 snap/snapcraft.yaml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename snap/{local => gui}/t-dengine.svg (100%) diff --git a/snap/local/t-dengine.svg b/snap/gui/t-dengine.svg similarity index 100% rename from snap/local/t-dengine.svg rename to snap/gui/t-dengine.svg diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 8be1511683..cf4f993394 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,7 +1,7 @@ name: tdengine base: core18 # the base snap is the execution environment for this snap version: '2.0.0.6' # just for humans, typically '1.2+git' or '1.3.2' -icon: snap/local/t-dengine.svg +icon: snap/gui/t-dengine.svg summary: an open-source big data platform designed and optimized for IoT. description: | TDengine is an open-source big data platform designed and optimized for Internet of Things (IoT), Connected Vehicles, and Industrial IoT. Besides the 10x faster time-series database, it provides caching, stream computing, message queuing and other functionalities to reduce the complexity and costs of development and operations.