Here is a short and easy method on how to connect and disconnect an AllstarLink 3 (ASL 3) node on a schedule. You need to leverage the ASL3 asterisk CLI tool (asterisk -rx) inside two basic bash scripts. Then, you map those scripts to system execution times using Linux's built-in crontab utility. Note: I know there are more than one way to effect these connections but here I concentrate on the newcomer to Linux and ASL3.
You will create two lightweight bash scripts that sends a command to your local Asterisk instance telling it to connect or disconnect to your target node at specific times. To instruct Linux to run the scripts automatically at specific times we will be using the cron tasks scheduler utility.
Let's get started.
Prerequisites:
Finding Your Node Numbers
Before
starting, write down your two node numbers. You will need them in the
steps below:
Your
Local Node Number:
The number assigned to your physical AllStarLink 3 hotspot or
server.
The
Target Node Number:
The number of the remote node, reflector, or hub you want to connect
to.
Step
1: Open Your Node Terminal
Open
your terminal program (like PuTTY
on Windows, or Terminal
on a Mac).
Log
into your AllStarLink 3 node using your username and password.
You
should see a command prompt waiting for your input (usually ending
with a $
sign).
Step
2: Create the Morning Connection Script
We
will use a basic text editor inside Linux called nano
to create the morning connection command.
Type
the following command to create a new file named connect.sh
and press Enter:
bash
sudo nano connect.sh
A
blank screen will open. Copy the text below, but replace
<YOUR_NODE>
and <TARGET_NODE>
with your actual node numbers. Do not include the <
>
brackets.
bash
#!/bin/bash
/usr/sbin/asterisk -rx "rpt fun <YOUR_NODE> *3<TARGET_NODE>"
Example
of what it should look like if your node is 1234 and the target is
5678:
/usr/sbin/asterisk
-rx "rpt fun 1234 *35678"
Save
and Close the file:
Press
Ctrl
+ O
on your keyboard (this means "Write Out" / Save).
Press
Enter
to confirm the file name.
Press
Ctrl
+ X
to exit the text editor and return to the main screen.
Give
Permission to Run:
Linux blocks files from running automatically until you give them
permission. Type this command and press Enter:
bash
sudo chmod +x connect.sh
Step
3: Create the Evening Disconnection Script
Now,
we will do the exact same thing to create the command that
disconnects your node.
Type
the following command to create a new file named disconnect.sh
and press Enter:
bash
sudo nano disconnect.sh
Copy
and paste the text below, making the exact same node number
replacements as before:
bash
#!/bin/bash
/usr/sbin/asterisk -rx "rpt fun <YOUR_NODE> *1<TARGET_NODE>"
(Note:
The *3
changed to *1,
which tells AllStarLink to disconnect instead of connect).
Save
and Close the file:
Press
Ctrl
+ O
Press
Enter
Press
Ctrl
+ X
Give
Permission to Run:
Type this command and press Enter:
bash
chmod +x disconnect.sh
Step
4: Find Your Secret "Home Path"
Linux
needs to know the exact folder path where your scripts live so it can
find them later.
Type
this command and press Enter:
bash
pwd
It
will print out a path on your screen. It will look something like
/home/admin
or /root.
Write
this down exactly as it appears.
We will use this in the final step.
Step
5: Schedule the Automation (04:00 to 20:00)
We
will now use the Linux calendar tool called crontab
to schedule your scripts at 04h00
and 20h00.
Type
this command to open the scheduler and press Enter:
bash
crontab -e
(If
Linux asks you to choose an editor, press 1
and hit Enter
to choose nano).
Use
the arrow keys on your keyboard to scroll all the way down to the
very
bottom
of the file.
Paste
the following two lines at the bottom. Replace
/home/yourusername
with the exact path you wrote down in Step 4:
text
0 4 * * * /home/yourusername/connect.sh >/dev/null 2>&1
0 20 * * * /home/yourusername/disconnect.sh >/dev/null 2>&1
Save
and Close the file:
Press
Ctrl
+ O
Press
Enter
Press
Ctrl
+ X
The
terminal will say crontab:
installing new crontab.
Your node will now automatically connect every morning at 04h00 and
cleanly disconnect every evening at 20h00!
Inside crontab -e ,
you can also use three-letter text abbreviations instead of numbers
for the days of the week if it is easier to remember (e.g., SUN,
MON,
TUE,
WED,
THU,
FRI,
SAT).
For
example, a weekend-only entry can look like this: 0
4 * * SAT,SUN
Lets add a bit of "meat" to the above method of connecting and disconnecting an ASL3 Node to another AllStar Node.
An
automated system to connect and disconnect specific nodes at
different times and days
This step-by-step guide will walk you through setting up an
automated system to connect and disconnect specific nodes at
different times and days using cron and Bash scripts.
Overview of How It Works
Instead of creating separate files for every single node, we use
one connection script and one disconnection script.
We pass the specific node ID (like 49355 or 647030)
as an "argument" from the scheduler (cron).
The script reads that number, plugs it into your connection command,
and executes it.
[cron scheduler] ──(sends node ID)──> [connect.sh] ──> Executed for that node only
Step 1: Create the Automation Scripts
We will place these scripts in a folder called scripts
inside your user's home directory.
1. Create the Directory
Open your terminal and run:
Bash
mkdir -p ~/scripts
2. Create the Connection Script
Create and open a new file called connect.sh:
Bash
nano ~/scripts/connect.sh
Paste the following code inside it:
Bash
#!/bin/bash
# 1. Check if the user (or cron) forgot to provide a node number
if [ -z "$1" ]; then
echo "ERROR: No node specified. Usage: $0 <node_id>"
exit 1
fi
# 2. Assign the argument to a readable variable
NODE_ID=$1
echo "=========================================="
echo "STARTING CONNECTION: Node $NODE_ID"
echo "Timestamp: $(date)"
echo "=========================================="
# 3. YOUR CONNECTION COMMAND GOES HERE
# Replace the line below with your actual command.
# Use $NODE_ID wherever the node number needs to go.
echo "Connecting to node $NODE_ID now..."
# Example placeholder (Uncomment and modify if using something like OpenVPN):
# openvpn --config "/home/$USER/vpn/${NODE_ID}.ovpn"
3. Create the Disconnection Script
Create and open a new file called disconnect.sh:
Bash
nano ~/scripts/disconnect.sh
Paste the following code inside it:
Bash
#!/bin/bash
# 1. Check if the user (or cron) forgot to provide a node number
if [ -z "$1" ]; then
echo "ERROR: No node specified. Usage: $0 <node_id>"
exit 1
fi
# 2. Assign the argument to a readable variable
NODE_ID=$1
echo "=========================================="
echo "STOPPING CONNECTION: Node $NODE_ID"
echo "Timestamp: $(date)"
echo "=========================================="
# 3. YOUR DISCONNECT COMMAND GOES HERE
# Replace the line below with your actual command.
echo "Disconnecting node $NODE_ID now..."
# Example placeholder:
# killall openvpn
4. Make the Scripts Executable
Linux security requires you to explicitly grant permission for
scripts to run. Execute this command in your terminal:
Bash
chmod +x ~/scripts/connect.sh ~/scripts/disconnect.sh
Step 2: Test Your Scripts Manually
Before letting the automation take over, test that the scripts
successfully receive your node variables. Run these commands in your
terminal:
Bash
~/scripts/connect.sh 49355
~/scripts/disconnect.sh 49355
You should see an output in your terminal confirming it attempted to
connect to node 49355.
Step 3: Configure the cron Schedule
cron is the built-in Linux background service that
runs tasks at specified times.
1. Open the Cron Editor
Run the following command to edit your personal schedule:
Bash
crontab -e
If it asks you to choose an editor, press 1
for nano (the easiest one).
2. Add Your Node Schedules
Scroll to the very bottom of the file and paste the following
lines exactly as shown.
Important: We use ~/scripts/... to
point to your home directory, and save logs to your home folder
(~/cron_node_...log) to prevent any permission issues.
Code snippet
# ===================================================================
# NODE 49355 SCHEDULE (Fridays)
# ===================================================================
# Connect at 5:00 AM on Friday (Day 5)
0 5 * * 5 /bin/bash /home/USER/scripts/connect.sh 49355 >> /home/USER/cron_49355.log 2>&1
# Disconnect at 8:00 PM (20:00) on Friday (Day 5)
0 20 * * 5 /bin/bash /home/USER/scripts/disconnect.sh 49355 >> /home/USER/cron_49355.log 2>&1
# ===================================================================
# NODE 647030 SCHEDULE (Saturdays)
# ===================================================================
# Connect at 6:00 AM on Saturday (Day 6)
0 6 * * 6 /bin/bash /home/USER/scripts/connect.sh 647030 >> /home/USER/cron_647030.log 2>&1
# Disconnect at 7:00 PM (19:00) on Saturday (Day 6)
0 19 * * 6 /bin/bash /home/USER/scripts/disconnect.sh 647030 >> /home/USER/cron_647030.log 2>&1
3. Critical Adjustment: Fix the Username Path
cron requires absolute system paths to be completely
reliable.
In the text you just pasted, look for /home/USER/.
Replace USER with your actual Linux account
username. (If your username is johndoe, the path
becomes /home/johndoe/scripts/...).
4. Save and Exit
You should see a message saying: crontab: installing new
crontab.
Step 4: Troubleshooting & Monitoring Logs
Because cron tasks run invisibly in the background,
the entries above are designed to output everything they do into
dedicated text files so you can check on them.
To see if your scripts are running smoothly or to view errors,
read your log files using the cat command:
Bash
cat ~/cron_49355.log
cat ~/cron_647030.log
If you ever want to add a third or fourth node in the future, you do
not need to modify your scripts at all. Simply open crontab -e
again and add two new lines with the new node number and your
preferred times.
Comment: Zayn ZR3VO from Orania is currently using this automated connect and disconnect method and he indicated that it is working well.
Images: (Click on images for larger view.)