default-settings 4.7 KB

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