Skip to content

Instantly share code, notes, and snippets.

View wannadrunk's full-sized avatar

WannaDrunk wannadrunk

  • Earth
View GitHub Profile
@wannadrunk
wannadrunk / dbbak.sh
Last active January 27, 2022 00:23
Bash script to dump the Postgresql DB and send the notification to LINE Notify
#!/bin/bash
### Author: cHoo
### Date: August 2019
### Description: Script to dump database.
### Version:
#### 1.01 - update messages.
#### 1.10 - 20210912 backup file size.
# Import global variable in this setting-global is consisting of LINE API key
CONFLE="/opt/scripts/setting-global.ini"
@wannadrunk
wannadrunk / chkspace.sh
Created September 4, 2021 04:27
Bash script to check the diskspace and send the notification to LINE.
#!/bin/bash
### Author: cHoo
### Date: September 2019
### Version: 1.0
### Description: Check diskspace used and alert if used up to 90%
#
# Import global variable
#
CONFLE="/opt/scripts/setting.ini"
if [ -f $CONFLE ]
@wannadrunk
wannadrunk / dailysync.sh
Last active April 29, 2021 01:32
Bash script to download the backup file from hosts.
#!/bin/bash
### Author: cHoo
### Date: August 2019
### Description:
### Version:
### 1.0 - initial first release
#
# Import global variable
#
CONFLE="/opt/scripts/setting-global.ini"
@wannadrunk
wannadrunk / chk_temp.sh
Last active September 16, 2021 07:09
Bash script to check the temperature on Raspberry Pi
#!/bin/bash
while :
do
LOGTIME=`date '+%Y-%m-%d_%H:%M:%S'`
TEMPDEG=`/usr/bin/vcgencmd measure_temp`
VOLTS=`/usr/bin/vcgencmd measure_volts`
echo "$HOSTNAME $LOGTIME $VOLTS $TEMPDEG"
sleep 5
done
@wannadrunk
wannadrunk / sources.list
Created March 5, 2020 10:18
/etc/apt source list for Raspbian 10 Buster
deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
deb http://archive.raspberrypi.org/debian/ buster main
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
@wannadrunk
wannadrunk / shutondate.sh
Last active February 20, 2020 12:21
Bash script to shutdown the system as date in shutdown.txt. Date format in shutdown.txt is 'yyyymmdd'
#!/bin/bash
TODAY=`date '+%Y%m%d'`
read -r SHUTDAY < shutdown.txt
echo $SHUTDAY
if [ "$SHUTDAY" == "$TODAY" ]
then
sudo reboot
else
echo 'not reach the time yet'
@wannadrunk
wannadrunk / convert_sec2HMS.sh
Last active February 10, 2020 11:27
Bash script to convert total seconds to H:M:s
#!/bin/bash
# Convert from total seconds to H:M:s
RUNTIME=$1
RUNSEC=$(($RUNTIME%60))
RUNMIN=$(((($RUNTIME - $RUNSEC)/60)%60))
RUNHRS=$(($RUNTIME/3600))
echo $RUNHRS:$RUNMIN:$RUNSEC
@wannadrunk
wannadrunk / smb.conf
Last active January 31, 2020 14:48
Samba config on Raspbian. [medias] read-only with guest access. Accessible only LAN IP
[global]
workgroup = WORKGROUP
log file = /var/log/samba/log.%m
max log size = 1000
logging = file
panic action = /usr/share/samba/panic-action %d
server role = standalone server
obey pam restrictions = yes
unix password sync = yes
passwd program = /usr/bin/passwd %u
@wannadrunk
wannadrunk / search.py
Last active January 27, 2020 19:23
Python Search in list
names = ['1','2','a','b']
# test or proof of concept
print('0' in names)
print('a' in names)
search = 'xxx'
if search in names:
print('Found')
else:
@wannadrunk
wannadrunk / chkport.sh
Last active October 14, 2021 00:15
Script to check network port service status
#!/bin/bash
### Author: cHoo
### Date: September 2019
### Description: Script to check host port
### Version:
#### 1.0 - initial
### Syntax
#### chkport.sh hostaddress port [servicename]
#### Ex. chkport.sh 192.168.1.1 80 http