Skip to content

Instantly share code, notes, and snippets.

View zGrav's full-sized avatar

David Silva zGrav

View GitHub Profile
#!/bin/bash
if command -v jq >/dev/null 2>&1; then
echo "jq parser found";
else
echo "this script requires the 'jq' json parser (https://stedolan.github.io/jq/).";
exit 1;
fi
if [ -z "$1" ]
then
@zGrav
zGrav / monit_disk.sh
Created February 9, 2018 08:25
disk monitoring + mail
#!/bin/bash
CURRENT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g')
THRESHOLD=90
if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
mail -s 'Disk Space Alert' [email protected] << EOF
Your root partition remaining free space is critically low. Used: $CURRENT%
EOF
fi
@zGrav
zGrav / wget_ftp.sh
Created February 8, 2018 22:50
wget_ftp.sh
wget -r -nH --cut-dirs=x ftp://xxx
@zGrav
zGrav / lastlog_bash_clear.sh
Created February 8, 2018 17:58
clear lastlog and bash_history
cat /dev/null > /var/log/lastlog && cat /dev/null > ~/.bash_history && history -c && exit
@zGrav
zGrav / curlup_log.sh
Created February 8, 2018 15:57
curlup_log
#!/bin/bash
LOG_FILE=/tmp/curlup_log.log
find mydir -type f -exec curl -u xxx:psw --ftp-create-dirs -T {} ftp://xxx/{} \; 2>&1 | tee ${LOG_FILE}
@zGrav
zGrav / curlup.sh
Created February 8, 2018 15:46
curlup
find mydir -type f -exec curl -u xxx:psw --ftp-create-dirs -T {} ftp://xxx/{} \;
@zGrav
zGrav / ovh-bk.sh
Last active October 21, 2020 09:46
#!/bin/bash
#
# Backing up the OVH server, checking the archive and sending it through FTP
#
BACKUPHOME=/home/backups
FTPUSER=ftpbackupser
FTPPASS=S0m3Th1nGH4rD
FTPSERVER=ftp.server.com
SERVER=youservername
@zGrav
zGrav / .htaccess
Created February 8, 2018 09:49
rosafgit
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^OLDDOMAIN\.com$ [NC]
RewriteRule ^(.*)$ http://NEWDOMAIN.com [R=301,L]
@zGrav
zGrav / jst.c
Last active January 27, 2018 15:26
#include <stdbool.h>
bool isvalueinarray(string val, int *arr, int size){
int i;
for (i=0; i < size; i++) {
if (arr[i].nome == val)
return true;
}
return false;
}
@zGrav
zGrav / jeremy.js
Created January 16, 2018 18:12
jeremy.js
const fs = require('fs');
(function() {
const file = '/tmp/file.txt';
const unlink = function() {
return new Promise((resolve, reject) => {
fs.unlink(file, function(e) {
if (e) { return reject(e); }
return resolve();