default-settings 4.7 KB

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