Skip to content

Instantly share code, notes, and snippets.

View hoangdh's full-sized avatar
🏠
Working from home

Dao Huy Hoang hoangdh

🏠
Working from home
View GitHub Profile
#!/bin/bash
yum install epel-release yum-utils -y
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
yum-config-manager --enable remi-php72
yum install php-cli php-fpm php-mysql php-json php-opcache php-mbstring php-xml php-gd php-curl -y
@hoangdh
hoangdh / percona.sh
Created April 23, 2019 02:09
Install Percona XtraDB without a password prompt
#!/bin/bash
apt-get remove apparmor -y
wget https://repo.percona.com/apt/percona-release_latest.generic_all.deb -P /tmp/
dpkg -i /tmp/percona-release_latest.generic_all.deb
apt-get update
export DEBIAN_FRONTEND=noninteractive
apt-get install percona-xtradb-cluster-57 -y -q
@hoangdh
hoangdh / disable-selinux.md
Last active April 21, 2019 16:12
Disable SELinux on CentOS7

Disable SELinux using sed command on CentOS 7

sed -i -E 's/^SELINUX=(.*)/SELINUX=disabled/g' /etc/sysconfig/selinux
setenforce 0
@hoangdh
hoangdh / install-SSLPaid.sh
Last active March 24, 2019 16:25
Install SSL Paid (GlobalSign - GMO) for Zimbra.
#!/bin/bash
if [ $# -ge 2 ]
then
dom=`basename $1 .txt`
mkdir -p /tmp/$dom/
CERT="/tmp/$dom/$dom.crt"
KEY="/tmp/$dom/$dom.key"
else
echo -e "Usage: $0 tenten.vn.txt <alpha,ov,dv,ev>\nNote: The extention file must be .txt - Example: tenten.vn.txt"
exit 2
#!/bin/bash
###
#
# 1. Gateway
# 2. Subnet mask
# 3. IP1
# ...
# n. IPn
#!/bin/bash
echo "Hello world!"
@hoangdh
hoangdh / send-mail-smtp.py
Last active March 4, 2019 03:41
Sending email via python script.
import smtplib
import os
import sys
import urllib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.header import Header
# Get argurment
data, recipient, subject = sys.argv[1:4]
@hoangdh
hoangdh / backup-all-databases-mysql.sh
Last active February 22, 2021 04:01
Dump all database on MySQL/MariaDB systems.
#!/bin/bash
BACKUP_DIR="/opt/backup"
mkdir -p ${BACKUP_DIR}
## Get all databases on system
USER="root"
PASSWORD=""
DBS=`mysql -u ${USER} -p${PASSWORD} -sNe "SHOW DATABASES;" | grep -Ev "information_schema|performance_schema|mysql|test"`
for DB in ${DBS}
@hoangdh
hoangdh / backup-to-aws.py
Last active February 26, 2019 15:56
Upload, delete files on AWS S3
import boto3
from datetime import datetime, timedelta
# Requeriment
## python2.7, boto3 (pip install boto3)
## ~/.aws/credentials - Contain your credentail (API, Secret)
## ~/.aws/config - Contain your config (Region,...)
## More details: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html
# Upload a file into Bucket
@hoangdh
hoangdh / sync-password-hash-zimbra.sh
Last active January 31, 2024 14:55
Sync password hash from another system to Zimbra.
#!/bin/bash
FILE=$1
if [ -e $FILE ]
then
cat $FILE | while read -r l
do
text=`echo $l | sed "s/(//g; s/'//g; s/)//; s/;//g; s/)//g; s/,//g"`
USER=$(echo $text | awk '{print $1}')