-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·126 lines (87 loc) · 2.64 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Global variables
SCRIPT_DIR="$( cd $( dirname ${BASH_SOURCE[0]} ) >/dev/null 2>&1 && pwd )"
DIR="/usr/local"
NAME="aws-simple"
AWS=$DIR/$NAME
BIN=$DIR"/bin"
REPO=$AWS"/repository"
# Grabs current scripts available
SERVICES=$(ls $SCRIPT_DIR"/bin")
# Runs the installation process, you can check what each
# function does by scrolling down below, no secrets!
function main() {
# 1) Checks if kiss is already installed,
# remove files when reinstalling
installation-checker
# 2) Install kiss!
run-installer
# 3) Set permissions for all users
setup-permissions
}
##################################################
# 1) S E A R C H I N S T A L L A T I O N #
##################################################
# Will look for the kiss directory, if found then
# promt the user if they wish to reinstall
function installation-checker() {
if [ -d $AWS ]; then
echo "Looks like kiss is already installed, do you wish to reinstall?"
printf "Current user settings will be lost, type \"YES\" to continue: "
read input
if [ $input != "YES" ]; then
echo "Reinstallation canceled"
exit 0
fi
installation-cleaner
fi
}
# Deletes current installation, it will skip the repository
# if you're running the installer found in that directory
function installation-cleaner() {
files=$(ls $AWS)
if [ $SCRIPT_DIR = $REPO ]; then
files=$(ls $AWS -I "repository")
fi
# Removes files from /usr/local/aws-simple/
for file in ${files[@]}; do
sudo rm -r $AWS/$file
done
# Removes kiss script files from /usr/local/bin/
for service in ${SERVICES[@]}; do
sudo rm $BIN/$service
done
}
####################################
# 2) I N S T A L L K I S S #
####################################
# Copy kiss files to their respective location
function run-installer() {
if [ ! -d $AWS ]; then
sudo mkdir $AWS
fi
sudo cp -r $SCRIPT_DIR/$NAME/* $AWS/
sudo cp $SCRIPT_DIR"/bin"/* $BIN/
# Create repository if it hasn't been setup
if [ ! -d $REPO ]; then
sudo cp -r $SCRIPT_DIR $REPO
fi
}
##############################################
# 3) S E T U P P E R M I S S I O N S #
##############################################
function setup-permissions() {
# Give all permissions, because why not
sudo chmod -R 777 $AWS
for service in ${SERVICES[@]}; do
sudo chmod 777 $BIN/$service
done
}
###################################
# R U N S C R I P T #
###################################
# Install everything
main
# Print kiss information
kiss info
# Show kiss help
kiss