From 180fd6bb16896ce8c76f1f8ebdb299a584abbce9 Mon Sep 17 00:00:00 2001 From: Aleksander Mistewicz Date: Wed, 24 May 2017 11:18:58 +0200 Subject: Move watchers to separate directory Current split is: - watchers: programs executed by cron - jobs: programs executed by queue - scripts: programs executed by jobs Change-Id: I522684417cd94729a76cf38c22d318c91f63ae2f --- tsp/cronfile.example | 10 +++++----- tsp/jobs/watch_diskspace.sh | 32 -------------------------------- tsp/jobs/watch_sdb.sh | 35 ----------------------------------- tsp/jobs/watch_symlinks.sh | 40 ---------------------------------------- tsp/jobs/watch_usb.sh | 28 ---------------------------- tsp/jobs/watcher.sh | 29 ----------------------------- tsp/watchers/watch_diskspace.sh | 32 ++++++++++++++++++++++++++++++++ tsp/watchers/watch_sdb.sh | 35 +++++++++++++++++++++++++++++++++++ tsp/watchers/watch_symlinks.sh | 40 ++++++++++++++++++++++++++++++++++++++++ tsp/watchers/watch_usb.sh | 28 ++++++++++++++++++++++++++++ tsp/watchers/watcher.sh | 29 +++++++++++++++++++++++++++++ 11 files changed, 169 insertions(+), 169 deletions(-) delete mode 100755 tsp/jobs/watch_diskspace.sh delete mode 100755 tsp/jobs/watch_sdb.sh delete mode 100755 tsp/jobs/watch_symlinks.sh delete mode 100755 tsp/jobs/watch_usb.sh delete mode 100755 tsp/jobs/watcher.sh create mode 100755 tsp/watchers/watch_diskspace.sh create mode 100755 tsp/watchers/watch_sdb.sh create mode 100755 tsp/watchers/watch_symlinks.sh create mode 100755 tsp/watchers/watch_usb.sh create mode 100755 tsp/watchers/watcher.sh (limited to 'tsp') diff --git a/tsp/cronfile.example b/tsp/cronfile.example index 543e658..c32d775 100644 --- a/tsp/cronfile.example +++ b/tsp/cronfile.example @@ -1,5 +1,5 @@ -*/10 * * * * /opt/testlab-major/tsp/jobs/watcher.sh -0 */4 * * * /opt/testlab-major/tsp/jobs/watch_diskspace.sh -0 * * * * /opt/testlab-major/tsp/jobs/watch_sdb.sh -*/10 * * * * /opt/testlab-major/tsp/jobs/watch_usb.sh -0 */8 * * * /opt/testlab-major/tsp/jobs/watch_symlinks.sh +*/10 * * * * /opt/testlab-major/tsp/watchers/watcher.sh +0 */4 * * * /opt/testlab-major/tsp/watchers/watch_diskspace.sh +0 * * * * /opt/testlab-major/tsp/watchers/watch_sdb.sh +*/10 * * * * /opt/testlab-major/tsp/watchers/watch_usb.sh +0 */8 * * * /opt/testlab-major/tsp/watchers/watch_symlinks.sh diff --git a/tsp/jobs/watch_diskspace.sh b/tsp/jobs/watch_diskspace.sh deleted file mode 100755 index 9fd2e54..0000000 --- a/tsp/jobs/watch_diskspace.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Author: Aleksander Mistewicz - -export TSP_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)/.." - -. "${TSP_DIR}/common.sh" - -# Get diskspace usage for filesystem storing workspaces. -PER="$(df -P "${WS_DOWNLOAD}" | grep -o "[0-9]\+%.*$")" -# Leave only numerical value. -PER="${PER%\%*}" -if [ "$PER" -ge 30 ] -then - nr="$(tsmaster -L DISK_CLEANUP sh "${TSP_DIR}/jobs/free_diskspace.sh")" - # make the above job urgent - tsmaster -u "$nr" -fi diff --git a/tsp/jobs/watch_sdb.sh b/tsp/jobs/watch_sdb.sh deleted file mode 100755 index 4546f9a..0000000 --- a/tsp/jobs/watch_sdb.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Author: Aleksander Mistewicz - -export TSP_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)/.." - -. "${TSP_DIR}/common.sh" - -# make sure the server is running -timeout 120 sdb start-server - -# check if it works -SDB="$(timeout 120 sdb devices)" -SDB_RET="$?" - -if [ "${SDB_RET}" -ne 0 ]; then - killall sdb - sdb start-server -fi - -post_prom "sdb_status" "$SDB_RET" "Return value of sdb devices" diff --git a/tsp/jobs/watch_symlinks.sh b/tsp/jobs/watch_symlinks.sh deleted file mode 100755 index 7d722c9..0000000 --- a/tsp/jobs/watch_symlinks.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Author: Aleksander Mistewicz - -UUID_DIR="/dev/disk/by-uuid" - -for SYMLINK in $(find "${UUID_DIR}" -type l) -do - echo "symlink: ${SYMLINK}" - DEST="$(readlink "${SYMLINK}")" - test -n "${DEST}" || { - echo "dest: empty" - continue - } - DEST="${UUID_DIR}/${DEST}" - echo "dest: ${DEST}" - test -f "${DEST}" && { - echo "dest is a file" - sudo rm -v "${DEST}" - } - test -b "${DEST}" && { - echo "dest is a block device" - continue - } - sudo rm -v "${SYMLINK}" -done diff --git a/tsp/jobs/watch_usb.sh b/tsp/jobs/watch_usb.sh deleted file mode 100755 index 99282a4..0000000 --- a/tsp/jobs/watch_usb.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Author: Aleksander Mistewicz -export TSP_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)/.." - -. "${TSP_DIR}/common.sh" - -timeout 120 lsusb -USB_RET="$?" -post_prom "usb_status" "$USB_RET" "Return value of lsusb" - -timeout 120 /usr/local/bin/sd-mux-ctrl -l -SDMUX_RET="$?" -post_prom "sdmux_status" "$SDMUX_RET" "Return value of sd-mux-ctrl -l" diff --git a/tsp/jobs/watcher.sh b/tsp/jobs/watcher.sh deleted file mode 100755 index d5869ef..0000000 --- a/tsp/jobs/watcher.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Author: Aleksander Mistewicz - -export TSP_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)/.." - -. "${TSP_DIR}/common.sh" - -# Dispatch tsp/jobs/trigger_downloads.sh for common snapshot and prerelease urls -tspoll -L 4_SNAPSHOT sh "${TSP_DIR}/jobs/trigger_downloads.sh" "http://download.tizen.org/snapshots/tizen/common/" tizen_4.0_snapshot -tspoll -L 4_PRERELEASE sh "${TSP_DIR}/jobs/trigger_downloads.sh" "http://download.tizen.org/prerelease/tizen/common/" tizen_4.0_prerelease -tspoll -L 3_SNAPSHOT sh "${TSP_DIR}/jobs/trigger_downloads.sh" "http://download.tizen.org/snapshots/tizen/3.0-common/" tizen_3.0_snapshot -tspoll -L 3_PRERELEASE sh "${TSP_DIR}/jobs/trigger_downloads.sh" "http://download.tizen.org/prerelease/tizen/3.0-common/" tizen_3.0_prerelease -tspoll -L UNI_SNAPSHOT sh "${TSP_DIR}/jobs/trigger_downloads.sh" "http://download.tizen.org/snapshots/tizen/unified/" tizen_uni_snapshot -tspoll -L UNI_PRERELEASE sh "${TSP_DIR}/jobs/trigger_downloads.sh" "http://download.tizen.org/prerelease/tizen/unified/" tizen_uni_prerelease diff --git a/tsp/watchers/watch_diskspace.sh b/tsp/watchers/watch_diskspace.sh new file mode 100755 index 0000000..9fd2e54 --- /dev/null +++ b/tsp/watchers/watch_diskspace.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Author: Aleksander Mistewicz + +export TSP_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)/.." + +. "${TSP_DIR}/common.sh" + +# Get diskspace usage for filesystem storing workspaces. +PER="$(df -P "${WS_DOWNLOAD}" | grep -o "[0-9]\+%.*$")" +# Leave only numerical value. +PER="${PER%\%*}" +if [ "$PER" -ge 30 ] +then + nr="$(tsmaster -L DISK_CLEANUP sh "${TSP_DIR}/jobs/free_diskspace.sh")" + # make the above job urgent + tsmaster -u "$nr" +fi diff --git a/tsp/watchers/watch_sdb.sh b/tsp/watchers/watch_sdb.sh new file mode 100755 index 0000000..4546f9a --- /dev/null +++ b/tsp/watchers/watch_sdb.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Author: Aleksander Mistewicz + +export TSP_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)/.." + +. "${TSP_DIR}/common.sh" + +# make sure the server is running +timeout 120 sdb start-server + +# check if it works +SDB="$(timeout 120 sdb devices)" +SDB_RET="$?" + +if [ "${SDB_RET}" -ne 0 ]; then + killall sdb + sdb start-server +fi + +post_prom "sdb_status" "$SDB_RET" "Return value of sdb devices" diff --git a/tsp/watchers/watch_symlinks.sh b/tsp/watchers/watch_symlinks.sh new file mode 100755 index 0000000..7d722c9 --- /dev/null +++ b/tsp/watchers/watch_symlinks.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Author: Aleksander Mistewicz + +UUID_DIR="/dev/disk/by-uuid" + +for SYMLINK in $(find "${UUID_DIR}" -type l) +do + echo "symlink: ${SYMLINK}" + DEST="$(readlink "${SYMLINK}")" + test -n "${DEST}" || { + echo "dest: empty" + continue + } + DEST="${UUID_DIR}/${DEST}" + echo "dest: ${DEST}" + test -f "${DEST}" && { + echo "dest is a file" + sudo rm -v "${DEST}" + } + test -b "${DEST}" && { + echo "dest is a block device" + continue + } + sudo rm -v "${SYMLINK}" +done diff --git a/tsp/watchers/watch_usb.sh b/tsp/watchers/watch_usb.sh new file mode 100755 index 0000000..99282a4 --- /dev/null +++ b/tsp/watchers/watch_usb.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Author: Aleksander Mistewicz +export TSP_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)/.." + +. "${TSP_DIR}/common.sh" + +timeout 120 lsusb +USB_RET="$?" +post_prom "usb_status" "$USB_RET" "Return value of lsusb" + +timeout 120 /usr/local/bin/sd-mux-ctrl -l +SDMUX_RET="$?" +post_prom "sdmux_status" "$SDMUX_RET" "Return value of sd-mux-ctrl -l" diff --git a/tsp/watchers/watcher.sh b/tsp/watchers/watcher.sh new file mode 100755 index 0000000..d5869ef --- /dev/null +++ b/tsp/watchers/watcher.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Author: Aleksander Mistewicz + +export TSP_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)/.." + +. "${TSP_DIR}/common.sh" + +# Dispatch tsp/jobs/trigger_downloads.sh for common snapshot and prerelease urls +tspoll -L 4_SNAPSHOT sh "${TSP_DIR}/jobs/trigger_downloads.sh" "http://download.tizen.org/snapshots/tizen/common/" tizen_4.0_snapshot +tspoll -L 4_PRERELEASE sh "${TSP_DIR}/jobs/trigger_downloads.sh" "http://download.tizen.org/prerelease/tizen/common/" tizen_4.0_prerelease +tspoll -L 3_SNAPSHOT sh "${TSP_DIR}/jobs/trigger_downloads.sh" "http://download.tizen.org/snapshots/tizen/3.0-common/" tizen_3.0_snapshot +tspoll -L 3_PRERELEASE sh "${TSP_DIR}/jobs/trigger_downloads.sh" "http://download.tizen.org/prerelease/tizen/3.0-common/" tizen_3.0_prerelease +tspoll -L UNI_SNAPSHOT sh "${TSP_DIR}/jobs/trigger_downloads.sh" "http://download.tizen.org/snapshots/tizen/unified/" tizen_uni_snapshot +tspoll -L UNI_PRERELEASE sh "${TSP_DIR}/jobs/trigger_downloads.sh" "http://download.tizen.org/prerelease/tizen/unified/" tizen_uni_prerelease -- cgit v1.2.3