-
Notifications
You must be signed in to change notification settings - Fork 14
/
configure
executable file
·71 lines (55 loc) · 1.72 KB
/
configure
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
63
64
65
66
67
68
69
70
71
#!/bin/sh
# Copyright 24.03.2022 - 31.03.2022 Nicolai Brand
#
# 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 2 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/>.
name="tomatoshell"
name_log="tomatoshell_log.csv"
bin_dir="/usr/local/bin"
data_dir="$HOME/.local/share/$name"
install() {
clean 2> /dev/null
sudo cp $name $bin_dir &&
mkdir -p "$data_dir" &&
touch "$data_dir/$name_log" &&
cp etc/alarm.wav $data_dir &&
exit 0
}
uninstall() {
sudo rm "$bin_dir/$name" 2> /dev/null &&
rm -rf "$data_dir" 2> /dev/null &&
exit 0
}
clean() {
rm "$data_dir/$name_log" &&
touch "$data_dir/$name_log" &&
cp etc/alarm.wav "$data_dir/"
}
print_help() {
echo "usage: 'install', 'uninstall', 'clean'." &&
echo "example: '$ ./configure install' to install the program." &&
exit 1
}
[ "$#" -eq 0 ] && print_help
if [ "$1" = "install" ]
then
install || exit 1
fi
if [ "$1" = "uninstall" ]
then
uninstall || exit 1
fi
[ "$1" = "clean" ] && clean && exit 0 || exit 1
# if program executions ends here it means the user typed an invalid argument
# i use printf here because echo -e is undefined in POSIX sh
printf "%s\n\n" "invalid argument '$1'." && print_help