funAc88u(){ # 主机名 if [ -n "$host_name" ]; then uci set system.@system[0].hostname="$host_name" uci commit system /etc/init.d/system reload fi # 时区 if [ -n "$zone_name" ]; then uci set system.@system[0].zonename="$zone_name" uci set system.@system[0].timezone='UTC-8' uci commit system /etc/init.d/system reload fi # root密码 if [ -n "$root_password" ]; then (echo "$root_password"; sleep 1; echo "$root_password") | passwd > /dev/null fi # WLAN # More options: https://openwrt.org/docs/guide-user/network/wifi/basic#wi-fi_interfaces if [ -n "$wlan_name" -a -n "$wlan_password" -a ${#wlan_password} -ge 8 ]; then uci set wireless.radio0.channel='11' uci set wireless.radio0.band='2g' uci set wireless.radio0.htmode='HT40' uci set wireless.default_radio0.device='radio0' uci set wireless.default_radio0.network='lan' uci set wireless.default_radio0.mode='ap' uci set wireless.default_radio0.ssid="$wlan_name" uci set wireless.default_radio0.encryption='psk2' uci set wireless.default_radio0.key="$wlan_password"
uci set wireless.radio1.channel='48' uci set wireless.radio1.band='5g' uci set wireless.radio1.htmode='VHT80' uci set wireless.default_radio1.device='radio1' uci set wireless.default_radio1.network='lan' uci set wireless.default_radio1.mode='ap' uci set wireless.default_radio1.ssid="$wlan_name_5G" uci set wireless.default_radio1.encryption='psk2' uci set wireless.default_radio1.key="$wlan_password_5G"
uci commit wireless /etc/init.d/wireless reload fi # 终端自动登录 if [ -n "$ttyd_login" ]; then uci set ttyd.@ttyd[0].command="$ttyd_login" uci commit ttyd /etc/init.d/ttyd reload fi # ddns if [ -n "$ddns_host" ]; then cat d_dns >> /etc/config/ddns uci commit ddns /etc/init.d/ddns reload rm d_dns fi # 开放端口(选择 test 用) if [ -f firewall_port ]; then cat firewall_port >> /etc/config/firewall uci commit firewall /etc/init.d/firewall reload rm firewall_port fi # 端口转发 if [ -f firewall_port_Forwards ]; then cat firewall_port_Forwards >> /etc/config/firewall rm firewall_port_Forwards uci commit firewall /etc/init.d/firewall reload fi
if [ -n "$clash_rules" ]; then #openclash #uci set openclash.config.enable='1' uci set openclash.config.dashboard_password='OpenClash8517' uci set openclash.@authentication[0].password='OpenClash8517' uci commit openclash /etc/init.d/openclash reload
uci add openclash config_subscribe uci set openclash.@config_subscribe[-1]=config_subscribe uci set openclash.@config_subscribe[-1].enabled='1' uci set openclash.@config_subscribe[-1].name='clash-rules' uci set openclash.@config_subscribe[-1].address="$clash_rules" uci set openclash.@config_subscribe[-1].sub_ua='Clash' uci set openclash.@config_subscribe[-1].sub_convert='0' uci commit openclash /etc/init.d/openclash reload fi # LAN 静态协议 # More options: https://openwrt.org/docs/guide-user/base-system/basic-networking if [ -n "$lan_ip_address" ]; then uci set network.lan.proto='static' uci set network.lan.ipaddr="$lan_ip_address" uci set network.lan.netmask="$lan_netmask" uci commit network /etc/init.d/network reload fi # LAN 其它协议 # More options: https://openwrt.org/docs/guide-user/base-system/basic-networking if [ -n "$lan_proto" ]; then uci set network.lan.proto="$lan_proto" uci commit network /etc/init.d/network reload fi # Wan pppoe 协议 # More options: https://openwrt.org/docs/guide-user/network/wan/wan_interface_protocols#protocol_pppoe_ppp_over_ethernet if [ -n "$pppoe_username" -a "$pppoe_password" ]; then uci set network.wan.proto=pppoe uci set network.wan.username="$pppoe_username" uci set network.wan.password="$pppoe_password" uci delete network.wan6 uci commit network /etc/init.d/network reload fi # WAN 其它协议 if [ -n "$wan_proto" ]; then uci set network.wan.proto="$wan_proto" uci commit network /etc/init.d/network reload fi # 文件共享 uuid=$(blkid -s UUID -o value /dev/sd*) device1=$(blkid -U $uuid) device2=$(echo $(blkid -U $uuid) | sed 's/dev/mnt/')
case $mnt_disk in "1") dockerd_dir="$device2/opt/docker" ksmbd_dir="/mnt" ;; "2") dockerd_dir="/opt/docker" ksmbd_dir="/opt" re_boot=1 ;; *) ksmbd_dir='/etc' esac
if [ -n "$k_smbd" ]; then uci set ksmbd.@globals[0].interface='lan wan' uci add ksmbd share uci set ksmbd.@share[-1]=share uci set ksmbd.@share[-1].name='ac88u' uci set ksmbd.@share[-1].path="$ksmbd_dir" uci set ksmbd.@share[-1].force_root='1' uci set ksmbd.@share[-1].read_only='no' uci set ksmbd.@share[-1].guest_ok='yes' uci set ksmbd.@share[-1].create_mask='0666' uci set ksmbd.@share[-1].dir_mask='0777' uci commit ksmbd /etc/init.d/ksmbd reload fi # dockerd 根目录 #匹配替换整行 sed -i "/data_root/c\ option data_root \'$dockerd_dir\'" /etc/config/dockerd #sed -i 's/opt\/docker/$dockerd_dir/' /etc/config/dockerd uci commit dockerd /etc/init.d/dockerd reload #磁盘挂载 case $mnt_disk in "1") #mount /dev/sda1 /mnt/sda1 #rm -rf /mnt/sda1/lost+found /mnt/sda1/upper /mnt/sda1/work #mkfs.ext4 /dev/sda1 uci add fstab mount uci set fstab.@mount[-1]=mount uci set fstab.@mount[-1].target="$device2" uci set fstab.@mount[-1].uuid="$uuid" uci set fstab.@mount[-1].enabled='1' uci commit fstab /etc/init.d/fstab reload ;; "2") mkdir -p /tmp/introot mkdir -p /tmp/extroot mount --bind / /tmp/introot mount "$device1" /tmp/extroot tar -C /tmp/introot -cvf - . | tar -C /tmp/extroot -xf - wait umount /tmp/introot umount /tmp/extroot
uci add fstab mount uci set fstab.@mount[-1]=mount uci set fstab.@mount[-1].target="/" uci set fstab.@mount[-1].uuid="$uuid" uci set fstab.@mount[-1].enabled='1' uci commit fstab /etc/init.d/fstab reload esac
# 磁盘挂载 1:/mnt 2:/ mnt_disk="2" # 文件共享 uuid=$(blkid -s UUID -o value /dev/sd*) device1=$(blkid -U $uuid) device2=$(echo $(blkid -U $uuid) | sed 's/dev/mnt/') #磁盘挂载 case $mnt_disk in "1") #mount /dev/sda1 /mnt/sda1 #rm -rf /mnt/sda1/lost+found /mnt/sda1/upper /mnt/sda1/work #mkfs.ext4 /dev/sda1 uci add fstab mount uci set fstab.@mount[-1]=mount uci set fstab.@mount[-1].target="$device2" uci set fstab.@mount[-1].uuid="$uuid" uci set fstab.@mount[-1].enabled='1' uci commit fstab /etc/init.d/fstab reload ;; "2") mkdir -p /tmp/introot mkdir -p /tmp/extroot mount --bind / /tmp/introot mount "$device1" /tmp/extroot tar -C /tmp/introot -cvf - . | tar -C /tmp/extroot -xf - wait umount /tmp/introot umount /tmp/extroot
uci add fstab mount uci set fstab.@mount[-1]=mount uci set fstab.@mount[-1].target="/" uci set fstab.@mount[-1].uuid="$uuid" uci set fstab.@mount[-1].enabled='1' uci commit fstab /etc/init.d/fstab reload esac