This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# how to send emails, with attachments, from linux command line, using gmail as relay server | |
# you need to allow insecure apps: https://support.google.com/accounts/answer/6010255 | |
sudo apt-get install -y libnss3-tools heirloom-mailx | |
mkdir ~/.certs | |
certutil -N --empty-password -d ~/.certs | |
echo -n | openssl s_client -connect smtp.gmail.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/gmail.crt | |
certutil -A -n "Google Internet Authority" -t "C,," -d ~/.certs -i ~/.certs/gmail.crt | |
# now create a new config file (example: nano $HOME/.mailrc) containing the following lines - change USER and PASSWORD as you need: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create a conf file (/etc/rsyslog.d/10-mylog.conf) as follows | |
# then restart rsyslog: sudo /etc/init.d/rsyslog restart | |
# in this example, i search log entries for the word "sda" | |
# and log in text format in /var/log/hdt.log and in json in /var/log/hdj.log | |
module(load="mmjsonparse") | |
template(name="json-template" | |
type="list") { | |
constant(value="{") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first part, enlarge partition to 100% | |
sudo apt-get install -y -qq parted | |
ROOT_DISK=$(sudo lsblk -s|grep -A1 \/$|grep -v \/$|tr -d "└─"|cut -d\ -f 1) | |
PART_NUM=$(sudo parted -l $ROOT_DISK|grep ext4|sed "s/^[ \t]*//"|cut -d\ -f 1) | |
sudo parted -s /dev/$ROOT_DISK unit % resizepart $PART_NUM 100% || sudo parted /dev/$ROOT_DISK unit % resizepart $PART_NUM Yes 100% | |
touch /forcefsck | |
sudo reboot | |
# second part, enlarge inside filesystem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd | |
# useful vars | |
DATE=$(date +"%Y%m%d%H%M") | |
WHERE=~/backup/$DATE | |
# create dated backup folders | |
mkdir -p $WHERE/{sqlite,nodered,etc} | |
# safely backup sqlite db | |
sqlite3 ~/dbs/iot.db ".backup $WHERE/sqlite/iot.db" | |
# backup json and js files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run this on a Debian Buster system setup by Peter Scargill's "The Script" to replace APACHE with NGINX, AFTER his script run... | |
# completely replace apache for nginx | |
sudo apt-get -y remove --purge *apache* *php* | |
sudo apt-get -y autoremove | |
sudo apt-get -y install nginx sqlite3 php php7.3-{common,cli,fpm,json,zip,gd,mbstring,curl,xml,bcmath,sqlite3} php-pear | |
# sudo apt-get -y install php7.3-pear # a line on its own as it caused instal issues to some... | |
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak | |
sudo sed -i -e 's/index index.html/index index.php index.html/g' /etc/nginx/sites-enabled/default | |
sudo sed -i -e 's/#location ~ \\.php$ {/location ~ \\.php$ {/g' /etc/nginx/sites-enabled/default | |
sudo sed -i -e 's/#.*include snippets/ include snippets/g' /etc/nginx/sites-enabled/default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run this AFTER this script: https://gist.github.com/fragolinux/7229c1785652e4598d0bb61e50aa9093#file-nginx4apache | |
# to add reverse proxy functionalities to same system... this way you'll have: | |
# grafana, from ip:3000 to ip/grafana | |
# nodered and its dashboard, from ip:1880 to ip/nodered and ip/ui | |
# chronograf, from ip:8888 to ip/chronograf | |
# if you change Nginx default port, all the above will change accordingly (example: web on http://ip:81 then nodered on http://ip:81/nodered) | |
# reverse proxy for grafana, from ip:3000 to ip/grafana | |
sudo sed -i -e 's#;root_url = http://localhost:3000#root_url = http://localhost:3000/grafana/#g' /etc/grafana/grafana.ini | |
sudo sed -i -e '71i\\n location /grafana/ {\n proxy_pass http://localhost:3000/;\n }\n' /etc/nginx/sites-enabled/default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt -y update | |
sudo apt -y install apt-transport-https ca-certificates curl gnupg2 gnupg-agent software-properties-common | |
curl -sL get.docker.com | sudo sh | |
# if your default user is not "pi", change next line | |
sudo usermod -aG docker pi | |
sudo apt -y install docker-compose | |
# open new putty session, or logout and login again | |
docker -v && docker-compose -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
################################# | |
# Speech Script by Dan Fountain # | |
# [email protected] # | |
################################# | |
INPUT=$* | |
STRINGNUM=0 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a couple of sensors and a lovelace card to show latest tasmota info in HA | |
if you don't like the colors, change them in the CSS code at line 14 :-) | |
------------- in configuration.yaml ------------- | |
# Sensors | |
sensor: | |
- platform: command_line | |
name: Tasmota Dev | |
command: 'curl -s https://raw.githubusercontent.com/arendst/Tasmota/development/tasmota/CHANGELOG.md|grep -m 1 "###"|cut -c 5-|cut -d\ -f1' | |
scan_interval: 3600 | |
# note: the following sensor will not produce output in HA itself, but creates a local file which will be included in a custom lovelace card |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## direnv enabler script, inspired by "basher" install script | |
die() { | |
echo "!! $1 " >&2 | |
echo "!! -----------------------------" >&2 | |
exit 1 | |
} | |
## stop if direnv is not installed |