Skip to content

Instantly share code, notes, and snippets.

View wannadrunk's full-sized avatar

WannaDrunk wannadrunk

  • Earth
View GitHub Profile
@wannadrunk
wannadrunk / mt-nt-pri-pub
Last active October 13, 2023 01:57
Mikrotik script to reconnect the pppoe when get the private/nat IP from ISP, keep trying to get a public ip.
# Don't forget to change the "wanInterface" value below to your PPPoE interface
:global reconnectCount;
:local wanInterface "pppoe-out1";
:if ($"local-address" in 100.64 .0.0/10) do={
:if ($reconnectCount < 10) do={
:set reconnectCount ($reconnectCount+1);
:log warning ("$wanInterface: Got Private IP ".$"local-address"." Reconnecting the interface...");
@wannadrunk
wannadrunk / mt-nt-pub-cf-ddns.src
Last active September 14, 2023 11:53
MikroTik script to loop the pppoe connection until it get the public IP, not NAT IP. And then update the DNS A record on CloudFlare Name Server.
# Mikrotik Script for loop until get the public IP from NT
# and then set DNS A record to that public IP.
#
# Update WANIF to match your interface name. And all CloudFlare required key and info.
#
# Put this into the ppp profile UP script and assign to pppoe connection
#
:local WANIF "pppoe-1";
@wannadrunk
wannadrunk / reconnectnatip.src
Last active September 14, 2023 14:32
Mikrotik Script to reconnect the pppoe that get the NAT IP. Some ISP provide both public and NAT IP to subscriber. Create a ppp profile and put this script in On Up section. Update the wanInterface according to yours.
:global reconnectCount;
:local wanInterface "pppoe-out1";
:while ( $"local-address" in 100.64.0.0/10 ) do={
:log warning ("$wanInterface: Got Private IP ".$"local-address"." Reconnecting the interface...");
/interface pppoe-client disable $wanInterface;
:delay 10s;
/interface pppoe-client enable $wanInterface;
};
:log info ("$wanInterface: Got IP ".$"local-address");
@wannadrunk
wannadrunk / UnifiController.txt
Created May 2, 2023 11:43
UniFi Controller on Debian based.
#=== Unifi Controller ===
# Add this line to apt source list
deb http://archive.raspbian.org/raspbian stretch main contrib non-free rpi
# add key
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9165938D90FDDD2E
# download installer
wget https://dl.ui.com/unifi/7.3.83/unifi_sysvinit_all.deb
@wannadrunk
wannadrunk / rcln-bak.sh
Last active December 10, 2022 08:31
Bash script to send a notification to Telegram when the rclone COPY/SYNC finish. Script requires `Telegrame Key` and `Chat id`.
#!/bin/bash
### Date: December 2022
### Description: Script to send a notification to Telegram about the RCLONE status.
### Version:
#### 0.1 - initial release
#
# Import global variable
#
@wannadrunk
wannadrunk / loop-test.sh
Created November 18, 2022 05:58
bash script to display the ASCII Art text file. Source of ASCII Art from https://www.asciiart.eu/
#!/bin/bash
clear
while :
do
cat cowfile | cowsay
inxi -F
sleep 3
for TXTFILE in *.txt; do
cat $TXTFILE
@wannadrunk
wannadrunk / db.py
Created March 17, 2022 03:18
SAMPLE SQLAlchemy connect to existing DB/Tables
from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine, MetaData, Table
# Using SQLAlchemy reflection example
engine = create_engine('connectionstringhere')
table1meta = MetaData(engine)
table1 = Table('Table_I_Want_to_Interact', table1meta, autoload=True)
DBSession = sessionmaker(bind=engine)
session = DBSession()
results = session.query(table1).filter(table1.columns.TimeStamp>="2019-02-26 18:00:00.000")
@wannadrunk
wannadrunk / syslog-mikrotik.conf
Last active February 24, 2022 15:26
Mikrotik log to syslog-ng - Line 4, update the IP address of your Mikrotik.
# MikroTik – Syslog
source s_mikrotik { udp(port(514)); };
destination d_mikrotik { file("/var/log/mikrotik.log"); };
filter f_mikrotik { host("192.168.88.1"); };
log { source(s_mikrotik); destination(d_mikrotik); filter(f_mikrotik); };
@wannadrunk
wannadrunk / debian-preseed.txt
Created November 25, 2021 19:01
Preseed sample
#_preseed_V1
#### Contents of the preconfiguration file (for bullseye)
### Localization
# Preseeding only locale sets language, country and locale.
d-i debian-installer/locale string en_US
# The values can also be preseeded individually for greater flexibility.
#d-i debian-installer/language string en
#d-i debian-installer/country string NL
#d-i debian-installer/locale string en_GB.UTF-8
@wannadrunk
wannadrunk / reverse RPi WiFi AP.md
Created November 24, 2021 07:14
refer to a few instruction to setup RPi as the WiFi AP, here is how to remove it.

Remove the packages

sudo apt purge hostapd dnsmasq

Remove all settings

if these setting files are existed, here is how to roll back

/etc/dhcpcd.conf