Skip to content

Instantly share code, notes, and snippets.

@lemajes
lemajes / rsync-exclude.sh
Last active March 28, 2019 10:33
[Rsync Epp] rsync exclude folder #linux #backup #script #exclude #fromto
#!/bin/bash
# for exclude, use relative path from source path
# cd into source path
# use --ignore-existing to write only new files
cd /home/source
rsync -avrP --progress --info=progress2 ./ user@backup:/home/dest/ --exclude 'notthisrelativefolder'
@lemajes
lemajes / ansible-cmd-exec.sh
Last active August 9, 2018 09:26
[Ansible Cmd Exec] execute command on terminal through ansible #linux #ansible #command #terminal
#!/bin/bash
ansible hosts -a "apt-get update"
@lemajes
lemajes / install-letsencrypt.sh
Last active August 21, 2018 09:34
[Install Letsencrypt] install letsencrypt on servers that cannot install it from sources #linux #install # script #letsencrypt #certbot
#!/bin/bash
apt-get install git -y
git clone https://github.com/letsencrypt/letsencrypt /usr/local/letsencrypt
cd /usr/local/letsencrypt
./letsencrypt-auto --help
sudo -H ./letsencrypt-auto certonly --standalone -d example.com -d www.example.com
@lemajes
lemajes / mysqldump-remote.sh
Last active August 9, 2018 09:26
[Mysqldump From Remote] dump database from remote sql server #linux #script #mysql #dump
#!/bin/bash
mysqldump -u <USER> -h <DBHOST> -p <BDD> > bdddump.sql
@lemajes
lemajes / clientsite.sh
Last active August 9, 2018 09:25
[Add Ssh User And Keyfile Login] Add a ssh user and authorize him to use key authentification only #linux #bash #script #ssh #keyfile
#!/bin/bash
useradd -m -d /home/myuser /bin/bash myuser
su - myuser
ssh-keygen
chown -R myuser /home/myuser
chmod 600 /home/myuser/.ssh/id_rsa
ssh-copy-id [email protected]
@lemajes
lemajes / php-error-finder.sh
Last active August 6, 2018 15:23
[Find Error Finder] Find php errors in webfolders #linux #web #php #script #find #error
#!/bin/bash
find . -name \*.php -type f -exec php -l {} \;
@lemajes
lemajes / msqy-db-collation-corrector.sh
Last active July 30, 2018 14:15
[MySQL utf8 error] Correct collation error when importing .sql file into database #linux #mysql #patch #utf8
#!/bin/bash
DBNAME=""
sed -i 's/utf8mb4/utf8/g' $DBNAME
sed -i 's/utf8_unicode_ci/utf8_general_ci/g' $DBNAME
sed -i 's/utf8_unicode_520_ci/utf8_general_ci/g' $DBNAME
@lemajes
lemajes / zabbix-server-installer.sh
Last active July 30, 2018 10:32
[Zabbix Server Installer] Install zabbix server for debian stretch #linux #script #install #zabbix #server #debian #stretch
#!/bin/bash
PASSWORD=""
wget https://repo.zabbix.com/zabbix/3.4/debian/pool/main/z/zabbix-release/zabbix-release_3.4-1+stretch_all.deb
dpkg -i zabbix-release_3.4-1+stretch_all.deb
apt update
apt install zabbix-server-mysql
apt install zabbix-frontend-php
mysql -e "create database zabbix character set utf8 collate utf8_bin;"
mysql -e "grant all privileges on zabbix.* to zabbix@localhost identified by "$PASSWORD";"
wget https://freefr.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.11/zabbix-3.4.11.tar.gz
@lemajes
lemajes / wp-cli-deployer.sh
Last active July 22, 2021 08:51
[Wp-Cli Deployer] Deploy WP-CLI on remote servers #linux #server #wordpress #wp-cli #terminal #script #bash
#!/bin/bash
cd /opt ;curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar;ln -s /opt/wp-cli.phar /usr/bin/wp ; chmod +x /usr/bin/wp
@lemajes
lemajes / install-softether-server.sh
Last active July 28, 2018 03:24
[Install Softether Server] Download compile and install SoftEther VPN Server #linux #script #install #softether #vpn #server
#!/bin/bash
apt -y install cmake gcc libncurses5-dev libreadline-dev libssl-dev make zlib1g-dev git
wget https://www.softether-download.com/files/softether/v4.27-9668-beta-2018.05.29-tree/Linux/SoftEther_VPN_Server/64bit_-_Intel_x64_or_AMD64/softether-vpnserver-v4.27-9668-beta-2018.05.29-linux-x64-64bit.tar.gz
mkdir /opt/softether
mv softether-vpnserver-v4.27-9668-beta-2018.05.29-linux-x64-64bit.tar.gz /opt/softether
cd /opt/softether
tar xf softether-vpnserver-v4.27-9668-beta-2018.05.29-linux-x64-64bit.tar.gz
cd vpnserver
./configure
make