Skip to content

Instantly share code, notes, and snippets.

View iarp's full-sized avatar

Ian R-P iarp

  • Toronto, Ontario, Canada
View GitHub Profile
@iarp
iarp / gitea file permision correction.sh
Last active April 27, 2022 14:38
Corrects file permission issues on gitea repos after unraid newperms accidental run
cd /mnt/user/repos/
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 755 {} \;
find objects/ -type d -exec chmod 755 {} \;
find info/ -type f -exec chmod 644 {} \;
find refs/ -type f -exec chmod 644 {} \;
find objects/ -type f -exec chmod 444 {} \;
find objects/info/ -type f -exec chmod 644 {} \;
chown -R iarp:1000 ./
chmod 644 HEAD config description
@iarp
iarp / idrac6-virtual-console.sh
Last active May 18, 2022 00:03
Connect to idrac6 virtual console in linux mint 20.3
#!/bin/bash
# {JRE_HOME}\lib\security\java.security and remove RC4 from jdk.tls.disabledAlgorithms
echo -n 'Host: '
read drachost
echo $drachost
echo -n 'Username: '
read dracuser
WIREGUARD_INTERFACE=wg1
WIREGUARD_LAN=10.253.2.0/24
MASQUERADE_INTERFACE=eth0
iptables -t nat -I POSTROUTING -o $MASQUERADE_INTERFACE -j MASQUERADE -s $WIREGUARD_LAN
iptables -N WIREGUARD_INPUT
iptables -N WIREGUARD_DROP_WG0_INPUT
iptables -A INPUT -j WIREGUARD_INPUT
#!/bin/bash
if [ $# -eq 0 ]
then
echo "Need a name for the peer"
exit 1;
fi
GEN_FILE_SAVE_LOCATION="/etc/wireguard/peer_files"
PUBLIC_IP="123.456.789.111:51820"
@iarp
iarp / copy.py
Created October 14, 2019 00:28
Mount, copy floppy, unmount. I needed to copy the contents of 100 floppies and used the following files. Insert floppy, ./copy.sh then eject when done.
import os
import shutil
floppy = '/home/linux/mounts/floppy/'
root = '/home/linux/mounts/family/Floppy_Disks/'
dirlen = len(os.listdir(floppy))
print(dirlen)
if not dirlen:
print('empty')
@iarp
iarp / a_reusable_celery.py
Last active August 26, 2019 16:12
Include celery tasks in a reusable django app without knowing the project name.
from __future__ import absolute_import
import os
from celery import Celery
from django.conf import settings
os.environ.setdefault('DJANGO_SETTINGS_MODULE', settings.SETTINGS_MODULE)
project = '.'.join(settings.SETTINGS_MODULE.split('.')[:-1])
@iarp
iarp / postgres backup.sh
Last active October 3, 2019 00:54
Used to crontab backup a postgres database
TIMESTAMP=$(date +%Y-%m-%d-%H.%M.%S)
TMP_DIR="/tmp"
BACKUP_DIR="/home/iarp/backups"
DATABASE="orhc_tryouts"
USERNAME="orhc_tryouts"
HOSTNAME="localhost"
echo "Backing up $DATABASE"
@iarp
iarp / backup.sh
Last active February 7, 2021 17:52
unraid mirroring script
# trap ctrl-c and call ctrl_c()
trap ctrl_c INT
function ctrl_c() {
exit
}
# check if there are arguments
if (( $# > 0 )); then
@iarp
iarp / celery-beat.conf
Last active March 2, 2018 22:54
Supervisord Setup for django celery worker
[program:celery-beat]
command=/home/iarp/venv-folder/bin/celery -A django_forms beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
directory=/home/iarp/site-root
user=iarp
numprocs=1
stdout_logfile=/home/iarp/celery.beat.log
stderr_logfile=/home/iarp/celery.beat.log
autostart=true
autorestart=true
startsecs=10
@iarp
iarp / ddwrt-delete-traffic.sh
Last active October 10, 2019 02:41
THIS IS AN OLD SCRIPT! I have not used it in many years as I haved moved onto pfSense. The purpose was to remove traffic information from my WRT54GL because the memory had filled up.
#!/bin/sh
# Delete traffic data leaving X number of months, includes current month
# If command line parameter is not provided then default to 1, which keeps current month only
if [ $1 -gt 0 ]; then i=$1; else i=1; fi
# Get current date in a format compatable with the date -d switch
d=`date +%Y.%m.%d-%H:%M`
# Loop back through the calendar X number of months
# each iteration lands at the last day of the previous month
while [ $i -gt 0 ]; do
d=$(date -D %s -d $(( $(date -d $d +%s)-( $(date -d $d +%d)*86400))) +%Y.%m.%d-%H:%M)