-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·45 lines (35 loc) · 1002 Bytes
/
install
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
#!/bin/bash
# exit at first error
set -e
# where config folders will be copied
GLOBAL_INSTALL=/opt/mpi-is/pam # if install called by root
USER_INSTALL=$HOME/.mpi-is/pam # if install called by someone else
# not same installation folder if script called
# with or without sudo
if [ "$EUID" -ne 0 ]
then
# without sudo: user home directory
INSTALL_DIR=$USER_INSTALL
echo "installing configuration file in $INSTALL_DIR"
else
# with sudo: global install
INSTALL_DIR=$GLOBAL_INSTALL
echo "sudo: installing configuration file in $INSTALL_DIR"
fi
# creating the install folder
mkdir -p $INSTALL_DIR
# going into the config folder
cd config
# listing the folders to install as array
directories=($(ls -d */))
# installing each folder one by one
for folder in "${directories[@]}"
do
# copying the content of the folder
echo "- copying ${folder}"
cp -r ./$folder $INSTALL_DIR
done
# setting permissions: everybody can read
# and execute
chmod -R 755 ${INSTALL_DIR}
exit 0