Skip to content

Erde321/startuprasp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ngrok SSH & Power Control with CallMeBot

Overview

This repository provides a Makefile-based automation system for managing remote SSH access using ngrok and sending connection details via WhatsApp through CallMeBot. Additionally, it includes power-saving and cooling control scripts to optimize energy consumption on a Raspberry Pi.

Features

  • Remote SSH Access: Uses ngrok to expose port 22 for SSH.
  • WhatsApp Notifications: Sends the ngrok connection URL via CallMeBot.
  • Power Management: Monitors SSH activity to toggle power-saving modes.
  • Cooling Control: Manages fan speed based on CPU temperature.

Installation & Setup

Prerequisites

Ensure the following dependencies are installed:

  • Ngrok:
    curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | sudo tee /etc/apt/sources.list.d/ngrok.list && sudo apt update && sudo apt install ngrok
  • jq
  • psutil (Python package)

Clone Repository

git clone https://github.com/Erde321/startuprasp

Configure ngrok

Create an ngrok https://dashboard.ngrok.com/get-started/your-authtoken and enter your Token:

ngrok authtoken <your-ngrok-token>

Set Up CallMeBot

Follow the setup instructions from the CallMeBot repository to configure message sending. The file 'callmebot.py' from CallMeBot-Whatsapp-Signal needs to be in the directory 'callmebot'!

Usage

Start ngrok & Fan Control

make start

This will:

  • Stop any existing ngrok process
  • Start the fan control script
  • Launch ngrok and extract the public SSH address
  • Send the SSH address to a predefined WhatsApp number

Stop ngrok

make stop

This will terminate any running ngrok process.

Enable Automatic Startup

To start the script at boot, add the following cron job:

crontab -e

Add this line:

@reboot cd /path/to/repository && make start &

Power Management

Monitor SSH Connections

The monitor_ssh.py script continuously checks for active SSH/VNC sessions:

  • If a session is detected, normal power mode is enabled.
  • If no session is active, the Raspberry Pi enters power-saving mode.

To start the monitoring script manually:

python powercontrol/monitor_ssh.py

Power Modes

To manually switch power modes, run:

sudo ./powercontrol/pi_power_mode.sh powersave
sudo ./powercontrol/pi_power_mode.sh normal

Fan Control

The fancontrol.sh script adjusts fan speed based on CPU temperature.

Default Temperature Thresholds:

  • 55°C → Low speed (33%)
  • 60°C → Medium speed (66%)
  • 65°C → High speed (100%)

Run the fan control script manually:

sudo ./fancontrol/fancontrol.sh

WhatsApp Messaging

The sendtext.py script sends WhatsApp messages via CallMeBot.

Configuration:

Before using the script, update sendtext.py with your phone number and API token:

Usage:

python sendtext.py 'Your Message Here'

Ensure you have configured your CallMeBot credentials correctly.

License

This project is open-source. Feel free to modify and improve!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors