This repository has been archived by the owner on Jul 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup
63 lines (50 loc) · 1.8 KB
/
setup
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
#!/bin/sh
# Print text in colored format
log_echo() {
# $1 is the text to print
# $2 is the color of the text
if [ "$2" == "red" ]; then
# Print the text in red
echo -e "\033[1;31m$1\033[0m" >&2
exit 1
elif [ "$2" == "green" ]; then
# Print the text in green
echo -e "\033[1;32m$1\033[0m"
else
# If the color is not recognized, print the text in the default color
echo "$1"
fi
}
# Create the /opt/watodo/ directory if it does not exist
if ! [ -d /opt/watodo/ ]; then
if ! sudo mkdir -p /opt/watodo/; then
log_echo "Error: Failed to create the /opt/watodo/ directory" "red"
fi
fi
# Change /opt/watodo/ directory ownership to current user
if ! sudo chown -R "$(whoami):$(whoami)" /opt/watodo/; then
log_echo "Error: Failed to change ownership of /opt/watodo/" "red"
fi
# Create the /usr/share/licenses/watodo/ directory if it does not exist
if ! [ -d /usr/share/licenses/watodo/ ]; then
if ! sudo mkdir -p /usr/share/licenses/watodo/; then
log_echo "Error: Failed to create the /usr/share/licenses/watodo/ directory" "red"
fi
fi
# Copy the necessary files to /opt/watodo/
if ! cp ./watodo.py ./README.md ./LICENCE /opt/watodo/; then
log_echo "Error: Failed to copy files to /opt/watodo/" "red"
fi
# Copy the LICENCE to /usr/share/licenses/watodo/
if ! sudo cp ./LICENCE /usr/share/licenses/watodo/; then
log_echo "Error: Failed to copy LICENCE to /usr/share/licenses/watodo/" "red"
fi
# Make the bin/watodo script executable
if ! chmod +x ./bin/watodo; then
log_echo "Error: Failed to make the watodo executable" "red"
fi
# Copy the watodo script to /usr/local/bin/watodo
if ! sudo cp ./bin/watodo /usr/local/bin/watodo; then
log_echo "Error: Failed to copy the bin/watodo script to /usr/local/bin/watodo" "red"
fi
log_echo "Now you can delete cloned repository" "green"