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
@hoangdh
hoangdh / install-youtube-dl.sh
Last active March 16, 2023 13:48
Install youtube-dl and FFMpeg on Linux
#!/bin/bash
wget -qP /tmp/ https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
cd /tmp
tar -xf /tmp/ffmpeg-release-amd64-static.tar.xz
cp -R /tmp/ffmpeg-*/ff* /usr/local/sbin/
rm -rf /tmp/ffmpeg-*
curl -sL https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
chmod a+rx /usr/local/bin/youtube-dl
@hoangdh
hoangdh / md5-hash.sh
Created February 11, 2019 04:47
How to get the MD5 hash of a string directly in the terminal
#!/bin/bash
encrypt(){
echo -n "$1" | md5sum | awk {'print $1'}
# echo -n "$1" | openssl md5 | awk {'print $2'}
}
RAW="$1"
encrypt $RAW
@hoangdh
hoangdh / update-timezone.sh
Created February 8, 2019 17:03
Automatic update time/date on Linux
#!/bin/bash
timedatectl set-timezone Asia/Ho_Chi_Minh
yum install ntp -y
ntpdate pool.ntp.org
@hoangdh
hoangdh / install-docker-c7.sh
Last active October 25, 2022 04:15
Install Docker + Docker Compose on CentOS 7
#!/bin/bash
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io -y
systemctl start docker
systemctl enable docker
curl -sLk "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
@hoangdh
hoangdh / install-MariaDB10.3.C7.sh
Last active May 27, 2019 03:35
Quick install MariaDB 10.3 on CentOS 7.3
#!/bin/bash
cat > /etc/yum.repos.d/mariadb.repo << EOF
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/centos73-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF
@hoangdh
hoangdh / gen-part.sh
Created February 2, 2019 15:07
Cutting video duration greater than 60 minutes using FFMPEG.
#!/bin/bash
dur=`ffprobe -v error -select_streams v:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 "$1" | head -n 1`
## Chinh so phut o $parts, $t va 2 cau lenh cut
flag=`echo "$dur > 3600" | bc`
name=`echo $1 | tr '.' ' ' | awk {'print $1'}`
if [ $flag = "1" ]
then
@hoangdh
hoangdh / http-code-status.sh
Last active February 7, 2019 03:39
Check HTTP code status using Nagios/check_mk plugin
#!/bin/bash
SERVER=$1
STATUS=$(curl -sL -o /dev/null -w "%{http_code}" $SERVER)
case $STATUS in
200)
echo "$SERVER is still running."
exit 0
;;
*)
echo "$SERVER is not running."
#!/bin/bash
compare(){
file1="$1"
file2="$2"
count_m=0
count_mn=0
### So sanh phan zmlocalconfig
cat "$file1" "$file2" | grep -E "^zimbra.*"| awk {'print $1'} | sed 's/://' | sort -u | while read -r l;
@hoangdh
hoangdh / install-docker-u18.sh
Last active June 16, 2021 10:21
Install Docker on Ubuntu 18.04
#!/bin/bash
apt-get update -y
apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update -y
@hoangdh
hoangdh / certbot-c7.sh
Created January 22, 2019 04:04
Note Certbot: Install and Usage.
#!/bin/bash
yum install -y epel-release
yum install -y certbot
echo -e "Usage:\nGenerate: certbot certonly --webroot /web/root -d domain.com\nRenew: certbot renew --cert-name"