kraloveckey / asus-router

πŸ’€ Simple shell scripts for Asus router that improve and simplify the work with samba, cron, firewall, torrents, telegram.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ASUS-Router

"Buy Me A Coffee"

Telegram Channel

Replace the default Samba smb.conf file with a customized configuration file, then kill, restart the smbd daemon and add firewall rules. Designed to be run at boot time, on a router with an attached USB storage drive.

Out of the box, the Asus TUF-AX5400 router has some handy, but limited, file and media sharing capabilities. Connect a USB hard drive to its USB port and the router can share data from that drive with anyone on your network. The firmware implements Samba, but through the GUI you have only two options: allow anonymous guests complete access, or require a username and password for every connection. Samba can be configured far more granularly, but you cannot get there from the router web interface. This script automates replacing the stock configuration file with one customized to the owner's preference and add firewall rules for access to Samba from Internet (by custom port).

Requirements:

  • Runs on an Asus wireless router using default firmware.
  • This only works if a USB drive is attached.

Usage:

Store smb.sh to /jffs on the router:

chmod 755 /jffs/smb.sh

Modify smb.conf to suit your preference, then store to /jffs:

chmod 644 /jffs/smb.conf
nvram show | grep script_usbmount
nvram set script_usbmount="/jffs/smb.sh"
nvram commit

Upon either rebooting, or disconnecting/reconnecting the USB drive, the script will execute, kill all existing smbd processes, copy the custom configuration file into place, restart smbd with the custom conf file and add firewall rules.

Cron

Cron is the well-known method of scheduling tasks for Unix, the equivalent of "at" on Windows. My purpose is not to document the use of cron - it is well documented elsewhere. Alas, ASUS does not include the crontab utility for creating and editing jobs in its firmware, but the cron daemon (crond) is installed and running. If a jobs file can be loaded into the daemon, crond will happily run the jobs.

A lesser documented standard feature in crond is to watch the directory /var/spool/cron/crontabs/ for a file listing jobs to run. Ordinarily you should not modify files in this directory manually - that's what crontab is for - but absent crontab one can still manually edit a file and place it in this folder.

For instance, if I create a file with the following contents, and copy it to /var/spool/cron/crontabs/<admin user name>, it will run the job.sh script every 5 minutes:

# cron jobs to import into root's crontab
*/5 * * * * /jffs/job.sh

Simple and sweet.

For our purposes, /jffs/scriptname contains the following line to copy a cron file from persistent storage into the folder watched by crond:

cp /jffs/<admin user name> /var/spool/cron/crontabs

About

πŸ’€ Simple shell scripts for Asus router that improve and simplify the work with samba, cron, firewall, torrents, telegram.

License:MIT License


Languages

Language:Shell 100.0%