-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
invokeTool.sh
executable file
·62 lines (52 loc) · 2.44 KB
/
invokeTool.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
#######################################################################################################################
#
# Download and invoke any tool available on raspberyyTools github repository
#
# Example to execute findSensors and sort the result according their mac addresses
# curl -s https://raw.githubusercontent.com/framps/raspberryTools/master/invokeTool.sh | bash -s -- findSensors.sh -s m
#
#######################################################################################################################
#
# Copyright (c) 2024 framp at linux-tips-and-tricks dot de
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#######################################################################################################################
MYSELF="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" # use linked script name if the link is used
MYNAME=${MYSELF%.*}
GITHUBREPO="https://github.com/framps/raspberryTools"
GITHUBREPODOWNLOAD="https://raw.githubusercontent.com/framps/raspberryTools"
if [[ -z "$1" || "$1" == "-h" || "$1" == "--help" || "$1" == "-?" || "$1" == "?" ]]; then
echo "Purpose: Download any file from raspberryTools github repository."
echo "Syntax: $MYSELF fileName"
echo "Example: $MYSELF findSensors.sh -s m"
exit 1
fi
branch="master"
targetFilename="$1"
shift
downloadURL="$GITHUBREPODOWNLOAD/$branch/$targetFilename"
trap "rm -f $targetFilename" SIGINT SIGTERM EXIT
echo "--- Downloading $targetFilename from git branch $branch from $GITHUBREPO into current directory ..."
wget -q $downloadURL -O "$targetFilename"
rc=$?
if (( $rc != 0 )); then
echo "??? Error occured downloading $downloadURL. RC: $rc"
echo "??? Does $targetFilename exist in repository $GITHUBREPO?"
exit 1
fi
echo "--- Download finished successfully"
echo "--- Invoking $targetFilename ..."
bash $targetFilename "$@"