-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_debug_archive_generation.sh
69 lines (54 loc) · 1.86 KB
/
install_debug_archive_generation.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
#!/usr/bin/bash
install_git() {
which git > /dev/null 2>&1
is_git_installed=$?
which dnf > /dev/null 2>&1
is_rhel=$?
if [[ $is_git_installed -eq 0 ]];then
echo -e "Git already installed"
else
echo -e "Intalling git..."
if [[ $is_rhel -eq 0 ]];then
dnf install -y git
else
apt update && apt install -y git
fi
fi
}
clone_repo() {
repo="https://github.com/ykacherCentreon/support_debug_archive.git"
home=$(echo ~)
destination="$home/support_debug_archive"
if [[ -d $destination ]]; then
rm -rf $destination
fi
echo -e "Downloading..."
git clone $repo $destination
}
install_debug_archive_tool() {
install_dir="/usr/share/centreon/www/include/Administration/parameters/debug"
copy_cmd="/bin/cp"
source=$1
#Backup the original content
sudo -u centreon $copy_cmd -r $install_dir{,.origin}
#Install the tool
echo -e "Installing..."
$copy_cmd $source/* $install_dir && chown -R centreon: $install_dir/*
}
add_sudoers_file(){
name="support_debug_archive"
path="/etc/sudoers.d/$name"
apache_users="apache,www-data" #separated_by_comma
cmd='/bin/tar -czvf *'
content="User_Alias HTTP_USERS=$apache_users\nDefaults:HTTP_USERS !requiretty\n\nHTTP_USERS ALL = (ALL) NOPASSWD: $cmd"
touch $path
echo -e "Adding sudoers file..."
echo -e "$content" > $path
}
echo -e "######### Starting installation #########"
install_git
clone_repo
install_debug_archive_tool $destination
rm -rf $destination #clean the cloned repo file after having installed them
add_sudoers_file
echo -e "######### Installation finished #########"