
These scripts start one another, as a workaround for systemd , corestarter and Termux boot go hand in hand to make script run all the time in background scrips works by spawning one another sequentially corestarter -> initProcess -> goLive ->initRVP
27 lines
753 B
Bash
27 lines
753 B
Bash
|
|
|
|
|
|
# Count the number of devices connected via ssh on port 8022
|
|
netstatcount=$(netstat | grep ':8022' | grep 'ESTABLISHED' | wc -l)
|
|
tempcount=$((netstatcount - netstatcount / 2))
|
|
actualcount=$((tempcount - 1))
|
|
|
|
# Use that count to decide the process flow
|
|
if [ $tempcount -eq 0 ]; then
|
|
|
|
#starts Reverse Port Forwarding when 0 devices where connected every 10 min once
|
|
if [ $actualcount -eq -1 ]; then
|
|
bash /data/data/com.termux/files/home/.custmScrpt/goLive.sh
|
|
fi
|
|
fi
|
|
|
|
# Create logs
|
|
log1=$(netstat | grep ':8022')
|
|
log2=$(date)
|
|
log3=$(date +"%Y%m%d_%H%M%S")
|
|
concatenatedLog="$log1 and $log2"
|
|
|
|
# Save the logs to a file
|
|
mkdir -p ~/.ssh_logs # Create the directory if it doesn't exist
|
|
echo "$concatenatedLog" > ~/.ssh_logs/"$log3".txt
|