zabbix urbackup

This commit is contained in:
2019-04-17 18:18:47 +02:00
parent 7f20c1f6c2
commit e129e4939f
16 changed files with 3417 additions and 163 deletions
+2
View File
@@ -3,3 +3,5 @@
apk add bash bash-doc bash-completion
sed -i 's/root:\/bin\/ash/root:\/bin\/bash/g' /etc/passwd
exec bash
+2 -21
View File
@@ -7,27 +7,8 @@ echo '
|___/\___/\__|_| |_|_\___/__/
'
#installing better prompt and some goodies
echo "Installing shell prompt for current user $USER "
echo "Installing dot files for current user"
sleep 2
#
# # get the current position
# _cwd="$(pwd)"
#
# # check for assets forlder
# _assets="$_cwd/assets"
# if [ ! -d "$_assets" ]; then
# _assets="$_cwd/../assets"
# if [ ! -d "$_assets" ]; then
# echo "!! can't find assets directory !!"
# exit
# fi
# fi
#
# cp "$_assets"/dotfiles/.vimrc /home/"$USER"/
# cp -r "$_assets"/dotfiles/.vim /home/"$USER"/
#
# cp "$_assets"/dotfiles/.inputrc /home/"$USER"/
# get the current position
_cwd="$(pwd)"
@@ -39,4 +20,4 @@ source ~/.bashrc
# return to working directory
cd "$_cwd"
echo "Dot files installed for $USER"
echo "Dot files installed"
+17 -122
View File
@@ -59,7 +59,7 @@ echo -e '
'
echo -e "Installing PHP 7.0"
sleep 3
apk add php7 php7-fpm php7-pdo_mysql php7-opcache php7-curl php7-mbstring php7-zip php7-xml php7-gd php7-mcrypt php7-imagick
apk add php7 php7-fpm php7-pdo_mysql php7-opcache php7-curl php7-mbstring php7-zip php7-xml php7-gd php7-mcrypt php7-imagick php7-phar
echo -e "Configuring PHP"
@@ -123,33 +123,30 @@ echo -e "Nginx installed"
# echo -e "You can access it at yourip/phpmyadmin"
echo -e '
____ ___
/ __ \___ ____/ (_)____
/ /_/ / _ \/ __ / / ___/
/ _, _/ __/ /_/ / (__ )
/_/ |_|\___/\__,_/_/____/
_ _
_ _ ___ __| (_)___
| `_/ -_) _` | (_-<
|_| \___\__,_|_/__/
'
echo -e "Installing Redis"
sleep 3
apk add redis-server php-redis
apk add redis php7-pecl-redis
# TODO set maxmemory=2gb
# TODO set maxmemory-policy=volatile-lru
# TODO comment all save line
systemctl enable redis-server
systemctl restart redis-server
systemctl restart php7.0-fpm
rc-update add redis
service redis start
service php-fpm7 restart
echo -e "Redis installed"
echo -e '
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
__ ___ _ __ _ __ ___ ___ ___ _ _
/ _/ _ \ ` \| `_ \/ _ (_-</ -_) `_|
\__\___/_|_|_| .__/\___/__/\___|_|
|_|
'
echo -e "Installing Composer"
sleep 3
@@ -160,11 +157,10 @@ echo -e "Composer installed"
echo -e '
____ __
/ __ \_______ _______/ /_
/ / / / ___/ / / / ___/ __ \
/ /_/ / / / /_/ (__ ) / / /
/_____/_/ \__,_/____/_/ /_/
_ _
__| |_ _ _ _ __| |_
/ _` | `_| || (_-< ` \
\__,_|_| \_,_/__/_||_|
'
echo -e "Installing Drush and DrupalConsole"
sleep 3
@@ -173,104 +169,3 @@ chmod +x /usr/local/bin/drupal
curl https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar -L -o /usr/local/bin/drush
chmod +x /usr/local/bin/drush
echo -e "Drush and DrupalConsoleinstalled"
# TODO supervising
# echo -e '
# __ ___ _ __ __ __ ___ _
# / |/ /__ ___ (_) /_ _/_/ / |/ /_ _____ (_)__
# / /|_/ / _ \/ _ \/ / __/ _/_/ / /|_/ / // / _ \/ / _ \
# /_/ /_/\___/_//_/_/\__/ /_/ /_/ /_/\_,_/_//_/_/_//_/
#'
# echo -e "Installing Munin"
# sleep 3
# # https://www.howtoforge.com/tutorial/server-monitoring-with-munin-and-monit-on-debian/
# apt-get --yes --force-yes install munin munin-node munin-plugins-extra
# # Configure Munin
# # enable plugins
# ln -s /usr/share/munin/plugins/mysql_ /etc/munin/plugins/mysql_
# ln -s /usr/share/munin/plugins/mysql_bytes /etc/munin/plugins/mysql_bytes
# ln -s /usr/share/munin/plugins/mysql_innodb /etc/munin/plugins/mysql_innodb
# ln -s /usr/share/munin/plugins/mysql_isam_space_ /etc/munin/plugins/mysql_isam_space_
# ln -s /usr/share/munin/plugins/mysql_queries /etc/munin/plugins/mysql_queries
# ln -s /usr/share/munin/plugins/mysql_slowqueries /etc/munin/plugins/mysql_slowqueries
# ln -s /usr/share/munin/plugins/mysql_threads /etc/munin/plugins/mysql_threads
#
# ln -s /usr/share/munin/plugins/apache_accesses /etc/munin/plugins/
# ln -s /usr/share/munin/plugins/apache_processes /etc/munin/plugins/
# ln -s /usr/share/munin/plugins/apache_volume /etc/munin/plugins/
#
# # ln -s /usr/share/munin/plugins/fail2ban /etc/munin/plugins/
#
# # dbdir, htmldir, logdir, rundir, and tmpldir
# sed -i 's/^#dbdir/dbdir/' /etc/munin/munin.conf
# sed -i 's/^#htmldir/htmldir/' /etc/munin/munin.conf
# sed -i 's/^#logdir/logdir/' /etc/munin/munin.conf
# sed -i 's/^#rundir/rundir/' /etc/munin/munin.conf
# sed -i 's/^#tmpldir/tmpldir/' /etc/munin/munin.conf
#
# sed -i "s/^\[localhost.localdomain\]/[${HOSTNAME}]/" /etc/munin/munin.conf
#
# # ln -s /etc/munin/apache24.conf /etc/apache2/conf-enabled/munin.conf
# sed -i 's/Require local/Require all granted\nOptions FollowSymLinks SymLinksIfOwnerMatch/g' /etc/munin/apache24.conf
# htpasswd -c /etc/munin/munin-htpasswd admin
# sed -i 's/Require all granted/AuthUserFile \/etc\/munin\/munin-htpasswd\nAuthName "Munin"\nAuthType Basic\nRequire valid-user/g' /etc/munin/apache24.conf
#
#
# service apache2 restart
# service munin-node restart
# echo -e "Munin installed"
#
# echo -e "Installing Monit"
# sleep 3
# # https://www.howtoforge.com/tutorial/server-monitoring-with-munin-and-monit-on-debian/2/
# apt-get --yes --force-yes install monit
# # TODO setup monit rc
# cat "$_assets"/monitrc > /etc/monit/monitrc
#
# # TODO setup webaccess
# passok=0
# while [ "$passok" = "0" ]
# do
# echo -n "Write web access password to monit"
# read passwda
# echo -n "ReWrite web access password to monit"
# read passwdb
# if [ "$passwda" = "$passwdb" ]; then
# sed -i 's/PASSWD_TO_REPLACE/$passwda/g' /etc/monit/monitrc
# passok=1
# else
# echo -e "pass words don't match, please try again"
# fi
# done
#
# # TODO setup mail settings
# sed -i "s/server1\.example\.com/$HOSTNAME/g" /etc/monit/monitrc
#
# mkdir /var/www/html/monit
# echo -e "hello" > /var/www/html/monit/token
#
# service monit start
#
# echo -e "Monit installed"
# echo -e '
# ___ __ __
# / |_ _______/ /_____ _/ /_
# / /| | | /| / / ___/ __/ __ `/ __/
# / ___ | |/ |/ (__ ) /_/ /_/ / /_
# /_/ |_|__/|__/____/\__/\__,_/\__/
#'
# echo -e "Installing Awstat"
# sleep 3
# apt-get --yes --force-yes install awstats
# # Configure AWStats
# temp=`grep -i sitedomain /etc/awstats/awstats.conf.local | wc -l`
# if [ $temp -lt 1 ]; then
# echo SiteDomain="$_domain" >> /etc/awstats/awstats.conf.local
# fi
# # Disable Awstats from executing every 10 minutes. Put a hash in front of any line.
# sed -i 's/^[^#]/#&/' /etc/cron.d/awstats
# echo -e "Awstat installed"
+4 -4
View File
@@ -15,12 +15,12 @@ echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/main
@edgecommunity http://dl-cdn.alpinelinux.org/alpine/edge/community
@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories
apk add vim curl
apk update
apk add procps vim curl tmux etckeeper htop lynx unzip # needrestart
# sed -i "s/^# en_GB.UTF-8/en_GB.UTF-8/g" /etc/locale.gen
# locale-gen
# apt-get --yes --force-yes install ntp
# dpkg-reconfigure tzdata
apk add tmux etckeeper htop lynx unzip # needrestart
apk add tzdata
TIMEZONE="Europe/Paris"
+81
View File
@@ -0,0 +1,81 @@
#!/bin/sh
echo -e '
_ _ _ _ ___ _ _ _
| | | |_ _| |__ __ _ __| |___ _ _ __ / __| | (_)___ _ _| |_
| |_| | _| _ \/ _` / _| / / || | _ \ | (__| |__| / -_) \ _|
\___/|_| |_.__/\__,_\__|_\_\\_,_| .__/ \___|____|_\___|_||_\__|
|_|
'
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit
fi
# get the current position
_cwd="$(pwd)"
# check for assets forlder
_assets="$_cwd/assets"
if [ ! -d "$_assets" ]; then
_assets="$_cwd/../assets"
if [ ! -d "$_assets" ]; then
echo "!! can't find assets directory !!"
exit
fi
fi
# install urbackup client
# https://www.urbackup.org/client_debian_ubuntu_install.html
# https://blog.stephane-huc.net/systeme/debian/urbackup_client_gui
# https://urbackup.atlassian.net/wiki/spaces/US/pages/9142274/Headless+Linux+client+setup
# Install the dependencies UrBackup needs
# apt install build-essential "g++" "libcrypto++-dev" libz-dev -y
apk add linux-headers "g++" zlib zlid-dev "crypto++@testing" "crypto++dev@testing"
ln -s /usr/lib/libcryptopp.so /usr/lib/libcryptopp.so.5.6
# Download the UrBackup client source files and extract them
wget -P /tmp/ https://hndl.urbackup.org/Client/latest/urbackup-client-2.3.4.0.tar.gz
cd /tmp
tar xzf /tmp/urbackup-client-2.3.4.0.tar.gz
# Build the UrBackup client and install it
cd /tmp/urbackup-client-2.3.4.0
./configure --enable-headless
make -j4
make install
# Make sure that the UrBackup client backend runs correctly
# urbackupclientbackend -v info
# configure
echo -n "Please provide the urbackup-server's ip : "
read _ip
echo -n "Please provide the internet_authkey of server : "
read _authkey
echo -n "Please provide the computer name of this client : "
read _computername
echo "internet_server=$_ip
internet_server_port=55415
internet_authkey=$_authkey
internet_mode_enabled=true
internet_image_backups_def=false
default_dirs_def=/etc;var/www;/var/backups/mysql
startup_backup_delay_def=3
computername=$_computername" > /usr/local/var/urbackup/data/settings.cfg
# firewall
ufw allow from "$_ip" to any port 35621
ufw allow from "$_ip" to any port 35622
ufw allow from "$_ip" to any port 35623
# install and enable openrc service
cp "$_assets"/urbackup.service /etc/init.d/urbackup
chmod a+x /etc/init.d/urbackup
rc-update add urbackup
service urbackup start
Executable
+94
View File
@@ -0,0 +1,94 @@
#!/bin/sh
echo -e '
_ _ _
_____ _| |__| |__(_)__
|_ / _` | `_ \ `_ \ / _|
/__\__,_|_.__/_.__/_\__|
'
. bin/checkroot.sh
# get the current position
_cwd="$(pwd)"
# check for assets forlder
_assets="$_cwd/assets"
if [ ! -d "$_assets" ]; then
_assets="$_cwd/../assets"
if [ ! -d "$_assets" ]; then
echo "!! can't find assets directory !!"
exit
fi
fi
apk add zabbix-agent
# configure
echo -n "Please provide the current server's public ip : "
read _cur_ip
echo -n "Please provide the zabbix-server's ip : "
read _ip
echo -n "Please provide the hostname of this agent : "
read _host_name
echo -n "Please provide the mysql root password : "
read _root_mysql_passwd
# configure zabbix agent
sed -i "s#Server=127.0.0.1#Server=$_ip#g" /etc/zabbix/zabbix_agentd.conf
sed -i "s#ServerActive=127.0.0.1#ServerActive=$_ip#g" /etc/zabbix/zabbix_agentd.conf
sed -i "s#Hostname=Zabbix server#Hostname=$_host_name#g" /etc/zabbix/zabbix_agentd.conf
_agent_conf_d="/etc/zabbix/zabbix_agentd.d"
mkdir $_agent_conf_d
sed -i "s|#\ Include=$|Include= $_agent_conf_d|g" /etc/zabbix/zabbix_agentd.conf
# apk
# check for alpine security updates
# # MYSQL
# # https://serverfault.com/questions/737018/zabbix-user-parameter-mysql-status-setting-home
# # create zabbix user home
# mkdir /var/lib/zabbix
# # generate random password for zabbix mysql user
# _passwd="$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12)"
# # add mysql credentials to zabbix home
# printf "[client]\n
# user=zabbix\n
# password=$_passwd" > /var/lib/zabbix/.my.cnf
# # create zabbix mysql user
# mysql -uroot -p"$_root_mysql_passwd" -e "CREATE USER 'zabbix' IDENTIFIED BY '$_passwd';"
# mysql -uroot -p"$_root_mysql_passwd" -e "GRANT USAGE ON *.* TO 'zabbix'@'localhost' IDENTIFIED BY '$_passwd';"
# # add zabbix-agent parameter
# cp "$_assets"/zabbix/userparameter_mysql.conf "$_agent_conf_d"/
# NGINX
# https://github.com/sfuerte/zbx-nginx
# nginxconf already included in default.nginxconf asset
sed -i "s/# allow CURRENT-SERVER-IP/allow $_cur_ip/g" /etc/nginx/sites-available/default
cp "$_assets"/zabbix/userparameter_nginx.conf "$_agent_conf_d"/
mkdir /etc/zabbix/zabbix_agentd.scripts
cp "$_assets"/zabbix/scripts/nginx-stat.py /etc/zabbix/zabbix_agentd.scripts/
chmod +x /etc/zabbix/zabbix_agentd.scripts/nginx-stat.py
echo -n "This is box is a proxmox CT? [Y|n] "
read yn
yn=${yn:-y}
if [ "$yn" = "Y" ] || [ "$yn" = "y" ]; then
cp "$_assets"/zabbix/proxmox-ct.conf "$_agent_conf_d"/
fi
# allow comm. port with zabbix-server
ufw allow from "$_ip" to any port 22
ufw allow from "$_ip" to any port 10050
# ufw allow from "$_ip" to any port 10051
rc-update add zabbix-agent
service zabbix-agent restart
echo -e "Zabbix-agent installed and configured, please add the host $_host_name in your zabbix-server"
echo -e "And import requested templates in assets/zabbix/templates/"
# echo -e "zabbix user mysql password is $_passwd"