Skip to content

Instantly share code, notes, and snippets.

@edendekker
edendekker / secs_to_human
Last active September 5, 2019 23:06 — forked from 7h3rAm/secs_to_human
Seconds to human readable text.
#!/usr/bin/env python
def sec_to_human(secs):
secs = end_time - start_time
units = dict({
7*24*3600: "week",
24*3600: "day",
3600: "hour",
60: "minute",
1: "second"
@edendekker
edendekker / keep_alive_ipsec
Last active September 6, 2019 01:16
Checks if ipsec connection is established. Restarts it if neccessary.
#!/usr/bin/bash
# Add this script to /etc/crontab
# Set permissions to chmod 100 owner to execute only
#
echo "Keeping alive..."
IPSEC_CONN="iceland-vpn"
IS_UP_IPSEC=$(sudo ipsec status|grep ESTABLISHED|wc -l)
IS_CONNECTING=$(sudo ipsec status|grep "CONNECTING,"|wc -l)
if [[ $IS_CONNECTING -gt 0 ]]
then
@edendekker
edendekker / anti_googleauth_pam_lockout
Last active September 6, 2019 00:43
Delete google pam files that cause the machine to get locked out.
#!/usr/bin/bash
# Add this to /etc/crontab
#
echo "Checking for bad config files..."
BAD_GOOGLE_PAM_FILE=/home/user/.google_authenticator~
HAS_BAD_GOOGLE_PAM_FILE=$(ls $BAD_GOOGLE_PAM_FILE|wc -w)
if [[ $HAS_BAD_GOOGLE_PAM_FILE -eq 1 ]]
then
sudo rm $BAD_GOOGLE_PAM_FILE
echo "Bad config found. Successfully removed."