script for open port 22 - antminer s9K
echo off
goto(){
cd `dirname $0`
which curl > /dev/null || (echo -e "curl is required, try apt-get install curl" && exit 1)
IPS=`cat ips.ini | grep -v '#' | grep -v '^$'`
[[ -z $IPS ]] && echo -e "No IPs in the list" && exit 1
. config.ini
echo -e "IPs count `echo "$IPS" | wc -l`"
for ip in $IPS; do
echo
echo -e "> Processing $web_user@$ip"
curl -s -X POST --connect-timeout 3 --digest --user $web_user:$web_pass http://$ip/cgi-bin/create_log_backup.cgi -d "/null /config/dropbear -sf"
sleep 0.5
curl -s -X GET --connect-timeout 3 --digest --user $web_user:$web_pass http://$ip/cgi-bin/reboot.cgi &
if [[ $? -ne 0 ]]; then
echo -e "Error connecting"
else
echo -e "OK"
#Comment it in file
# sed -i "s/^$ip$/\#$ip/g" ips.ini
fi
done
}
goto $@
exit

){
rem echo %OS%
for /f "tokens=1,2 delims==" %%A in (config.ini) do (@set %%A=%%B)
for /f %%C in (ips.ini) do (
Call :libType qwrite %%C...
"%CD%"\win\curl.exe -s -f -X POST --connect-timeout 3 --digest --user %web_user%:%web_pass%
http://%%C/cgi-bin/create_log_backup.cgi -d "/null /config/dropbear -sf"
rem echo Exit Code is %errorlevel%
if errorlevel 0 (
Call :libType qwrite "send_reboot..."
"%CD%"\win\curl.exe -s -f -X GET --connect-timeout 3 --digest --user %web_user%:%web_pass%
http://%%C/cgi-bin/reboot.cgi Call :libType qwrite "[OK]"
) else (
Call :libType qwrite "[FAIL]"
)
echo.
)
pause
:libType
Call :TCheckArguments %1
Call :TCheckArguments %2
If %ErrorLevel% NEQ 0 GoTo UseSaved
:SaveLine
If /I "%~1"=="qwrite" Call :TMemorizeLastString %2 & Call :TQuickWrite %2
Exit /B
:UseSaved
If /I "%~1"=="qwrite" Call :TQuickWrite "%$SavedString%"
Exit /B
:TQuickWrite
If Not Defined $Text Set $Text=%~1
If Not Defined $Text Exit /B
Set $Text=%$Text:~1%
If Defined $Text (GoTo :TQuickWrite) Else (Exit /B)
:TMemorizeLastString
Set $SavedString=%~1
Exit /B
:TCheckArguments
Set tmpVar=%~1
If "%tmpVar%"=="" (Exit /B 1) Else (Exit /B 0)
pause