forked from possatti/pokemonsay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·74 lines (58 loc) · 2.01 KB
/
install.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
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh
# Define install directories and names
install_path="$HOME/.pokemonsay"
bin_path="$HOME/bin"
pokemonsay_bin="pokemonsay"
pokemonthink_bin="pokemonthink"
# Make sure the directories exist
mkdir -p $install_path/
mkdir -p $install_path/cows/
mkdir -p $bin_path/
# Copy the cows and the main script to the install path.
cp ./cows/*.cow $install_path/cows/
cp ./pokemonsay.sh $install_path/
cp ./pokemonthink.sh $install_path/
# Create the pokemonsay script in the home bin directory.
cat > $bin_path/$pokemonsay_bin <<- EOF
#!/bin/sh
# This script changes to the pokemonsay installation directory,
# runs the main script for running the pokemonsay, and changes
# back to the previous directory.
cd $install_path/
./pokemonsay.sh \$@
cd - >/dev/null
EOF
# Create the pokemonthink script in the home bin directory.
cat > $bin_path/$pokemonthink_bin <<- EOF
#!/bin/sh
# This script changes to the pokemonsay installation directory,
# runs the main script for running the pokemonthink, and changes
# back to the previous directory.
cd $install_path/
./pokemonthink.sh \$@
cd - >/dev/null
EOF
# Create uninstall script in the install directory
cat > $install_path/uninstall.sh <<- EOF
#!/bin/sh
#
# This script uninstalls pokemonsay.
#
# Remove the install directory
rm -r "$install_path/"
# Remove the bin files
rm "$bin_path/$pokemonsay_bin"
rm "$bin_path/$pokemonthink_bin"
# Say what's going on.
echo "'$install_path/' directory was removed."
echo "'$bin_path/$pokemonsay_bin' file was removed."
echo "'$bin_path/$pokemonthink_bin' file was removed."
EOF
# Change permission of the generated scripts
chmod +x "$bin_path/$pokemonsay_bin"
chmod +x "$bin_path/$pokemonthink_bin"
chmod +x "$install_path/uninstall.sh"
echo "The files were installed to '$install_path/'."
echo "A '$pokemonsay_bin' script was created in '$bin_path/'."
echo "A uninstall script was created in '$install_path/'."
echo "It may be necessary to logout and login back again in order to have the '$pokemonsay_bin' available in your path."