Last active
June 1, 2025 01:00
-
-
Save cjamcu/c956eb86331e6800b9d8b718d768fabb to your computer and use it in GitHub Desktop.
curl -sSL https://gist.githubusercontent.com/cjamcu/c956eb86331e6800b9d8b718d768fabb/raw/f33a98824bc01244b42aa27f2396274102689ef3/install-routeros.sh | sudo bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script to install RouterOS without VNC requirement | |
# WARNING: This script will COMPLETELY REMOVE Ubuntu | |
set -e | |
echo "=== RouterOS Automated Installation Script ===" | |
echo "β οΈ WARNING: This will completely replace Ubuntu!" | |
echo "Press Ctrl+C now to cancel or any key to continue..." | |
read -n 1 -s | |
# Install required tools | |
echo "π¦ Installing required tools..." | |
apt update -qq | |
apt install -y unzip wget | |
# Get current system information | |
MAIN_INTERFACE=$(ip route | grep default | awk '{print $5}' | head -n1) | |
CURRENT_IP=$(ip addr show $MAIN_INTERFACE | grep 'inet ' | awk '{print $2}' | head -n1) | |
GATEWAY=$(ip route | grep default | awk '{print $3}' | head -n1) | |
MAIN_DISK=$(lsblk -dn -o NAME | head -n1) | |
echo "Detected configuration:" | |
echo "- Interface: $MAIN_INTERFACE" | |
echo "- Current IP: $CURRENT_IP" | |
echo "- Gateway: $GATEWAY" | |
echo "- Main disk: /dev/$MAIN_DISK" | |
# Validate that we have the necessary information | |
if [ -z "$CURRENT_IP" ] || [ -z "$GATEWAY" ] || [ -z "$MAIN_DISK" ]; then | |
echo "β Error: Could not detect network configuration" | |
exit 1 | |
fi | |
# Download RouterOS | |
echo "π₯ Downloading RouterOS..." | |
cd /tmp | |
wget -q https://download.mikrotik.com/routeros/7.16/chr-7.16.img.zip -O chr.img.zip | |
# Extract image | |
echo "π¦ Extracting RouterOS image..." | |
unzip -q chr.img.zip | |
# Final message before installation | |
echo "π¨ LAST WARNING: Ubuntu will be completely replaced!" | |
echo "Network config: $CURRENT_IP via $GATEWAY" | |
echo "πΎ Writing RouterOS to disk..." | |
# Write image to disk | |
dd if=/tmp/chr-7.16.img of=/dev/$MAIN_DISK bs=1M status=progress | |
# Sync disk | |
echo "π Syncing disk..." | |
sync | |
echo "β RouterOS installation completed!" | |
echo "π Access information:" | |
echo " IP: ${CURRENT_IP%/*}" | |
echo " Default user: admin (no password)" | |
echo " SSH: ssh admin@${CURRENT_IP%/*}" | |
echo "" | |
echo "π Rebooting now..." | |
# Restart system | |
reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment