Auto-Run Script Upon System Boot Up


From PicOS2.9.1, user can add customized scripts which will run automatically upon system boot up.

The script at /cftmp/auto/pre-nos will be started when Linux booting is over. The script at /cftmp/auto/post-xorplus will be launched when XorPlus is ready. And the script at /cftmp/auto/post-ovs will be launched when OVS is ready.

The files pre-nos/ post-xorplus/ post-ovs are not existing in directory /cftmp/auto defaultly. If user want to run the scripts, they need to create them and make sure they are read and write files.


Example 1:

Run script when Linux booting over.

admin@PicOS-OVS$sudo touch /cftmp/auto/pre-nos
admin@PicOS-OVS$sudo chmod 777 /cftmp/auto/pre-nos
admin@PicOS-OVS$sudo vi /cftmp/auto/pre-nos
echo "####################Start add linux scripts####################"
echo "####################Add linux scripts finished####################"
 
admin@PicOS-OVS$sudo reboot
...
...
[ ok ] Starting enhanced syslogd: rsyslogd.
[ ok ] Starting periodic command scheduler: cron.
[ ok ] Starting OpenBSD Secure Shell server: sshd.
####################Start add linux scripts####################
####################Add linux scripts finished####################
Auto Provisioning Tool - checking updates ....
No tftp server address found, exit now
[ ok ] Stopping enhanced syslogd: rsyslogd.
[ ok ] Starting enhanced syslogd: rsyslogd.
[ ok ] Stopping internet superserver: xinetd.
[ ok ] Restarting OpenBSD Secure Shell server: sshd.
[ ok ] Create Inventory database file.
[ ok ] Starting web server: lighttpd.
[ ok ] Starting network snmp: snmpd.
[....] Starting: Open vSwitch/OpenFlowdevice ovs-pica8 entered promiscuous mode
device br0 entered promiscuous mode
. ok 
 
OVS login: 


Example 2:

Run script when OVS is ready.

admin@PicOS-OVS$sudo touch /cftmp/auto/post-ovs
admin@PicOS-OVS$sudo chmod 777 /cftmp/auto/post-ovs
admin@PicOS-OVS$sudo vi /cftmp/auto/post-ovs
echo "Start add ovs scripts"
ovs-vsctl del-br br0
ovs-vsctl add-br br0
ovs-vsctl add-port br0 te-1/1/1
ovs-vsctl add-port br0 te-1/1/2
ovs-vsctl add-port br0 te-1/1/3
ovs-ofctl add-group br0 group_id=1,type=select,bucket=output:2,bucket=output:3
ovs-ofctl add-meter br0 meter=1,kbps,stats,band=type=drop,rate=10000
ovs-ofctl add-flow br0 in_port=1,actions=meter:1,group:1
echo "Add ovs scripts finished"
 
admin@PicOS-OVS$sudo systemctl restart picos
..........................


Example 3:

Run script when Xorplus is ready.

admin@XorPlus$sudo touch /cftmp/auto/post-xorplus
admin@XorPlus$sudo chmod 777 /cftmp/auto/post-xorplus
admin@XorPlus$sudo vi /cftmp/auto/post-xorplus
echo "Start add xorplus scripts"
/usr/bin/cli -c 'configure;
set interface gigabit-ethernet te-1/1/1 crossflow enable true;
set interface gigabit-ethernet te-1/1/1 crossflow local-control false;
set interface gigabit-ethernet te-1/1/2 crossflow enable true;
set interface gigabit-ethernet te-1/1/2 crossflow local-control false;
set interface gigabit-ethernet te-1/1/3 crossflow enable true;
set xovs enable true;
commit'
ovs-vsctl del-br br0
ovs-vsctl add-br br0
ovs-vsctl add-port br0 te-1/1/1
ovs-vsctl add-port br0 te-1/1/2
ovs-vsctl add-port br0 te-1/1/3 -- set interface te-1/1/3 type=crossflow
ovs-ofctl add-group br0 group_id=1,type=select,bucket=output:2,bucket=output:3
ovs-ofctl add-meter br0 meter=1,kbps,stats,band=type=drop,rate=10000
ovs-ofctl add-flow br0 in_port=1,actions=meter:1,group:1
echo "Add xorplus scripts finished"
 

admin@PicOS-OVS$sudo systemctl restart picos
..........................
root@XorPlus> 
Execute command: configure.
Entering configuration mode.
There are no other users in configuration mode.
root@XorPlus# 
Execute command: 
set interface gigabit-ethernet te-1/1/1 crossflow enable true.
root@XorPlus# 
Execute command: 
set interface gigabit-ethernet te-1/1/1 crossflow local-control false.
root@XorPlus# 
Execute command: 
set interface gigabit-ethernet te-1/1/2 crossflow enable true.
root@XorPlus# 
Execute command: 
set interface gigabit-ethernet te-1/1/2 crossflow local-control false.
root@XorPlus# 
Execute command: 
set interface gigabit-ethernet te-1/1/3 crossflow enable true.
root@XorPlus# 
Execute command: 
set xovs enable true.
root@XorPlus# 
Execute command: 
commit
.
Commit OK.
Save done.
root@XorPlus# 
ovs-vsctl: no bridge named br0
device ovs-pica8 entered promiscuous mode
device br0 entered promiscuous mode
Add xorplus scripts finished
admin@XorPlus$


 



Copyright © 2024 Pica8 Inc. All Rights Reserved.