default-settings 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #!/bin/sh
  2. version=`uci get base_config.@status[0].version 2>/dev/null`
  3. . /etc/openwrt_release
  4. test -n "${DISTRIB_ID}" || DISTRIB_ID=OpenWrt
  5. DISTRIB_ID=`echo -n $DISTRIB_ID | tr a-z A-Z`
  6. sed -i '/profile.d/d' /lib/upgrade/keep.d/base-files
  7. sed -i '/openwrt_custom/d' /etc/opkg/distfeeds.conf
  8. sed -i 's/downloads.openwrt.org/op.supes.top/g' /etc/opkg/distfeeds.conf
  9. echo $(uci get uhttpd.main.index_page) | grep -q "cgi-bin/luci" ||
  10. uci -q add_list uhttpd.main.index_page='cgi-bin/luci' && uci commit uhttpd
  11. [ -f /usr/bin/wget ] &&
  12. ln -s /usr/bin/wget /usr/bin/wget-ssl
  13. sed -i "s/git-.*-\(.*\)/git-\1/g" /usr/lib/lua/luci/version.lua
  14. ln -s /sbin/poweroff /sbin/shutdown
  15. sed -i '/S99opkg/d' /etc/crontabs/root
  16. echo "0 4 * * * sh /etc/rc.d/S99opkg >/tmp/opkgupdate.log 2>&1" >> /etc/crontabs/root
  17. cpuinfo=`/sbin/cpuinfo 2>/dev/null`
  18. test -n "$cpuinfo" || sed -i "s/_('CPU Info'),cpuinfo.cpufreq,//" /www/luci-static/resources/view/status/include/10_system.js
  19. test $version -lt 1 && {
  20. uci set luci.main.lang='auto'
  21. uci set luci.main.mediaurlbase=/luci-static/edge
  22. uci commit luci
  23. uci get system.@system[0] >/dev/null 2>&1 && {
  24. uci set system.@system[0].hostname="${DISTRIB_ID}"
  25. uci set system.@system[0].zonename='Asia/Shanghai'
  26. uci set system.@system[0].timezone='CST-8'
  27. uci del system.ntp.server
  28. uci add_list system.ntp.server='ntp.aliyun.com'
  29. uci add_list system.ntp.server='0.openwrt.pool.ntp.org'
  30. uci set system.@system[0].autoupgrade_pkg='1'
  31. uci set system.@system[0].autoupgrade_fm='1'
  32. uci commit system
  33. }
  34. uci set uhttpd.main.rfc1918_filter=0
  35. uci set uhttpd.main.redirect_https=0
  36. uci commit uhttpd
  37. SSID=${DISTRIB_ID}
  38. SSID_PASSWD=88888888
  39. uci set base_config.@status[0].SSID=${SSID}
  40. # uci set base_config.@status[0].SSID_PASSWD=${SSID_PASSWD}
  41. uci set upnpd.config.enabled='1'
  42. uci commit upnpd
  43. grep -q log-facility /etc/dnsmasq.conf ||
  44. echo "log-facility=/dev/null" >> /etc/dnsmasq.conf
  45. grep -q /etc/dnsmasq.d /etc/dnsmasq.conf ||
  46. echo "conf-dir=/etc/dnsmasq.d" >> /etc/dnsmasq.conf
  47. uci set turboacc.config.sfe_ipv6='1'
  48. uci commit turboacc
  49. uci set fstab.@global[0].anon_mount=1
  50. uci commit fstab
  51. test ! -f /etc/config/placeholder && {
  52. sed -i 's/root:.*/root:$1$tTPCBw1t$ldzfp37h5lSpO9VXk4uUE\/:18336:0:99999:7:::/g' /etc/shadow
  53. uci set network.lan.ipaddr="10.0.0.1"
  54. uci set network.@globals[0].packet_steering=1
  55. uci commit network
  56. }
  57. uci set dhcp.@dnsmasq[0].dns_redirect='1'
  58. uci set dhcp.dnsmasq[0].allservers='1'
  59. uci set dhcp.lan.force='1'
  60. uci set dhcp.@dnsmasq[0].cachesize='1500'
  61. uci set dhcp.@dnsmasq[0].min_ttl='3600'
  62. uci set dhcp.lan.ra='hybrid'
  63. uci set dhcp.lan.ndp='hybrid'
  64. uci set dhcp.lan.dhcpv6='hybrid'
  65. uci set dhcp.lan.force='1'
  66. uci commit dhcp
  67. uci set nft-qos.default.limit_enable='0'
  68. uci commit nft-qos
  69. }
  70. # kB
  71. memtotal=`grep MemTotal /proc/meminfo | awk '{print $2}'`
  72. cachesize=2048
  73. dnsforwardmax=2048
  74. nf_conntrack_max=16384
  75. if test $memtotal -ge 1048576; then
  76. # > 1024M
  77. cachesize=10000
  78. dnsforwardmax=10000
  79. nf_conntrack_max=262144
  80. elif test $memtotal -ge 524288; then
  81. # <= 1024M
  82. cachesize=10000
  83. dnsforwardmax=10000
  84. nf_conntrack_max=131072
  85. elif test $memtotal -ge 262144; then
  86. # <= 512M
  87. cachesize=8192
  88. dnsforwardmax=8192
  89. nf_conntrack_max=65536
  90. elif test $memtotal -ge 131072; then
  91. # <= 256M
  92. cachesize=4096
  93. dnsforwardmax=4096
  94. nf_conntrack_max=65536
  95. elif test $memtotal -ge 65536; then
  96. # <= 128M
  97. cachesize=2048
  98. dnsforwardmax=2048
  99. nf_conntrack_max=32768
  100. else
  101. # < 64M
  102. cachesize=1024
  103. dnsforwardmax=1024
  104. nf_conntrack_max=16384
  105. fi
  106. test $version -lt 1 && {
  107. uci -q get dhcp.@dnsmasq[0] || uci add dhcp dnsmasq
  108. uci set dhcp.@dnsmasq[0].cachesize="$cachesize"
  109. uci set dhcp.@dnsmasq[0].dnsforwardmax="$dnsforwardmax"
  110. uci set dhcp.@dnsmasq[0].localservice='0'
  111. uci set dhcp.@dnsmasq[0].localise_queries='1'
  112. uci set dhcp.@dnsmasq[0].rebind_protection='0'
  113. uci set dhcp.@dnsmasq[0].rebind_localhost='1'
  114. uci commit dhcp
  115. version=1
  116. }
  117. # sysctl overwrite
  118. SYSCTL_LOCAL=/etc/sysctl.d/50-local.conf
  119. mkdir -p /etc/sysctl.d
  120. echo -n >$SYSCTL_LOCAL
  121. echo net.nf_conntrack_max=$nf_conntrack_max >>$SYSCTL_LOCAL
  122. echo net.ipv4.ip_early_demux=0 >>$SYSCTL_LOCAL
  123. echo net.bridge.bridge-nf-call-iptables=0 >>$SYSCTL_LOCAL
  124. echo net.ipv4.fib_multipath_hash_policy=1 >>$SYSCTL_LOCAL
  125. echo net.ipv4.tcp_congestion_control=cubic >>$SYSCTL_LOCAL
  126. echo net.netfilter.nf_conntrack_helper=1 >>$SYSCTL_LOCAL
  127. echo kernel.msgmax = 65536 >>$SYSCTL_LOCAL
  128. echo kernel.msgmnb = 65536 >>$SYSCTL_LOCAL
  129. echo vm.swappiness=0 >>$SYSCTL_LOCAL
  130. rm -rf /tmp/luci-*