summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Lacerda <alacerda@alpinelinux.org>2015-07-15 13:37:14 +0000
committerAlan Lacerda <alacerda@alpinelinux.org>2015-07-15 13:37:14 +0000
commit0e248cae153c5f647daa7ef14b0c9b0c62cec72e (patch)
treed24d038a1bd32597a3172bc96a2f6adac3edf2d4
parent77bc59558d9a4823258f0241fe21460124ec3cc6 (diff)
downloadsetup-box-0e248cae153c5f647daa7ef14b0c9b0c62cec72e.tar.bz2
setup-box-0e248cae153c5f647daa7ef14b0c9b0c62cec72e.tar.xz
setup-box: adding zabbix server subgroup (auto setup)
now we can install and configure zabbix monitoring with: ~# setup-box -s networking.zabbix_monitor
-rw-r--r--json/networking.json36
-rwxr-xr-xsetup-box135
2 files changed, 140 insertions, 31 deletions
diff --git a/json/networking.json b/json/networking.json
index b5edea9..e9a60db 100644
--- a/json/networking.json
+++ b/json/networking.json
@@ -10,6 +10,42 @@
]
}
]
+ },
+ { "zabbix_monitor": [
+ { "packages": [
+ "php-common",
+ "php-iconv",
+ "php-json",
+ "php-gd",
+ "php-curl",
+ "php-xml",
+ "php-pgsql",
+ "php-imap",
+ "php-cgi",
+ "fcgi",
+ "php-pdo",
+ "php-pdo_pgsql",
+ "php-soap",
+ "php-xmlrpc",
+ "php-posix",
+ "php-mcrypt",
+ "php-gettext",
+ "php-ldap",
+ "php-ctype",
+ "php-dom",
+ "postgresql-client",
+ "zabbix-pgsql",
+ "zabbix-webif",
+ "zabbix-setup"
+ ]
+ },
+ { "services": [
+ "zabbix",
+ "lighttpd",
+ "postgresql"
+ ]
+ }
+ ]
}
]
}
diff --git a/setup-box b/setup-box
index b4663d8..f2c49d0 100755
--- a/setup-box
+++ b/setup-box
@@ -33,7 +33,7 @@ $(basename $0) $VERSION - Setup a variety Environments
Usage: $(basename $0) option [args]
Options:
- -b Setup Alpine Linux
+ -b Basic Alpine Linux Setup
-d Select a desktop environment:
mate
openbox
@@ -271,14 +271,20 @@ optimize_serv() {
# Function to execute the rc-update add against each services that were installed
add_services() {
for i in $@; do
- rc-update add $i
if [ "$i" == "udev" ]; then
+ rc-update add $i
rc-update add $i-postmount
add_to_sysinit "$i $i-postmount"
elif [ "$i" == "dbus" ]; then
+ rc-update add $i
add_to_sysinit "$i"
elif [ "$i" == "xrdp" ]; then
+ rc-update add $i
rc-update add $i-sesman
+ elif [ "$i" == "zabbix" ]; then
+ rc-update add $i-server
+ else
+ rc-update add $i
fi
done
}
@@ -291,13 +297,66 @@ add_to_sysinit() {
start_services() {
for i in $@; do
- rc-service $i start
if [ "$i" == "udev" ]; then
+ rc-service $i start
rc-service $i-postmount start
+ elif [ "$i" == "zabbix" ]; then
+ rc-service $i-server start
+ else
+ rc-service $i start
fi
done
}
+setup_zabbix() {
+ php_conf="/etc/php/php.ini"
+ zabbix_conf="/etc/zabbix/zabbix_server.conf"
+ # first lets enable lighttpd fastcgi module
+ sed -i '/mod_fastcgi.conf/s/#//g' /etc/lighttpd/lighttpd.conf
+
+ # next, let us setup postgresql
+ /etc/init.d/postgresql setup
+
+ start_services "postgresql"
+
+ echo -n -e "Choose a password for zabbix's database user:\033[1;31m "
+ read zabbix_pass
+ echo -e "\033[0m"
+
+ # executing database commands:
+ psql -U postgres <<EOF
+\x
+create user zabbix with password '$zabbix_pass';
+create database zabbix owner zabbix;
+EOF
+
+ for i in schema.sql images.sql data.sql; do
+ < /usr/share/zabbix/database/postgresql/$i psql -U zabbix zabbix
+ done
+
+ rm /var/www/localhost/htdocs -R
+ ln -s /usr/share/webapps/zabbix /var/www/localhost/htdocs
+
+ cat << EOF >> $php_conf
+max_execution_time = 600
+expose_php = off
+post_max_size = 32M
+upload_max_filesize = 16M
+max_input_time = 600
+memory_limit = 256M
+always_populate_raw_post_data = -1
+EOF
+
+ # setting user and password to access the database
+ sed -e "s/#*DBName.*/DBName\=zabbix/g" -i $zabbix_conf
+ sed -e "s/#*DBUser.*/DBUser\=zabbix/g" -i $zabbix_conf
+ sed -e "s/#*DBPassword.*/DBPassword\=$zabbix_pass/g" -i $zabbix_conf
+
+ # fixing permission
+ chown -R lighttpd /usr/share/webapps/zabbix/conf
+
+}
+
##
# Main function starts here
main () {
@@ -327,6 +386,9 @@ main () {
create_user="1"
search_desktop "$OPTARG";;
s)
+ if [ "$OPTARG" == "networking.zabbix_monitor" ]; then
+ zabbix_config="1"
+ fi
search_sub_group "$OPTARG";;
g)
search_meta_group "$OPTARG";;
@@ -355,40 +417,51 @@ main () {
# Packages to be installed (including services)
optimize_pack "$final_pack"
- echo "We are about to install the following packages:"
- echo $final_pack | tr '\ ' '\n'
- echo -n "Do you agree?[Y/n]: "
- read answer
- if [ "$answer" == "" ]; then answer="Y"; fi
- if [ $answer == "Y" ] || [ $answer == "y" ]; then
- apk add $final_pack
- else
- exit 0
- fi
+ apk add $final_pack -i
# Services to be added to startup (just services)
- optimize_serv "$final_serv"
- add_services $final_serv
+ if [ "$?" == "0" ]; then
+ optimize_serv "$final_serv"
+ add_services $final_serv
- if [ "$create_user" == "1" ]; then
- if [ "x$new_user" == "x" ]; then
- new_user="alpine"
+ if [ "$create_user" == "1" ]; then
+ if [ "x$new_user" == "x" ]; then
+ new_user="alpine"
+ fi
+ echo -e "\033[1;33m****************************************************"
+ echo -e "We've created a new user for you: $new_user"
+ echo -e "****************************************************"
+ adduser -h /home/$new_user -g "Alpine Linux User" $new_user
+ while [ $? -eq 1 ]; do
+ echo -e "\033[0;31mPasswords mismatch. Try again"
+ passwd $new_user
+ done
+ for grp in audio video cdrom usb; do
+ adduser $new_user $grp
+ done
+ echo -e "\033[0m"
fi
- echo -e "\033[1;33m****************************************************"
- echo -e "We've created a new user for you: $new_user"
- echo -e "****************************************************"
- adduser -h /home/$new_user -g "Alpine Linux User" $new_user
- while [ $? -eq 1 ]; do
- echo -e "\033[0;31mPasswords mismatch. Try again"
- passwd $new_user
- done
- for grp in audio video cdrom usb; do
- adduser $new_user $grp
- done
+
+ # start of setup environments - after install the packages
+ # but before start their services
+
+ if [ "$zabbix_config" == "1" ]; then
+ setup_zabbix
+ start_services zabbix
+ final_msg="\033[1;33mKeep note of the following information:\nDATABASE:\n"
+ final_msg=$final_msg"\tDatabase name: zabbix\n\tDatabase user: zabbix\n\tDatabase password: $zabbix_pass\nHTTP:\n"
+ final_msg=$final_msg"\tZabbix User: Admin\n\tZabbix Pass: zabbix\nNow browse to: http://<my_ip>/setup.php"
+ fi
+
+ # end of setup environments
+
+ start_services $final_serv
+
+ echo -e "$final_msg"
echo -e "\033[0m"
+ else
+ exit $?
fi
-
- start_services $final_serv
}
main $@