Am I still here? This was scheduled long ago.
Today is 20. Am I still here?
run this on cron every 30 */13 - requires preshared ssh key between the webserver and router
#!/bin/bash
exec 3>&1 4>&2
trap 'exec 2>&4 1>&3' 0 1 2 3 RETURN
exec 1>>/var/log/upd-gtssl.log 2>&1
echo "$(date) : Script - start" >&3 # This still shows on console
# make sure this runs every 89 days since the day the cert was renew. (in my case this happen to be "day 59 of a 89 days cycle")
if test $(( $(date +%s)/24/60/60%89 )) = 59; then
echo $(date) - renew cert.
#open port 80 in firewall, so getssl can be confirmed
ssh -x router -q 'iptables -t nat -I PREROUTING -d $(nvram get wan_ipaddr) -p tcp --dport 80 -j DNAT --to-destination webserver:80 && iptables -I FORWARD -p tcp -d webserver --dport 80 -j ACCEPT'
#renew cert
cd /usr/local/etc/getssl/
/usr/local/etc/getssl/getssl mydomain.tld
sleep 10
#close port 80 in firewall, we don't run plain http
ssh -x router -q 'iptables -t nat -D PREROUTING -d $(nvram get wan_ipaddr) -p tcp --dport 80 -j DNAT --to-destination webserver:80 && iptables -D FORWARD -p tcp -d webserver --dport 80 -j ACCEPT'
else
echo $(date) - Cert still good.
fi
@echo off
:: first go get the skus.zip - in the issues are the ones for W11 too
echo [92m Starting conversion to[1;105m LTSC...[0m
:: If not launched as admin, relaunch
net.exe session 2>NUL 1>&2
if not %errorlevel%==0 (echo [91;44;4m You are NOT ADMIN. Relaunching... [0m
powershell Start -File "cmd '/K %~f0 runas'" -Verb RunAs
goto out)
:start
pushd "%CD%"
CD /D "%~dp0"
echo [96m Take ownership of the skus subfolders [0m
"%windir%\system32\takeown.exe" /F "%windir%\system32\spp\tokens\skus\csvlk-pack" /R /A /D Y
"%windir%\system32\icacls.exe" "%windir%\system32\spp\tokens\skus\csvlk-pack" /T /grant Administrators:F
"%windir%\system32\takeown.exe" /F "%windir%\system32\spp\tokens\skus\IoTEnterpriseS" /R /A /D Y
"%windir%\system32\icacls.exe" "%windir%\system32\spp\tokens\skus\IoTEnterpriseS" /T /grant Administrators:F
"%windir%\system32\takeown.exe" /F "%windir%\system32\spp\tokens\skus\IoTEnterpriseSK" /R /A /D Y
"%windir%\system32\icacls.exe" "%windir%\system32\spp\tokens\skus\IoTEnterpriseSK" /T /grant Administrators:F
"%windir%\system32\takeown.exe" /F "%windir%\System32\spp\tokens\EnterpriseS" /R /A /D Y
"%windir%\system32\icacls.exe" "%windir%\system32\spp\tokens\skus\EnterpriseS" /T /grant Administrators:F
echo. [0m
echo [96m Extract and copy the new skus [0m
FOR /F "tokens=1,2,3 delims= " %%A IN ('wmic os get Caption') DO @IF %%C EQU 10 "%windir%\System32\tar.exe" -v -x -f skus10.zip -C %windir%\system32\spp\tokens\skus
FOR /F "tokens=1,2,3 delims= " %%A IN ('wmic os get Caption') DO @IF %%C EQU 11 "%windir%\System32\tar.exe" -v -x -f skus11.zip -C %windir%\system32\spp\tokens\skus
echo [96m Reinstall the new licenses - be patient, this will take a minute [0m
cscript.exe %windir%\system32\slmgr.vbs /rilc
echo [96m Uninstall the actual product key [0m
cscript.exe %windir%\system32\slmgr.vbs /upk
echo [96m Remove the KMS [0m
cscript.exe %windir%\system32\slmgr.vbs /ckms
echo [96m Remove the old product key from registry [0m
cscript.exe %windir%\system32\slmgr.vbs /cpky
echo [96m Install LTSC Product key [0m
:: use key from https://learn.microsoft.com/en-us/windows-server/get-started/kms-client-activation-keys - it requires a KMS Server, otherwise you will have to manually change the license from KMS to MAK
cscript.exe %windir%\system32\slmgr.vbs /ipk M7XTQ-FN8P6-TTKYV-9D4CC-J462D
:end
:: cleanup
del /f /q "skus*.zip" 2>nul
:: check the Windows version
wmic os get Caption | findstr "Microsoft"
echo [96m Now we should reboot... [0;4;1;41m
choice /t 30 /c yn /d n /n /m "press "Y" in the next 30 seconds if you want to reboot"
if errorlevel 2 goto :out
if errorlevel 1 shutdown.exe -r -f -t 0
:out
:: reset the colors
echo.[0m
#Persistent
Menu, Tray, Icon, Shell32.dll, 174
Menu, Tray, Tip, MM-rnd
Menu, Tray, NoStandard
Menu, Tray, Add, Exit, Exit
return
loop {
Random, RandomSleep, 2000, 100000
sleep, %RandomSleep%
mousemove, 10, 0, 10, R
mousemove, -10, 0, 10, R
}
Exit:
ExitApp
#import multiple CSV files into separate Excel worksheets
$wrkfldr='C:\temp'
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $true
$wb = $excel.Workbooks.Add()
Get-ChildItem $wrkfldr\*.csv | ForEach-Object {
if ((Import-Csv $_.FullName).Length -gt 0) {
$csvBook = $excel.Workbooks.Open($_.FullName)
$csvBook.ActiveSheet.Copy($wb.Worksheets($wb.Worksheets.Count))
$csvBook.Close()
}
}
to be run */10 * * * * from cron
#!/bin/bash
wlan='wlan0'
gateway='192.168.1.1'
ping -c2 $gateway 2>&1 >/dev/null; rc=$?
if [[ $rc -eq 0 ]] ; then
echo `date +"%b %d %T "`$0": The network is up."
else
echo `date +"%b %d %T "`$0": Network down! Attempting reconnection."
if [ -f /storage/.cache/nonet ]; then
rm -f /storage/.cache/nonet
reboot
fi
ifdown $wlan
rmmod brcmfmac
sleep 2
modprobe brcmfmac brcmfmac_wcc
ifup --force $wlan
sleep 2
connmanctl connect wifi_dc345a1743d_6e6545675289d3567_managed_psk &>/dev/null
sleep 10
ping -c2 $gateway 2>&1 >/dev/null; rc=$?
if [[ $rc -ne 0 ]] ; then
echo "1" > /storage/.cache/nonet
fi
fi
exit 0