Bash Scripts

Need script that should find whether .deb os or .rpm os and install package 

 

#!/bin/bash

# Set variables

RPM=$(cat /etc/issue | awk -F . '{ print $1 }' | head -1)
DEB=$(cat /etc/issue | awk '( Print $1)' | cut -d ' ' -f1)

# Test for distro types
if [ -f $RPM ] 2> /dev/null
then
yum update
yum install -y snmpd
elif [ -f $DEB ] 2> /dev/null
then
apt-get update
apt-get install -y snmpd
fi

# Start your service
service snmpd status
if [ $? -ne 0 ]
then
echo "Would you like to start your service? Enter yes or no"
read ans
if [ $ans == yes ]
then
service snmpd start
elif [ $ans == no ]
then
echo "Your service has not been started"
fi
fi
echo "Please check your installation"  

 

 

Content Sync:

 

#!/bin/bash
#Web Contents
SRCDIR=/var/www/vhosts/grannliv.granngarden.se/
DESTDIR=root@10.224.44.126:/var/www/vhosts/grannliv.granngarden.se/
rsync -azvorgp --stats --progress --human-readable $SRCDIR $DESTDIR | tail -n 16 | mail -s 'web01 to ggab_test web-content sync report' test@gmail.com
# Database Contents
mysql_dump_path = '/var/backups/mysql'
database = 'iklasgra17402se12271_'
/usr/bin/mysqldump -u root -p<web01-mysql-password> -e -E --routines --single-transaction $database > $mysql_dump_path/$database.sql
/usr/bin/mysql -h 10.224.44.126 -u root -p<ggab_test-mysql-password> $database < $mysql_dump_path/$database.sql  && rm -f $mysql_dump_path/$database.sql | mail -s 'web01 to ggab_test db-content synced' test@gmail.com

Comments

Popular posts from this blog

KVM & Qemu

PHP Fatal error: Class 'JFactory' not found

docker.errors.APIError: 400 Client Error client is newer than server