-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2806946
commit b9de250
Showing
8 changed files
with
312 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
# | ||
logger -st "($(basename $0))" $$ "*--------- ENTWARE FOR ASUS ROUTER INSTALLATION ---------*" | ||
# | ||
########## INSTALLATION PREPARATION ########## | ||
# | ||
# Check type of the ASUS Router | ||
# 检查华硕路由器型号 | ||
router_type=$(nvram get model) | ||
# | ||
# Install Entware according to the type of the ASUS Router | ||
# 安装适合于特定型号路由器的Entware版本 | ||
if [ $router_type == 'RT-AC68U' ] || [ $router_type == 'RT-AC56U' ] || [ $router_type == 'RT-AC87U' ] || [ $router_type == 'RT-AC3200' ] || [ $router_type == 'RT-AC88U' ] || [ $router_type == 'RT-AC3100' ] || [ $router_type == 'RT-AC5300' ] | ||
then | ||
wget -O - http://bin.entware.net/armv7sf-k2.6/installer/generic.sh | sh | ||
fi | ||
# | ||
if [ $router_type == 'RT-AC86U' ] | ||
then | ||
wget -O - http://bin.entware.net/aarch64-k3.10/installer/generic.sh | sh | ||
fi | ||
# | ||
if [ $router_type == 'RT-AC66U' ] || [ $router_type == 'RT-N66U' ] || [ $router_type == 'RT-N16' ] | ||
then | ||
wget -O - http://pkg.entware.net/binaries/mipsel/installer/installer.sh | sh | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/sh | ||
# | ||
# 此脚本用于安装“华硕路由器开机自动运行脚本系统” | ||
# | ||
logger -st "($(basename $0))" $$ "*--------- SCRIPTS BOOTLOADER FOR ASUS ROUTER INSTALLATION ---------*" | ||
# | ||
########## ROUTER CONFIGURATION ########## | ||
# | ||
# Check if /tmp/mnt/sda1/script_bootloader/script_bootloader_usb_mount and /tmp/mnt/sda1/script_bootloader/script_bootloader_usb_umount exist | ||
# 检查/tmp/mnt/sda1/script_bootloader/script_bootloader_usb_mount和/tmp/mnt/sda1/script_bootloader/script_bootloader_usb_umount文件是否存在 | ||
if [ -e "/tmp/mnt/sda1/script_bootloader/script_bootloader_usb_mount" ] && [ -e "/tmp/mnt/sda1/script_bootloader/script_bootloader_usb_umount" ] | ||
then | ||
logger -st "($(basename $0))" $$ "***** ALL THE ESSENTIAL FILES EXIST *****" | ||
logger -st "($(basename $0))" $$ "***** SETTING THE ROUTER *****" | ||
# | ||
# Set nvram variable "script_usbmount" and "script_usbumount" | ||
# 如果两个文件都存在,则设置nvram变量script_usbmount和script_usbumount | ||
# | ||
# When a flash disk is mounted, the script "script_bootloader_usb_mount" will run automatically | ||
# 当U盘被挂载后,脚本script_bootloader_usb_mount会自动运行 | ||
# 使用nvram对变量script_usbmount进行设置。当U盘被挂载后,任何被该变量引用的可执行脚本会自动执行。本例中,设置该变量引用脚本/tmp/mnt/sda1/script_bootloader/script_bootloader_usb_mount | ||
nvram set script_usbmount="/tmp/mnt/sda1/script_bootloader/script_bootloader_usb_mount" | ||
# | ||
# When a flash disk is unmounted, the script "script_bootloader_usb_umount" will run automatically | ||
# 当U盘被卸载前,脚本script_bootloader_usb_umount会自动运行 | ||
# 使用nvram对变量script_usbumount进行设置。当U盘被卸载前,任何被该变量引用的可执行脚本会自动执行。本例中,设置该变量引用脚本/tmp/mnt/sda1/script_bootloader/script_bootloader_usb_umount | ||
nvram set script_usbumount="/tmp/mnt/sda1/script_bootloader/script_bootloader_usb_umount" | ||
# | ||
# Commit the changes | ||
# 使用nvram命令对路由器进行设置后,必须执行nvram commit命令,才能将已作出的修改保存至路由器 | ||
nvram commit | ||
logger -st "($(basename $0))" $$ "***** INSTALLATION HAS BEEN COMPLETE *****" | ||
# | ||
# Reboot the router | ||
# 需使用reboot命令重启路由器,确保设置生效 | ||
logger -st "($(basename $0))" $$ "***** REBOOTING THE ROUTER *****" | ||
reboot | ||
# | ||
else | ||
# Stop and Exit | ||
# 如果两个文件不同时存在,则该脚本终止 | ||
logger -st "($(basename $0))" $$ "***** UNABLE TO LOCATE THE ESSENTIAL FILES *****" | ||
logger -st "($(basename $0))" $$ "***** INSTALLATION HAS NOT BEEN COMPLETE *****" | ||
logger -st "($(basename $0))" $$ "***** EXIT *****" | ||
exit 1 | ||
fi | ||
# | ||
########## END ########## |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/bin/sh | ||
# | ||
# 此脚本用于在确认路由器已经成功启动后,执行用户自定义脚本列表,并准备Entware运行环境 | ||
# | ||
logger -st "($(basename $0))" $$ "***** BOOTING UP ASUS ROUTER (300 SECONDS) *****" | ||
# | ||
########## CHECK ASUS ROUTER STATUS ########## | ||
# | ||
# Check if the router is ready for running user's custom scripts | ||
# 检查路由器是否已经准备好执行用户自定义脚本 | ||
# | ||
# Check it out every 30 seconds in 5 minutes. | ||
# 每30秒检查1次,最多执行10次,最多用时5分钟 | ||
i=1 | ||
while [ $i -le 10 ] | ||
do | ||
success_start_service=`nvram get success_start_service` | ||
if [ "$success_start_service" == "1" ] | ||
then | ||
logger -st "($(basename $0))" $$ "***** ASUS ROUTER IS READY *****" | ||
break | ||
fi | ||
i=$(($i+1)) | ||
logger -st "($(basename $0))" $$ "***** ASUS ROUTER IS NOT READY, WAIT 30 SECONDS MORE *****" | ||
sleep 30 | ||
done | ||
# | ||
# Stop and Exit | ||
# 如果10次检查均为路由器没准备好执行脚本,则该脚本终止 | ||
if [ "$success_start_service" != "1" ] | ||
then | ||
logger -st "($(basename $0))" $$ "***** ASUS ROUTER IS NOT READY *****" | ||
logger -st "($(basename $0))" $$ "***** EXIT *****" | ||
exit 1 | ||
fi | ||
# | ||
########## END ########## | ||
# | ||
# | ||
########## LOCATE AND LOAD THE LIST OF USER'S CUSTOM SCRIPTS ########## | ||
# | ||
# Check if /tmp/mnt/sda1/script_bootloader/user_scripts/list_of_user_custom_scripts exists | ||
# 检查用户自定义脚本列表(本例中,该脚本为/tmp/mnt/sda1/script_bootloader/user_scripts/list_of_user_custom_scripts exists)是否存在 | ||
if [ -e "/tmp/mnt/sda1/script_bootloader/user_scripts/list_of_user_custom_scripts" ] | ||
then | ||
logger -st "($(basename $0))" $$ "***** LIST OF USER'S CUSTOM SCRIPTS EXISTS *****" | ||
# Load user's custom scripts | ||
# 如果用户自定义脚本列表存在,则执行该脚本 | ||
logger -st "($(basename $0))" $$ "***** LOAD USER'S CUSTOM SCRIPTS *****" | ||
/tmp/mnt/sda1/script_bootloader/user_scripts/list_of_user_custom_scripts | ||
# | ||
else | ||
# Stop and Exit | ||
# 如果用户自定义脚本列表不存在,则该脚本终止 | ||
logger -st "($(basename $0))" $$ "***** UNABLE TO LOCATE LIST OF USER'S CUSTOM SCRIPTS *****" | ||
logger -st "($(basename $0))" $$ "***** EXIT *****" | ||
exit 2 | ||
fi | ||
# | ||
########## END ########## | ||
# | ||
# | ||
########## LOCATE AND ENABLE ENTWARE ########## | ||
# | ||
# Prepare the environment for Entware | ||
# 准备Entware运行环境 | ||
ln -sf /tmp/mnt/sda1 /tmp/opt | ||
# | ||
# Check if /opt/etc/init.d/rc.unslung exists | ||
# 检查文件/opt/etc/init.d/rc.unslung是否存在 | ||
if [ -e '/opt/etc/init.d/rc.unslung' ] | ||
then | ||
# Start /opt/etc/init.d/rc.unslung | ||
# 如果文件/opt/etc/init.d/rc.unslung存在,则执行 | ||
/opt/etc/init.d/rc.unslung start | ||
logger -st "($(basename $0))" $$ "***** ENTWARE HAS BEEN ENABLED *****" | ||
# | ||
else | ||
# Stop and Exit | ||
# 如果文件/opt/etc/init.d/rc.unslung不存在,则该脚本终止 | ||
logger -st "($(basename $0))" $$ "***** ENTWARE CAN NOT BE ENABLED *****" | ||
logger -st "($(basename $0))" $$ "***** EXIT *****" | ||
exit 3 | ||
fi | ||
# | ||
########## END ########## |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/sh | ||
# | ||
# 此脚本在卸载U盘前,强制结束从U盘中加载的可执行程序的进程,并消除Entware运行环境,防止卸载U盘失败 | ||
# | ||
logger -st "($(basename $0))" $$ "***** UMOUNT THE USB FLASH DRIVE *****" | ||
# | ||
########## KILL ALL THE RELEVANT PROCESSES ########## | ||
# | ||
logger -st "($(basename $0))" $$ "***** KILL ALL THE RELEVANT PROCESSES *****" | ||
# | ||
# Kill all the relevant processes | ||
# 结束全部从U盘中加载的可执行程序的进程(本例中,该可执行程序为/tmp/mnt/sda1/script_bootloader/usr/software/software) | ||
# | ||
# Kill /tmp/mnt/sda1/script_bootloader/usr/software/software | ||
# 结束进程/tmp/mnt/sda1/script_bootloader/usr/software/software,使用时,删除下一行行首的# | ||
#ps | grep "/tmp/mnt/sda1/script_bootloader/usr/software/software" | grep -v 'grep' | awk '{print $1}' | xargs kill | ||
# Kill next process | ||
# 结束下一个进程XXXXX(假定该可执行程序为/tmp/mnt/sda1/script_bootloader/usr/XXXXX/XXXXX),使用时,删除下一行行首的# | ||
#ps | grep "/tmp/mnt/sda1/script_bootloader/usr/XXXXX/XXXXX" | grep -v 'grep' | awk '{print $1}' | xargs kill | ||
# | ||
logger -st "($(basename $0))" $$ "***** ALL THE RELEVANT PROCESSES HAVE BEEN KILLED *****" | ||
# | ||
########## END ########## | ||
# | ||
# | ||
########## DISABLE ENTWARE ########## | ||
# | ||
# Check if /opt/etc/init.d/rc.unslung exists | ||
# 检查文件/opt/etc/init.d/rc.unslung是否存在 | ||
if [ -e '/opt/etc/init.d/rc.unslung' ] | ||
then | ||
# Stop /opt/etc/init.d/rc.unslung | ||
# 如果文件/opt/etc/init.d/rc.unslung存在,则执行 | ||
/opt/etc/init.d/rc.unslung stop | ||
logger -st "($(basename $0))" $$ "***** ENTWARE HAS BEEN DISABLED *****" | ||
# | ||
else | ||
# Stop and Exit | ||
# 如果文件/opt/etc/init.d/rc.unslung不存在,则该脚本终止 | ||
logger -st "($(basename $0))" $$ "***** ENTWARE CAN NOT BE DISABLED *****" | ||
logger -st "($(basename $0))" $$ "***** EXIT *****" | ||
exit 1 | ||
fi | ||
# | ||
########## END ########## |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/sh | ||
# | ||
# 此脚本用于卸载“华硕路由器开机自动运行脚本系统” | ||
# | ||
logger -st "($(basename $0))" $$ "*--------- SCRIPTS BOOTLOADER FOR ASUS ROUTER UNINSTALLATION ---------*" | ||
# | ||
########## TERMINATE ANYTHING RELATED ########## | ||
# | ||
# Load /tmp/mnt/sda1/script_bootloader/script_bootloader_usb_umount | ||
# 加载/tmp/mnt/sda1/script_bootloader/script_bootloader_usb_umount | ||
/tmp/mnt/sda1/script_bootloader/script_bootloader_usb_umount | ||
logger -st "($(basename $0))" $$ "***** ANYTHING RELATED HAS BEEN TERMINATED *****" | ||
# | ||
########## END ########## | ||
# | ||
# | ||
########## ROUTER CONFIGURATION ########## | ||
# | ||
logger -st "($(basename $0))" $$ "***** RESTORE ASUS ROUTER SETTINGS *****" | ||
# | ||
# When a USB flash Drive is mounted, nothing will run automatically | ||
# 使用nvram对变量script_usbmount进行设置,将其恢复为默认状态 | ||
nvram unset script_usbmount | ||
# | ||
# When a USB flash Drive is unmounted, nothing will run automatically | ||
# 使用nvram对变量script_usbumount进行设置,将其恢复为默认状态 | ||
nvram unset script_usbumount | ||
# | ||
# Commit the changes | ||
# 使用nvram命令对路由器进行设置后,必须执行nvram commit命令,才能将已作出的修改保存至路由器 | ||
nvram commit | ||
# | ||
# Reboot the router | ||
# 需使用reboot命令重启路由器,设置才能生效 | ||
reboot | ||
# | ||
########## END ########## |
44 changes: 44 additions & 0 deletions
44
script_bootloader/user_scripts/list_of_user_custom_scripts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/sh | ||
# | ||
# 此脚本为用户自定义脚本列表,可按使用需求修改第15-28行 | ||
# | ||
########## SET THE CUSTOM ENVIRONMENT VARIABLES ########## | ||
# | ||
# 设置环境变量(本例中,该环境变量为ADMINUSER) | ||
# | ||
# ADMINUSER: The admin user of this router. | ||
# 设置环境变量ADMINUSER为路由器的后台登陆用户名(本例中,用户名为routeradmin) | ||
logger -st "($(basename $0))" $$ "***** SET CUSTOM ENVIRONMENT VARIABLES *****" | ||
export ADMINUSER='routeradmin' | ||
# | ||
########## END ########## | ||
# | ||
# | ||
########## LIST OF USER'S CUSTOM SCRIPTS ########## | ||
# | ||
# 用户自定义脚本列表(遵循下述格式) | ||
# | ||
# 脚本名 | ||
# 可执行脚本文件的绝对路径 | ||
# | ||
# 例如: | ||
# SOFTWARE SERVICE(使用时,删除下一行行首的#) | ||
#/tmp/mnt/sda1/script_bootloader/user_scripts/software/software.service | ||
# | ||
# NEXT SERVICE | ||
#/tmp/mnt/sda1/script_bootloader/user_scripts/ | ||
# | ||
########## END ########## | ||
# | ||
# | ||
########## UNSET THE CUSTOM ENVIRONMENT VARIABLES ########## | ||
# | ||
# 当所有用户自定义脚本加载后,取消之前设定的环境变量ADMINUSER | ||
# | ||
logger -st "($(basename $0))" $$ "***** UNSET CUSTOM ENVIRONMENT VARIABLES *****" | ||
unset ADMINUSER | ||
# | ||
########## END ########## | ||
# | ||
# | ||
logger -st "($(basename $0))" $$ "***** ALL THE USER'S CUSTOM SCRIPTS HAVE BEEN LOADED SUCCESSFULLY *****" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
# | ||
logger -st "($(basename $0))" $$ "*--------- SOFTWARE SERVICE ---------*" | ||
# | ||
########## CHECK AND ENABLE SOFTWARE ########## | ||
# | ||
# Check if the software exists | ||
# 检查所需外部程序是否存在(本例中,外部程序为/tmp/mnt/sda1/script_bootloader/usr/software/software)(使用时,删除下列所有行行首的#) | ||
#if [ -e "/tmp/mnt/sda1/script_bootloader/usr/software/software" ] | ||
#then | ||
# logger -st "($(basename $0))" $$ "***** SOFTWARE EXISTS *****" | ||
# # Load user's custom scripts | ||
# # 如果外部程序存在,则执行该程序 | ||
# /tmp/mnt/sda1/script_bootloader/usr/software/software | ||
# logger -st "($(basename $0))" $$ "***** SOFTWARE SERVICE HAS BEEN LOADED *****" | ||
# # | ||
#else | ||
# # Stop and Exit | ||
# # 如果外部程序不存在,则该脚本终止 | ||
# logger -st "($(basename $0))" $$ "***** UNABLE TO LOCATE SOFTWARE KMS SERVER *****" | ||
# logger -st "($(basename $0))" $$ "***** EXIT *****" | ||
# exit 1 | ||
#fi | ||
# | ||
########## END ########## |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# 引用software仅为说明本系统的使用方法 |