├── .github ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── 1.txt ├── LICENSE ├── README.md ├── Warehouse ├── index_Weather │ ├── index.htm │ └── x86_index.htm └── index_temperature │ ├── autocore │ └── temperature ├── doc ├── Command_Line.PNG ├── Command_Line_old.PNG ├── CompileScript.PNG └── OpenwrtCompileScript使用说明.pdf └── openwrt.sh /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 反馈bug/问题模板,提建议请删除 2 | 3 | ## 一.关于你要提交的问题 4 | 5 | Q:是否搜索了issue (使用 "x" 选择) 6 | * [ ] 没有类似的issue 7 | 8 | ## 二. 详细叙述 9 | 10 | ### (1) 具体问题 11 | 12 | A: 13 | 14 | ### (2) 步骤重现 15 | 16 | A: 17 | 18 | ### (3) 无法描述清楚,请图片或者视频 19 | 20 | A: 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Q:你知道这是`pull request`吗?(使用 "x" 选择) 2 | * [ ] 我知道 3 | 如果你不知道他的作用,建议你先百度看看 4 | 5 | -------------------------------------------------------------------------------- /1.txt: -------------------------------------------------------------------------------- 1 | 脚本已经最新 2 | >>文件夹:/home/zhang/Openwrt/11/lede 执行make clean 3 | 4 | 5 | make[1]: Entering directory '/home/zhang/Openwrt/11/lede' 6 | make[2]: Entering directory '/home/zhang/Openwrt/11/lede/scripts/config' 7 | set -e; mkdir -p ./; trap "rm -f ./.mconf-cfg.tmp" EXIT; { /bin/sh mconf-cfg.sh; } > ./.mconf-cfg.tmp; if [ ! -r mconf-cfg ] || ! cmp -s mconf-cfg ./.mconf-cfg.tmp; then true ' UPD mconf-cfg'; mv -f ./.mconf-cfg.tmp mconf-cfg; fi 8 | make[2]: Leaving directory '/home/zhang/Openwrt/11/lede/scripts/config' 9 | make[2]: Entering directory '/home/zhang/Openwrt/11/lede' 10 | make[2]: Leaving directory '/home/zhang/Openwrt/11/lede' 11 | [?1049h(B[?7h[?1h=[?1h=[?1h=(B .config - OpenWrt Configuration 12 | (0q(B 13 |  14 |    15 |    16 |    17 |    18 |    19 |  (B (B Target System (x86) --->(B(B   20 |     21 |     22 |     23 |     24 |     25 |     26 |     27 |     28 |     29 |    30 |    31 |    32 |    33 | (B 34 |   (BS(Bubtarget (x86_64) --->(B 35 |   (BT(Barget Profile (Generic x86/64) --->(B 36 |   (BT(Barget Images --->(B 37 |  [ ] (BE(Bnable experimental features by default (NEW)(B 38 |   (BG(Blobal build settings --->(B 39 |  [ ] (BA(Bdvanced configuration options (for developers) (NEW) ---- (B 40 |  [ ] (BB(Build the OpenWrt Image Builder (NEW)(B 41 |  [ ] (BB(Build the OpenWrt SDK (NEW)(B 42 |  [ ] (BP(Backage the OpenWrt-based Toolchain (NEW)(B(0lq(B OpenWrt Configuration (0q(0k(B(B 43 | (0(0x(B Arrow keys navigate the menu. selects submenus ---> (or empty (0x(B(B 44 | (0(0x(B submenus ----). Highlighted letters are hotkeys. Pressing (0x(B(B 45 | (0(0x(B includes, excludes, modularizes features. Press to (0x(B(B 46 | (0(0x(B exit, for Help, for Search. Legend: [*] built-in [ ] (0x(B(B 47 | (0(0x(B (0lq(0k(B (0x(B(B 48 | (0(0x(B (0x(B(B(0(0x(B (0x(B(B 49 | (0(0x(B (0x(B(B(0(0x(B (0x(B(B 50 | (0(0x(B (0x(B(B(0(0x(B (0x(B(B 51 | (0(0x(B (0x(B(B(0(0x(B (0x(B(B 52 | (0(0x(B (0x(B(B(0(0x(B (0x(B(B 53 | (0(0x(B (0x(B(B(0(0x(B (0x(B(B 54 | (0(0x(B (0x(B(B(0(0x(B (0x(B(B 55 | (0(0x(B (0x(B(B(0(0x(B (0x(B(B 56 | (0(0x(B (0x(B(B(0(0x(B (0x(B(B 57 | (0(0x(B (0x(B(B(0(0x(B (0x(B(B 58 | (0(0x(B (0m(0qj(B (0x(B(B 59 | (0(0tq(0u(B(B 60 | (0(0x(B(0x(B(B 61 | (0(0m(0qj(B(B(0(B(B(0v(B(+)(B(B<Select>(B <(B (BE(Bxit (B> <(B (BH(Belp (B> <(B (BS(Bave (B> <(B (BL(Boad (B>(B[?1h= (B 62 |  63 |  64 |  65 |  66 |  67 |  (0lq(0k(B (0x(B Do you wish to save your new configuration? (0x(B  (0x(B (Press to continue kernel configuration.) (0x(B  (0tq(0u(B  (0x(B(B< Yes >(B <(B (BN(Bo (B> (0x(B  (0m(0qj(B   (B/home/zhang/Openwrt/11/lede/include/toplevel.mk:134: recipe for target 'menuconfig' failed 68 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenwrtCompileScript 2 | 3 | ![Command_Line](doc/Command_Line.PNG) 4 | 5 | ## 序言 6 | 7 | 用于辅助Openwrt编译,但不会帮你完成整个编译过程,需要一点Openwrt编译基础 8 | 9 | 降低编译难度,减少重复的步骤,但不利于学习,此脚本适用于有点openwrt编译的基础的最佳,完全没有编译基础的请去补充相关知识 10 | 11 | 想学点东西请走这里: https://www.right.com.cn/forum/thread-324501-1-1.html 12 | 13 | 此脚本并不是无脑脚本,这个脚本对新手是无脑的但要点基础,起码你要会选择机型与插件,有点基础的可以说是辅助,加快你的编译速度,写这个脚本的初衷就是编译的过程重复太多,所以写了脚本 14 | 15 | > ### 感谢 @学渣 @sjz 等的帮助 16 | 17 | ## 支持系统 18 | 19 | The script is made to work on these OS : 20 | 21 | - Ubuntu 16.4 22 | - Ubuntu 18.4 (首选,脚本基于此版本编写测试) 23 | - win10子系统(ubuntu 18.04 LTS) 24 | - Deepin 15.11桌面版(群友测试ok) 25 | 26 | ## 脚本使用教程 27 | 28 | **脚本视频教程加群** :**667491026** (**拒绝大爷公子伸手党**) 29 | 30 | **脚本问题反馈** :https://github.com/openwrtcompileshell/OpenwrtCompileScript/issues 或者加群反馈 31 | 32 | 33 | ## Usage 使用方法 34 | **请勿使用Root进行编译!!!** 35 | 36 | 37 | 1、使用git克隆下载脚本并赋予执行权限 38 | 39 | ```bash 40 | git clone https://github.com/openwrtcompileshell/OpenwrtCompileScript.git && chmod +x OpenwrtCompileScript/openwrt.sh 41 | 42 | ``` 43 | 44 | 2、进入脚本目录并执行 45 | 46 | ```bash 47 | cd OpenwrtCompileScript && bash openwrt.sh 48 | ``` 49 | 50 | **注意**:执行脚本后会自动添加系统变量,第二次可使用如下命令运行脚本。(如果不行,请重启的你的Linux) 51 | 52 | `bash $openwrt` 53 | 54 | ## 命令行调用脚本 55 | ```bash 56 | 用法: bash $openwrt [文件夹] [命令] 57 | 脚本创建文件夹目录结构:/home/zhang/Openwrt/你起的文件夹名/lede 58 | 59 | 首次编译建议: 60 | new_source_make 脚本新建一个文件夹下载你需要的源码并进行编译 61 | 62 | 二次编译建议: 63 | noclean_make 不执行make clean清理一下源码然后再进行编译 64 | clean_make 执行make clean清理一下源码然后再进行编译 65 | update_clean_make 执行make clean 并同步最新的源码 再进行编译 66 | update_script 将脚本同步到最新 67 | update_script_rely 将脚本和源码依赖同步到最新 68 | 69 | 70 | 例子: 71 | 1.新建一个文件夹下载你需要的源码并进行编译(适合首次编译) 72 | bash $openwrt new_source_make 73 | 74 | 2.不执行clean,执行make download 和make -j V=s(适合二次编译) 75 | bash $openwrt 你起的文件夹名 noclean_make 76 | 77 | 3.清理编译文件,再重新编译(适合二次编译) 78 | bash $openwrt 你起的文件夹名 clean_make 79 | 80 | 4.同步最新的源码清理编译文件再编译(适合二次编译) 81 | bash $openwrt 你起的文件夹名 update_clean_make 82 | 83 | bash $openwrt help 查看帮助 84 | bash $openwrt update_script 将脚本同步到最新 85 | 86 | 87 | 88 | ``` 89 | 90 | 91 | 92 | ## 版本修改记录 93 | ### ++3.0版本 94 | 1.禁用图形界面 95 | 2.现在支持lean的源码,后期有时间再考虑其他 96 | 97 | ### ++2.9版本 98 | 99 | 1. 修复误 100 | 2. 将插件默认选上我经常用的 101 | 3. 添加天气预报 102 | 4. 个别变量改名 103 | 5. 修改固件生成名字,添加日期和时间,方便分类 104 | 6. 重写source_if整个模块(大改动)添加dl文件检测代码 105 | 7. 支持gitpod云编译 106 | 8. 新增 git_reset回退功能 107 | 9. 适配lienol源码 108 | 10. 更新OpenwrtCompileScript使用说明.pdf 109 | 11. 修复windows10子系统无法更新 110 | 12. 增加回退选择,报错可以选择回退到编译选择界面,方便继续编译,而不是重新开始 111 | 13. 脚本支持Deepin 15.11桌面版 112 | 14. 支持N1制作镜像源码 113 | 15. 增加help模块 114 | 16. 脚本支持命令模式 115 | 116 | ### ++2.8版本 117 | 118 | 1. 更新dl下载代码, 119 | 2. 补全if判断代码 120 | 3. 修复之前代码不完整 121 | 4. 新增变量openwrt_shfile 122 | 5. 调整代码的阅读顺序,方便阅读调整 123 | 6. 环境依赖加入判断,防止报错 124 | 7. openwrt加入lean插件功能 125 | 8. 颜色调整,方便阅读 126 | 9. 新增功能按键 更新lean仓库 127 | 10. 编写OpenwrtCompileScript使用说明.pdf 128 | 11. 将二次编译与源码更新模块合并,并加入显示远端仓库的最近三条更新内容模块 129 | 12. 加入比较源码参数 130 | 13. 取消官方源码强制https 131 | 14. 合并左右的部分脚本代码 132 | 15. 删除dl国内服务器下载功能选项 133 | 16. 增加software_Setting_Public模块 134 | 135 | ### ++2.7版本 136 | 137 | 1. 修改脚本名字为《openwrt.sh》不再以版本命名,以后执行脚本bash openwrt.sh即可 138 | 2. 加入if判断是否源码下载成功 139 | 3. Dl服务器下载增加一个参数,解决证书不信任问题 140 | 4. 增加脚本描述文本 141 | 5. 文件夹创建提前 142 | 6. 加入时间计算让自己更加直观看到编译耗时 143 | 7. 增加多线程编译可以自己决定以多少线程进行编译 144 | 8. 增加脚本自检程序 145 | 9. 新增选项 9.更新脚本 146 | 10. 优化一下代码 147 | 11. 增加一个ls函数模块 148 | 12. 适配win10子系统(ubuntu 18.04 LTS) 149 | 13. 删除无用的5.选项替换DNS 150 | 151 | ### ++2.6版本 152 | 153 | 1. 支持不在home底下也能正常运行,因为服了一下小白老是报错 154 | 2. 只需要执行脚本就可以操作你任意的openwrt文件夹 155 | 3. 新增国内DL服务器(感谢LGA1150) 156 | 4. 新增选择( 6.其他选项),可以单独使用个别模块,如:支持单独只搭建编译环境,而不进行编译 157 | 5. 创建文件时加入判断,防止覆盖之前的目录 158 | 6. 删除之前的个别文件,脚本执行目录随意没有要求了,但Home目录底下的Openwrt目录禁止改名移动 159 | 160 | ### ++2.5版本 161 | 162 | 1. 简化之前目录 163 | 2. 代码的重写 164 | 3. 一个目录方便管理 165 | 4. 加入Lean_R9_source and Openwrt17.01_source 166 | 167 | ### ++2.4版本 168 | 169 | 1. 增加config文件保存与调用(家里机型较多的可以更省事),此建议由 @兔巴哥提供 170 | 171 | ### ++2.3版本 172 | 173 | 1. 合并功能按键并增加第5.HOST选项 174 | -------------------------------------------------------------------------------- /Warehouse/index_Weather/index.htm: -------------------------------------------------------------------------------- 1 | <%# 2 | Copyright 2008 Steven Barth 3 | Copyright 2008-2011 Jo-Philipp Wich 4 | Licensed to the public under the Apache License 2.0. 5 | -%> 6 | 7 | <% 8 | local fs = require "nixio.fs" 9 | local util = require "luci.util" 10 | local stat = require "luci.tools.status" 11 | local ver = require "luci.version" 12 | 13 | local has_ipv6 = fs.access("/usr/sbin/ip6tables") 14 | local has_dhcp = fs.access("/etc/config/dhcp") 15 | local has_wifi = ((fs.stat("/etc/config/wireless", "size") or 0) > 0) 16 | 17 | local sysinfo = luci.util.ubus("system", "info") or { } 18 | local boardinfo = luci.util.ubus("system", "board") or { } 19 | local unameinfo = nixio.uname() or { } 20 | 21 | local meminfo = sysinfo.memory or { 22 | total = 0, 23 | free = 0, 24 | buffered = 0, 25 | shared = 0 26 | } 27 | 28 | local mem_cached = luci.sys.exec("sed -e '/^Cached: /!d; s#Cached: *##; s# kB##g' /proc/meminfo") 29 | 30 | local swapinfo = sysinfo.swap or { 31 | total = 0, 32 | free = 0 33 | } 34 | 35 | local has_dsl = fs.access("/etc/init.d/dsl_control") 36 | 37 | if luci.http.formvalue("status") == "1" then 38 | local ntm = require "luci.model.network".init() 39 | local wan = ntm:get_wannet() 40 | local wan6 = ntm:get_wan6net() 41 | 42 | local conn_count = tonumber( 43 | fs.readfile("/proc/sys/net/netfilter/nf_conntrack_count") or "") or 0 44 | 45 | local conn_max = tonumber(luci.sys.exec( 46 | "sysctl -n -e net.nf_conntrack_max net.ipv4.netfilter.ip_conntrack_max" 47 | ):match("%d+")) or 4096 48 | 49 | local user_info = tonumber(luci.sys.exec("cat /proc/net/arp | grep 'br-lan' | grep '0x2' | wc -l")) 50 | 51 | local cpu_usage = fs.readfile("/tmp/cpuusage") or "6.6%" 52 | 53 | local temper_ature = luci.sys.exec("temperature") 54 | 55 | luci.sys.exec("/bin/getcpu &") 56 | 57 | local rv = { 58 | cpuusage = cpu_usage, 59 | temperature = temper_ature, 60 | userinfo = user_info, 61 | uptime = sysinfo.uptime or 0, 62 | localtime = os.date(), 63 | loadavg = sysinfo.load or { 0, 0, 0 }, 64 | memory = meminfo, 65 | memcached = mem_cached, 66 | swap = swapinfo, 67 | connmax = conn_max, 68 | conncount = conn_count, 69 | leases = stat.dhcp_leases(), 70 | leases6 = stat.dhcp6_leases(), 71 | wifinets = stat.wifi_networks() 72 | } 73 | 74 | if wan then 75 | rv.wan = { 76 | ipaddr = wan:ipaddr(), 77 | gwaddr = wan:gwaddr(), 78 | netmask = wan:netmask(), 79 | dns = wan:dnsaddrs(), 80 | expires = wan:expires(), 81 | uptime = wan:uptime(), 82 | proto = wan:proto(), 83 | ifname = wan:ifname(), 84 | link = wan:adminlink() 85 | } 86 | end 87 | 88 | if wan6 then 89 | rv.wan6 = { 90 | ip6addr = wan6:ip6addr(), 91 | gw6addr = wan6:gw6addr(), 92 | dns = wan6:dns6addrs(), 93 | ip6prefix = wan6:ip6prefix(), 94 | uptime = wan6:uptime(), 95 | proto = wan6:proto(), 96 | ifname = wan6:ifname(), 97 | link = wan6:adminlink() 98 | } 99 | end 100 | 101 | if has_dsl then 102 | local dsl_stat = luci.sys.exec("/etc/init.d/dsl_control lucistat") 103 | local dsl_func = loadstring(dsl_stat) 104 | if dsl_func then 105 | rv.dsl = dsl_func() 106 | end 107 | end 108 | 109 | luci.http.prepare_content("application/json") 110 | luci.http.write_json(rv) 111 | 112 | return 113 | elseif luci.http.formvalue("hosts") == "1" then 114 | luci.http.prepare_content("application/json") 115 | luci.http.write_json(luci.sys.net.host_hints()) 116 | 117 | return 118 | end 119 | -%> 120 | 121 | <%+header%> 122 | 123 | 124 | 693 | 694 |

<%:Status%>

695 | 696 |
697 | <%:System%> 698 | 699 | 700 | 701 | 702 | 703 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 |
<%:Hostname%><%=luci.sys.hostname() or "?"%>
<%:Model%><%=pcdata(boardinfo.model or "?")%> <%=luci.sys.exec("cat /etc/bench.log") or " "%>
<%:Architecture%><%=pcdata(boardinfo.system or "?")%> x <%=luci.sys.exec("cat /proc/cpuinfo | grep 'processor' | wc -l") or "1"%>
<%:Firmware Version%> 704 | <%=pcdata(ver.distname)%> <%=pcdata(ver.distversion)%> / 705 | <%=pcdata(ver.luciname)%> (<%=pcdata(ver.luciversion)%>) 706 |
<%:Kernel Version%><%=unameinfo.release or "?"%>
<%:Local Time%>-
<%:Uptime%>-
<%:Load Average%>-
<%:CPU Temperature%>-
<%:CPU usage (%)%>-
<%:Compile_time %><%=luci.sys.exec("cat /etc/Compile_time") or " "%>
716 |
717 | 718 |
719 | <%:Weather%> 720 | 721 | 722 |
<%:Local Weather%> 723 |
724 |
725 | 726 | 727 |
728 | <%:Memory%> 729 | 730 | 731 | 732 | 733 |
<%:Total Available%>-
<%:Buffered%>-
734 |
735 | 736 | <% if swapinfo.total > 0 then %> 737 |
738 | <%:Swap%> 739 | 740 | 741 | 742 | 743 |
<%:Total Available%>-
<%:Free%>-
744 |
745 | <% end %> 746 | 747 |
748 | <%:Network%> 749 | 750 | 751 | 757 | <% if has_ipv6 then %> 758 | 764 | <% end %> 765 | 766 | 767 |
<%:IPv4 WAN Status%> 752 | 753 | 754 | 755 |

?
<%:Collecting data...%>
756 |
<%:IPv6 WAN Status%> 759 | 760 | 761 | 762 |

?
<%:Collecting data...%>
763 |
<%:Online Users%>0
<%:Active Connections%>-
768 |
769 | 770 | <% if has_dhcp then %> 771 |
772 | <%:DHCP Leases%> 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 |
<%:Hostname%><%:IPv4-Address%><%:MAC-Address%><%:Leasetime remaining%>

<%:Collecting data...%>
785 |
786 | 787 | <% if has_ipv6 then %> 788 | 803 | <% end %> 804 | <% end %> 805 | 806 | <% if has_dsl then %> 807 |
808 | <%:DSL%> 809 | 810 | 816 |
<%:DSL Status%> 811 | 812 | 813 | 814 |

?
<%:Collecting data...%>
815 |
817 |
818 | <% end %> 819 | 820 | <% if has_wifi then %> 821 |
822 | <%:Wireless%> 823 | 824 | 825 | 826 |
<%:Collecting data...%>
827 |
828 | <% end %> 829 | 830 | <%+footer%> 831 | -------------------------------------------------------------------------------- /Warehouse/index_Weather/x86_index.htm: -------------------------------------------------------------------------------- 1 | <%# 2 | Copyright 2008 Steven Barth 3 | Copyright 2008-2011 Jo-Philipp Wich 4 | Licensed to the public under the Apache License 2.0. 5 | -%> 6 | 7 | <% 8 | local fs = require "nixio.fs" 9 | local util = require "luci.util" 10 | local stat = require "luci.tools.status" 11 | local ver = require "luci.version" 12 | 13 | local has_ipv6 = fs.access("/usr/sbin/ip6tables") 14 | local has_dhcp = fs.access("/etc/config/dhcp") 15 | local has_wifi = ((fs.stat("/etc/config/wireless", "size") or 0) > 0) 16 | 17 | local sysinfo = luci.util.ubus("system", "info") or { } 18 | local boardinfo = luci.util.ubus("system", "board") or { } 19 | local unameinfo = nixio.uname() or { } 20 | 21 | local meminfo = sysinfo.memory or { 22 | total = 0, 23 | free = 0, 24 | buffered = 0, 25 | shared = 0 26 | } 27 | 28 | local mem_cached = luci.sys.exec("sed -e '/^Cached: /!d; s#Cached: *##; s# kB##g' /proc/meminfo") 29 | 30 | local swapinfo = sysinfo.swap or { 31 | total = 0, 32 | free = 0 33 | } 34 | 35 | local has_dsl = fs.access("/etc/init.d/dsl_control") 36 | 37 | if luci.http.formvalue("status") == "1" then 38 | local ntm = require "luci.model.network".init() 39 | local wan = ntm:get_wannet() 40 | local wan6 = ntm:get_wan6net() 41 | 42 | local conn_count = tonumber( 43 | fs.readfile("/proc/sys/net/netfilter/nf_conntrack_count") or "") or 0 44 | 45 | local conn_max = tonumber(luci.sys.exec( 46 | "sysctl -n -e net.nf_conntrack_max net.ipv4.netfilter.ip_conntrack_max" 47 | ):match("%d+")) or 4096 48 | 49 | local cpu_info = luci.sys.exec("cpuinfo") 50 | 51 | local eth_info = luci.sys.exec("ethinfo") 52 | 53 | local user_info = luci.sys.exec("cat /proc/net/arp | grep '0x2' | wc -l") or 0 54 | 55 | local cpu_usage = (luci.sys.exec("expr 100 - $(top -n 1 | grep 'CPU:' | awk -F '%' '{print$4}' | awk -F ' ' '{print$2}')") or "6") .. "%" 56 | 57 | local rv = { 58 | cpuusage = cpu_usage, 59 | cpuinfo = cpu_info, 60 | ethinfo = eth_info, 61 | userinfo = user_info, 62 | uptime = sysinfo.uptime or 0, 63 | localtime = os.date(), 64 | loadavg = sysinfo.load or { 0, 0, 0 }, 65 | memory = meminfo, 66 | memcached = mem_cached, 67 | swap = swapinfo, 68 | connmax = conn_max, 69 | conncount = conn_count, 70 | leases = stat.dhcp_leases(), 71 | leases6 = stat.dhcp6_leases(), 72 | wifinets = stat.wifi_networks() 73 | } 74 | 75 | if wan then 76 | rv.wan = { 77 | ipaddr = wan:ipaddr(), 78 | gwaddr = wan:gwaddr(), 79 | netmask = wan:netmask(), 80 | dns = wan:dnsaddrs(), 81 | expires = wan:expires(), 82 | uptime = wan:uptime(), 83 | proto = wan:proto(), 84 | ifname = wan:ifname(), 85 | link = wan:adminlink() 86 | } 87 | end 88 | 89 | if wan6 then 90 | rv.wan6 = { 91 | ip6addr = wan6:ip6addr(), 92 | gw6addr = wan6:gw6addr(), 93 | dns = wan6:dns6addrs(), 94 | ip6prefix = wan6:ip6prefix(), 95 | uptime = wan6:uptime(), 96 | proto = wan6:proto(), 97 | ifname = wan6:ifname(), 98 | link = wan6:adminlink() 99 | } 100 | end 101 | 102 | if has_dsl then 103 | local dsl_stat = luci.sys.exec("/etc/init.d/dsl_control lucistat") 104 | local dsl_func = loadstring(dsl_stat) 105 | if dsl_func then 106 | rv.dsl = dsl_func() 107 | end 108 | end 109 | 110 | luci.http.prepare_content("application/json") 111 | luci.http.write_json(rv) 112 | 113 | return 114 | elseif luci.http.formvalue("hosts") == "1" then 115 | luci.http.prepare_content("application/json") 116 | luci.http.write_json(luci.sys.net.host_hints()) 117 | 118 | return 119 | end 120 | -%> 121 | 122 | <%+header%> 123 | 124 | 125 | 732 | 733 |

<%:Status%>

734 | 735 |
736 | <%:System%> 737 | 738 | 739 | 740 | 741 | 742 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 |
<%:Hostname%><%=luci.sys.hostname() or "?"%>
<%:Model%><%=pcdata(boardinfo.model or "?")%> <%=luci.sys.exec("cat /etc/bench.log") or " "%>
<%:CPU Info%>-
<%:Firmware Version%> 743 | <%=pcdata(ver.distname)%> <%=pcdata(ver.distversion)%> / 744 | <%=pcdata(ver.luciname)%> (<%=pcdata(ver.luciversion)%>) 745 |
<%:Kernel Version%><%=unameinfo.release or "?"%>
<%:Local Time%>-
<%:Uptime%>-
<%:Load Average%>-
<%:CPU usage (%)%>-
<%:Compile_time %><%=luci.sys.exec("cat /etc/Compile_time") or " "%>
754 |
755 | 756 |
757 | <%:Weather%> 758 | 759 | 760 |
<%:Local Weather%> 761 |
762 |
763 | 764 | 765 |
766 | <%:Memory%> 767 | 768 | 769 | 770 | 771 |
<%:Total Available%>-
<%:Buffered%>-
772 |
773 | 774 | <% if swapinfo.total > 0 then %> 775 |
776 | <%:Swap%> 777 | 778 | 779 | 780 | 781 |
<%:Total Available%>-
<%:Free%>-
782 |
783 | <% end %> 784 | 785 |
786 | <%:Interfaces%> 787 | 788 | 789 |
790 |
791 | 792 |
793 | <%:Network%> 794 | 795 | 796 | 802 | <% if has_ipv6 then %> 803 | 809 | <% end %> 810 | 811 | 812 |
<%:IPv4 WAN Status%> 797 | 798 | 799 | 800 |

?
<%:Collecting data...%>
801 |
<%:IPv6 WAN Status%> 804 | 805 | 806 | 807 |

?
<%:Collecting data...%>
808 |
<%:Online Users%>0
<%:Active Connections%>-
813 |
814 | 815 | <% if has_dhcp then %> 816 |
817 | <%:DHCP Leases%> 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 |
<%:Hostname%><%:IPv4-Address%><%:MAC-Address%><%:Leasetime remaining%>

<%:Collecting data...%>
830 |
831 | 832 | <% if has_ipv6 then %> 833 | 848 | <% end %> 849 | <% end %> 850 | 851 | <% if has_dsl then %> 852 |
853 | <%:DSL%> 854 | 855 | 861 |
<%:DSL Status%> 856 | 857 | 858 | 859 |

?
<%:Collecting data...%>
860 |
862 |
863 | <% end %> 864 | 865 | <% if has_wifi then %> 866 |
867 | <%:Wireless%> 868 | 869 | 870 | 871 |
<%:Collecting data...%>
872 |
873 | <% end %> 874 | 875 | <%+footer%> 876 | -------------------------------------------------------------------------------- /Warehouse/index_temperature/autocore: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2017 lean 3 | 4 | START=99 5 | 6 | start() 7 | { 8 | rfc=4096 9 | cc=$(grep -c processor /proc/cpuinfo) 10 | rsfe=$(echo $cc*$rfc | bc) 11 | sysctl -w net.core.rps_sock_flow_entries=$rsfe >/dev/null 12 | for fileRps in $(ls /sys/class/net/eth*/queues/rx-*/rps_cpus) 13 | do 14 | echo $cc > $fileRps 15 | done 16 | 17 | for fileRfc in $(ls /sys/class/net/eth*/queues/rx-*/rps_flow_cnt) 18 | do 19 | echo $rfc > $fileRfc 20 | done 21 | 22 | uci set network.@globals[0].packet_steering=1 23 | uci commit network 24 | 25 | a=$(cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq) 26 | b=$(echo -n ' : ') 27 | c=$(cat /proc/cpuinfo | grep 'core id' | sort -u | wc -l) 28 | d=$(echo -n 'C') 29 | e=$(cat /proc/cpuinfo | grep 'processor' | wc -l) 30 | f=$(echo -n 'T ') 31 | g=$(dmesg | grep 'DMI:' | awk -F ',' '{print $1 }' | awk -F ':' '{print $2 }') 32 | 33 | if [ -d /sys/devices/cpu_atom/ ]; then 34 | pcore=$(cat /sys/devices/cpu_core/cpus | awk -F- '{print $2}') 35 | pc=$(echo "($pcore+1)/2" | bc) 36 | ecore1=$(cat /sys/devices/cpu_atom/cpus | awk -F- '{print $1}') 37 | ecore2=$(cat /sys/devices/cpu_atom/cpus | awk -F- '{print $2}') 38 | ec=$(echo "$ecore2-$ecore1+1" | bc) 39 | hydrid='('${pc}'P+'${ec}'E)' 40 | fi 41 | 42 | h=${g}' - '${a}${b}${c}${d}${e}${f}${hydrid} 43 | 44 | mkdir -p /tmp/sysinfo 45 | echo $h > /tmp/sysinfo/model 46 | 47 | all_pcis=`lspci | grep -i 'eth' | grep -i 'x550' | cut -d ' ' -f 1` 48 | all_ifs=`cat /proc/net/dev | grep -i 'eth' | cut -d : -f 1 | sed 's/^[ \t]*//g'` 49 | 50 | for ifname in ${all_ifs} 51 | do 52 | if_pci=`ethtool -i ${ifname} | grep -i 'bus-info' | cut -d : -f 3-` 53 | if [[ "$all_pcis" =~ "$if_pci" ]] 54 | then 55 | ethtool -s ${ifname} advertise 0x1800000001028 56 | fi 57 | done 58 | 59 | a=$(ip address | grep ^[0-9] | awk -F: '{print $2}' | sed "s/ //g" | grep '^[e]' | grep -v "@" | grep -v "\.") 60 | b=$(echo "$a" | wc -l) 61 | for i in $(seq 1 $b) 62 | do 63 | c=$(echo "$a" | sed -n ${i}p) 64 | ethtool -K $c rx-checksum on >/dev/null 2>&1 65 | ethtool -K $c tx-checksum-ip-generic on >/dev/null 2>&1 || ( 66 | ethtool -K $c tx-checksum-ipv4 on >/dev/null 2>&1 67 | ethtool -K $c tx-checksum-ipv6 on >/dev/null 2>&1) 68 | ethtool -K $c tx-scatter-gather on >/dev/null 2>&1 69 | ethtool -K $c tso on >/dev/null 2>&1 70 | done 71 | 72 | [ -f /etc/index.htm ] && mv /etc/index.htm /usr/lib/lua/luci/view/admin_status/index.htm 73 | } 74 | -------------------------------------------------------------------------------- /Warehouse/index_temperature/temperature: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | info() 4 | { 5 | #获取CPU核心温度(r7800测试正常)(已知竟斗云,N1无法获取温度,强迫症可以换回我之前的index.htm文件) 6 | sen=`sensors | grep 'temp1' | sed -n '1p' | cut -c10-24` 7 | sen_na=`sensors | grep 'N/A' | sed -n '1p' | wc -l` 8 | cut_temp=`cut -c1-2 /sys/class/thermal/thermal_zone0/temp` 9 | symbol=`echo "°C"` 10 | 11 | if [ "$sen_na" == "1" ];then 12 | $cut_temp 13 | if [[ $? -eq 0 ]]; then 14 | a=$cut_temp$symbol 15 | else 16 | a="Not Support" 17 | fi 18 | else 19 | a=$sen 20 | fi 21 | } 22 | 23 | out() 24 | { 25 | info 26 | echo " $a " 27 | } 28 | 29 | out 30 | -------------------------------------------------------------------------------- /doc/Command_Line.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openwrtcompileshell/OpenwrtCompileScript/0b3cf4587d1b348c9b5869644b04061db136db6c/doc/Command_Line.PNG -------------------------------------------------------------------------------- /doc/Command_Line_old.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openwrtcompileshell/OpenwrtCompileScript/0b3cf4587d1b348c9b5869644b04061db136db6c/doc/Command_Line_old.PNG -------------------------------------------------------------------------------- /doc/CompileScript.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openwrtcompileshell/OpenwrtCompileScript/0b3cf4587d1b348c9b5869644b04061db136db6c/doc/CompileScript.PNG -------------------------------------------------------------------------------- /doc/OpenwrtCompileScript使用说明.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openwrtcompileshell/OpenwrtCompileScript/0b3cf4587d1b348c9b5869644b04061db136db6c/doc/OpenwrtCompileScript使用说明.pdf -------------------------------------------------------------------------------- /openwrt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #set -x 3 | #set -u 4 | 5 | version="3.0" 6 | SF="Script_File" 7 | OW="Openwrt" 8 | by="ITdesk" 9 | OCS="OpenwrtCompileScript" 10 | cpu_cores=`cat /proc/cpuinfo | grep processor | wc -l` 11 | 12 | #颜色调整参考wen55333 13 | red="\033[31m" 14 | green="\033[32m" 15 | yellow="\033[33m" 16 | white="\033[0m" 17 | 18 | calculating_time_start() { 19 | startTime=`date +%Y%m%d-%H:%M:%S` 20 | startTime_s=`date +%s` 21 | } 22 | 23 | calculating_time_end() { 24 | endTime=`date +%Y%m%d-%H:%M:%S` 25 | endTime_s=`date +%s` 26 | sumTime=$[ $endTime_s - $startTime_s ] 27 | 28 | echo -e "$yellow开始时间:$green $startTime ---> $yellow结束时间:$green $endTime $white" 29 | echo -e "耗时:" 30 | 31 | #以下代码copy https://blog.csdn.net/weixin_33478575/article/details/116683248 32 | local T=$sumTime 33 | 34 | local D=$((T/60/60/24)) 35 | 36 | local H=$((T/60/60%24)) 37 | 38 | local M=$((T/60%60)) 39 | 40 | local S=$((T%60)) 41 | 42 | (( $D > 0 )) && printf '%d 天 ' $D 43 | 44 | (( $H > 0 )) && printf '%d 小时 ' $H 45 | 46 | (( $M > 0 )) && printf '%d 分钟 ' $M 47 | 48 | (( $D > 0 || $H > 0 || $M > 0 )) && printf 'and ' 49 | 50 | printf '%d 秒\n' $S 51 | 52 | echo "" 53 | 54 | } 55 | 56 | prompt() { 57 | echo -e "$green 脚本问题反馈:https://github.com/openwrtcompileshell/OpenwrtCompileScript/issues或者加群反馈(群在github有)$white" 58 | echo -e " $yellow温馨提示,最近的编译依赖有变动,如果你最近一直编译失败,建议使用脚本5.其他选项 --- 1.只搭建编译环境功能 $white" 59 | } 60 | 61 | source_make_clean() { 62 | clear 63 | echo "--------------------------------------------------------" 64 | echo -e "$green++是否执行make clean清理固件++$white" 65 | echo "" 66 | echo " 1.执行make clean" 67 | echo "" 68 | echo " 2.不执行make clean" 69 | echo "" 70 | echo -e "$yellow 温馨提醒make clean会清理掉之前编译的固件,为了编译成功 $white" 71 | echo -e "$yellow率建议执行make clean,虽然编译时间会比较久$white" 72 | echo "--------------------------------------------------------" 73 | read -p "请输入你的参数(回车默认:make clean):" mk_c 74 | if [[ -z "$mk_c" ]];then 75 | clear && echo -e "$green开始执行make clean $white" 76 | make clean 77 | else 78 | case "$mk_c" in 79 | 1) 80 | clear && echo -e "$green开始执行make clean $white" 81 | make clean 82 | ;; 83 | 2) 84 | clear && echo -e "$green不执行make clean $white" 85 | ;; 86 | *) 87 | clear && echo "Error请输入正确的数字 [1-2]" && Time 88 | clear && source_make_clean 89 | ;; 90 | esac 91 | fi 92 | 93 | } 94 | 95 | rely_on() { 96 | sudo apt install -y ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \ 97 | bzip2 ccache cmake cpio curl device-tree-compiler fastjar flex gawk gettext gcc-multilib g++-multilib \ 98 | git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libglib2.0-dev libgmp3-dev libltdl-dev \ 99 | libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libreadline-dev libssl-dev libtool lrzsz \ 100 | mkisofs msmtp nano ninja-build p7zip p7zip-full patch pkgconf python2.7 python3 python3-pip libpython3-dev qemu-utils \ 101 | rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev 102 | 103 | #sudo apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch python3 python2.7 unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core gcc-multilib p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint device-tree-compiler g++-multilib antlr3 gperf wget curl swig rsync bison g++ gcc help2man htop ncurses-term ocaml-nox sharutils yui-compressor make cmake 104 | } 105 | 106 | #显示编译文件夹 107 | ls_file() { 108 | LF=`ls $HOME/$OW | grep -v $0 | grep -v Script_File` 109 | echo -e "$green$LF$white" 110 | echo "" 111 | } 112 | ls_file_luci(){ 113 | clear && cd 114 | echo "***你的openwrt文件夹有以下几个***" 115 | ls_file 116 | read -p "请输入你的文件夹(记得区分大小写):" file 117 | if [[ -e $HOME/$OW/$SF/tmp ]]; then 118 | echo "$file" > $HOME/$OW/$SF/tmp/you_file 119 | else 120 | mkdir -p $HOME/$OW/$SF/tmp 121 | fi 122 | } 123 | 124 | #显示config文件夹 125 | ls_my_config() { 126 | LF=`ls My_config` 127 | echo -e "$green$LF$white" 128 | echo "" 129 | } 130 | 131 | #倒数专用 132 | Time() { 133 | seconds_left=3 134 | echo "" 135 | echo " ${seconds_left}秒以后执行代码" 136 | echo " 如果不需要执行代码以Ctrl+C 终止即可" 137 | echo "" 138 | while [[ ${seconds_left} -gt 0 ]]; do 139 | echo -n ${seconds_left} 140 | sleep 1 141 | seconds_left=$(($seconds_left - 1)) 142 | echo -ne "\r" 143 | done 144 | } 145 | 146 | #选项9.更新update_script 147 | update_script() { 148 | clear 149 | cd $shfile 150 | if [[ "$action1" == "" ]]; then 151 | git fetch --all 152 | git reset --hard origin/master 153 | if [[ $? -eq 0 ]]; then 154 | echo -e "$green>> 脚本源码更新成功$white" 155 | sleep 2 156 | else 157 | echo -e "$red>> 脚本源码更新失败,重新执行代码$white" 158 | update_script 159 | fi 160 | else 161 | git fetch --all 162 | git reset --hard origin/master 163 | if [[ $? -eq 0 ]]; then 164 | echo -e "$green>> 脚本源码更新成功$white" 165 | sleep 2 166 | else 167 | echo -e "$red>> 脚本源码更新失败,重新执行代码$white" 168 | update_script 169 | fi 170 | fi 171 | } 172 | 173 | #选项5.其他选项 174 | other() { 175 | clear 176 | echo " -------------------------------------" 177 | echo " 【 5.其他选项 】" 178 | echo "" 179 | echo " 1 只搭建编译环境,不进行编译" 180 | echo "" 181 | echo " 2 单独Download DL库 " 182 | echo "" 183 | echo " 3 更新lean软件库 " 184 | echo "" 185 | echo " 4 下载额外的插件 " 186 | echo "" 187 | echo " 0. 回到上一级菜单" 188 | echo "" 189 | echo "" 190 | echo " PS:请先搭建好梯子再进行编译,不然很慢!" 191 | echo " By:ITdesk" 192 | echo " --------------------------------------" 193 | read -p "请输入数字:" other_num 194 | case "$other_num" in 195 | 1) 196 | clear 197 | echo "5.1 只搭建编译环境,不进行编译 " && Time 198 | update_system 199 | echo "环境搭建完成,请自行创建文件夹和git" 200 | ;; 201 | 2) 202 | ls_file_luci 203 | dl_other 204 | ;; 205 | 3) 206 | update_lean_package 207 | ;; 208 | 4) 209 | download_package 210 | ;; 211 | 0) 212 | main_interface 213 | ;; 214 | *) 215 | clear && echo "请输入正确的数字 [1-4,0]" && Time 216 | other 217 | ;; 218 | esac 219 | } 220 | 221 | dl_other() { 222 | dl_download 223 | if [[ $? -eq 0 ]]; then 224 | echo "" 225 | echo -e ">>$green dl已经单独下载完成$white" 226 | else 227 | clear 228 | echo -e "$red dl没有下载成功,重新执行下载代码 $white" && Time 229 | dl_other 230 | fi 231 | 232 | } 233 | 234 | update_lean_package() { 235 | ls_file_luci 236 | source_make_clean 237 | rm -rf package/lean 238 | source_openwrt_Setting 239 | echo "插件下载完成" 240 | Time 241 | display_git_log_luci 242 | update_feeds 243 | source_config 244 | } 245 | 246 | download_package() { 247 | ls_file_luci 248 | if [[ -e package/Extra-plugin ]]; then 249 | echo "" 250 | else 251 | mkdir package/Extra-plugin 252 | fi 253 | download_package_luci 254 | 255 | } 256 | 257 | download_package2() { 258 | cd $HOME/$OW/$you_file/lede 259 | rm -rf ./tmp 260 | display_git_log_luci 261 | update_feeds 262 | source_config 263 | } 264 | 265 | 266 | download_package_luci() { 267 | cd $HOME/$OW/$you_file/lede/package/Extra-plugin 268 | clear 269 | echo " -------------------------------------" 270 | echo " 【 5.4额外的插件 】" 271 | echo "" 272 | echo " 1. luci-theme-argon" 273 | echo "" 274 | echo " 2. luci-app-oaf (测试中)" 275 | echo "" 276 | echo " 3. cups 共享打印机" 277 | echo "" 278 | echo " 4. luci-app-netkeeper(闪讯插件)" 279 | echo "" 280 | echo " 99. 自定义下载插件 " 281 | echo "" 282 | echo " 0. 回到上一级菜单" 283 | echo "" 284 | echo " PS:如果你有什么好玩的插件,可以提交给我" 285 | echo " --------------------------------------" 286 | read -p "请输入数字:" download_num 287 | case "$download_num" in 288 | 1) 289 | git clone https://github.com/jerrykuku/luci-theme-argon.git 290 | ;; 291 | 2) 292 | git clone https://github.com/destan19/OpenAppFilter.git 293 | ;; 294 | 3) 295 | cd $HOME/$OW/$you_file/lede/ 296 | if [[ `cat feeds.conf.default | grep "cups" | wc -l` -eq 0 ]]; then 297 | echo "src-git cups https://github.com/TheMMcOfficial/lede-cups.git" >> feeds.conf.default 298 | fi 299 | ./scripts/feeds update cups 300 | ./scripts/feeds install cups 301 | ;; 302 | 4) 303 | cd $HOME/$OW/$you_file/lede/ 304 | if [[ `cat feeds.conf.default | grep "netkeeper" | wc -l` -eq 0 ]]; then 305 | echo "src-git netkeeper https://github.com/sjz123321/feed-netkeeper.git" >> feeds.conf.default 306 | fi 307 | ./scripts/feeds update netkeeper 308 | ./scripts/feeds install netkeeper 309 | ;; 310 | 99) 311 | download_package_customize 312 | ;; 313 | 0) 314 | other 315 | ;; 316 | *) 317 | clear && echo "请输入正确的数字 [1-4,99,0]" && Time 318 | download_package_luci 319 | ;; 320 | esac 321 | if [[ $? -eq 0 ]]; then 322 | download_package_customize_Decide 323 | else 324 | clear 325 | echo -e "没有下载成功或者插件已经存在,请检查$red package/Extra-plugin $white里面是否已经存在" && Time 326 | download_package_customize 327 | fi 328 | } 329 | 330 | download_package_customize() { 331 | cd $HOME/$OW/$you_file/lede/package/Extra-plugin 332 | clear 333 | echo "--------------------------------------------------------------------------------" 334 | echo "自定义下载插件" 335 | echo "" 336 | echo -e " $green例子:git clone https://github.com/destan19/OpenAppFilter.git (此插件用于过滤应用)$white" 337 | echo "--------------------------------------------------------------------------------" 338 | echo "" 339 | read -p "请输入你要下载的插件地址:" download_url 340 | $download_url 341 | if [[ $? -eq 0 ]]; then 342 | cd $HOME/$OW/$you_file/lede 343 | else 344 | clear 345 | echo -e "没有下载成功或者插件已经存在,请检查$red package/Extra-plugin $white里面是否已经存在" && Time 346 | download_package_customize 347 | fi 348 | download_package_customize_Decide 349 | 350 | } 351 | 352 | download_package_customize_Decide() { 353 | echo "----------------------------------------" 354 | echo -e "$green是否需要继续下载插件$white" 355 | echo " 1.继续下载插件" 356 | echo " 2.不需要了" 357 | echo "----------------------------------------" 358 | read -p "请输入你的决定:" Decide 359 | case "$Decide" in 360 | 1) 361 | cd $HOME/$OW/$you_file/lede/package/Extra-plugin 362 | download_package_luci 363 | ;; 364 | 2) 365 | download_package2 366 | ;; 367 | *) 368 | clear && echo -e"$red Error请输入正确的数字 [1-2]$white" && Time 369 | clear && download_package_customize_Decide 370 | ;; 371 | esac 372 | } 373 | 374 | 375 | #选项4.恢复编译环境 376 | source_RestoreFactory() { 377 | ls_file_luci 378 | echo "" 379 | if [[ -e $HOME/$OW/$you_file ]]; then 380 | cd $HOME/$OW/$you_file/lede 381 | echo -e "危险操作注意:$red所有编译过的文件全部删除,openwrt源代码保存,回车继续$white $green Ctrl+c取消$white" && read a 382 | echo -e ">>$green开始删除$file文件 $white" && Time 383 | echo "" 384 | else 385 | clear && echo "-----文件名错误,请重新输入-----" && Time 386 | source_RestoreFactory 387 | fi 388 | make distclean 389 | ln -s $HOME/$OW/$SF/dl $HOME/$OW/$you_file/lede/dl 390 | echo -e ">>$green $file文件删除完成 $white" 391 | echo -e " 所有编译过的文件全部删除完成,回车可以开始编译 不需要编译Ctrl+c取消,如依旧编译失败,请重新下载源代码" && read a 392 | source_if 393 | display_git_log_luci 394 | } 395 | 396 | #选项2.二次编译 与 源码更新合并 397 | source_secondary_compilation() { 398 | ls_file_luci 399 | if [[ -e $HOME/$OW/$you_file ]]; then 400 | cd && cd $HOME/$OW/$you_file/lede 401 | else 402 | clear && echo "-----文件名错误,请重新输入-----" && Time 403 | source_secondary_compilation 404 | fi 405 | echo "开始清理之前的文件" 406 | source_make_clean && rm -rf ./tmp && Time 407 | if [[ `grep -o "PandoraBox" .config | wc -l` == "2" ]]; then 408 | echo "检测到PandoraBox源码,开始更新" 409 | rm -rf package/lean && rm -rf ./feeds 410 | source_lean_package 411 | source_Soft_link 412 | update_feeds 413 | else 414 | source_if 415 | display_git_log_luci 416 | fi 417 | } 418 | 419 | #显示git log 提交记录 420 | display_git_log() { 421 | git log -3 --graph --all --branches --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(bold green)(%ai)%C(reset) %C(white)%s%C(reset) %C(yellow) - %an%C(reset)%C(auto) %d%C(reset)' 422 | #参考xueguang668 423 | } 424 | 425 | display_git_log_if() { 426 | git_branch=$(git branch -v | grep -o 落后 ) 427 | if [[ "$git_branch" == "落后" ]]; then 428 | echo -e "$yellow自动检测:$white $red本地源码已经落后远端,建议更新$white" 429 | else 430 | echo -e "$yellow自动检测:$white $green本地源码与远端一样$white" 431 | fi 432 | } 433 | 434 | display_git_log_luci() { 435 | clear 436 | echo "稍等一下,正在取回分支,用于比较现在源码,不会更新请放心,速度看你网络" 437 | git fetch 438 | if [[ $? -eq 0 ]]; then 439 | echo "" 440 | else 441 | echo -e "$red>> 取回分支没有成功,重新执行代码$white" && Time 442 | display_git_log_luci 443 | fi 444 | clear 445 | echo "----------------------------------------" 446 | echo -e " $green显示远端仓库最近三条更新内容$white " 447 | echo "----------------------------------------" 448 | echo "" 449 | display_git_log 450 | echo "" 451 | echo -e "$yellow你所在的文件夹:$white $green $file $white" 452 | display_git_log_if 453 | echo -e "$yellow你现在所用的分支版本:$white`git branch -v`" 454 | echo "" 455 | read -p "是否需要更新源码(1.yes 2.no 3.退到/进到某个版本):" update_source 456 | case "$update_source" in 457 | 1) 458 | rm -rf ./feeds && source_update && rm -rf ./tmp && source_openwrt && update_feeds 459 | ;; 460 | 2) 461 | source_openwrt && update_feeds 462 | ;; 463 | 3) 464 | git_reset && source_openwrt && update_feeds 465 | ;; 466 | *) 467 | clear && echo "Error请输入正确的数字 [1-2]" && Time 468 | display_git_log_luci 469 | ;; 470 | esac 471 | if [[ "$?" == "0" ]]; then 472 | source_lean 473 | source_lienol 474 | source_Setting_Public 475 | source_config 476 | make_defconfig 477 | ecc 478 | else 479 | echo -e "$red >>命令错误或者网络不好,重新执行代码$white" && Time 480 | display_git_log_luci 481 | fi 482 | 483 | } 484 | 485 | 486 | git_reset() { 487 | clear 488 | echo "----------------------------------------" 489 | echo -e " $green Git reset 回退到某个版本$white " 490 | echo "----------------------------------------" 491 | echo -e "$green >>例子$white" 492 | echo -e " git reset --hard HEAD^ $green回退到上个版本$white" 493 | echo -e " git reset --hard HEAD~3 $green回退到前3次提交之前,以此类推$white" 494 | echo -e " git reset --hard (commit_id) $green退到/进到 指定commit的sha码(不会的百度)$white" 495 | echo "" 496 | echo -e "$yellow你所在的文件夹:$white $green $file $white" 497 | echo -e "$yellow你现在所用的分支版本:$white`git branch -v`" 498 | echo "" 499 | read -p "请输入你的命令(手动敲别偷懒):" git_reset_read 500 | $git_reset_read 501 | rm -rf ./feeds && rm -rf ./tmp 502 | if [[ "$?" == "0" ]]; then 503 | clear 504 | echo "" 505 | echo -e "$green >>命令执行完成$white" 506 | echo -e "$yellow你现在所用的分支版本:$white`git branch -v`" && Time 507 | else 508 | echo -e "$red >>命令错误或者网络不好,重新执行代码$white" && Time 509 | git_reset 510 | fi 511 | } 512 | 513 | source_config() { 514 | clear 515 | echo "----------------------------------------------------------------------" 516 | echo -e "$green选择编译方式$white" 517 | echo "" 518 | echo " 1.以全新的config进行编译 (适合编译新机型)" 519 | echo " 2.继续上次的编译(不对配置做任何操作)" 520 | echo "" 521 | echo -e "$yellow PS:如果源码进行过重大更新,建议直接选择1.以全新config进行编译,以减少报错$white" 522 | echo "----------------------------------------------------------------------" 523 | read -p "请输入你的决定:" config 524 | case "$config" in 525 | 1) 526 | rm -rf .config && rm -rf ./tmp 527 | ;; 528 | 2) 529 | echo "" 530 | ;; 531 | *) 532 | clear && echo "Error请输入正确的数字 [1-2]" && Time 533 | source_config 534 | ;; 535 | esac 536 | } 537 | 538 | Save_My_Config_luci() { 539 | clear && echo "------------------------------------------------" 540 | echo "是否要保存你的配置,以备下次使用(1.是 2.否 )" 541 | echo "注:同一名字的文件会覆盖" 542 | echo "------------------------------------------------" 543 | read -p "请输入你的决定:" save 544 | case "$save" in 545 | 1) 546 | save_my_config_yes 547 | ;; 548 | 2) 549 | ;; 550 | *) 551 | clear && echo "请输入正确的数字 [1-2]" && Time 552 | Save_My_Config_luci 553 | ;; 554 | esac 555 | } 556 | 557 | save_my_config_yes() { 558 | read -p "请输入你的配置名:" mange_config 559 | cp .config My_config/$mange_config 560 | echo "******配置保存完成回车进行编译*******" && read a 561 | } 562 | 563 | transfer_my_config() { 564 | clear 565 | echo "你的配置文件如下:" 566 | echo "" 567 | ls_my_config 568 | echo "" 569 | read -p "请输入你要调用的配置名(记得区分大小写):" transfer 570 | if [[ -e `pwd`/My_config/$transfer ]]; then 571 | Time && clear 572 | echo "正在调用" 573 | rm -rf .config 574 | cp My_config/$transfer .config 575 | echo "配置加载完成" && Time 576 | 577 | else 578 | clear && echo "调用错误" && Time 579 | transfer_my_config 580 | fi 581 | } 582 | 583 | #源码更新 584 | source_update() { 585 | clear 586 | echo "------------------------------------------------------------------" 587 | echo -e "$green***准备开始更新openwrt源代码与软件***$white" 588 | echo "" 589 | echo "有没有改动过源代码,因为改动过源代码可能会导致git pull失效无法更新" 590 | echo "1.是 2.否 " 591 | echo " " 592 | echo "------------------------------------------------------------------" 593 | read -p "请输入你的决定:" git_source 594 | case "$git_source" in 595 | 1) 596 | source_update_No_git_pull 597 | ;; 598 | 2) 599 | source_update_git_pull 600 | ;; 601 | *) 602 | clear && echo "Error请输入正确的数字 [1-2]" && Time 603 | source_update 604 | ;; 605 | esac 606 | if [[ "$?" == "0" ]]; then 607 | echo -e "$green >>源码更新完成$white" && Time 608 | else 609 | echo -e "$red >>源码更新失败,重新执行代码$white" && Time 610 | source_update 611 | fi 612 | } 613 | 614 | source_update_No_git_pull() { 615 | if [ -z ${source_branch} ];then 616 | source_branch=$(cat "$HOME/$OW/$SF/tmp/source_branch") 617 | fi 618 | 619 | clear 620 | if [[ "$source_branch" == "" ]]; then 621 | git fetch --all 622 | git reset --hard origin/master 623 | else 624 | git fetch --all 625 | git reset --hard origin/$source_branch 626 | if [[ $? -eq 0 ]]; then 627 | echo -e "$green>> 源码更新$white" 628 | sleep 1 629 | else 630 | echo -e "$red>> 源码更新失败,重新执行代码$white" && Time 631 | source_update_No_git_pull 632 | fi 633 | fi 634 | } 635 | 636 | source_update_git_pull() { 637 | git pull 638 | if [[ $? -eq 0 ]]; then 639 | echo "" 640 | else 641 | echo -e "$red>> 源码更新失败,重新执行代码$white" && Time 642 | source_update_git_pull 643 | fi 644 | } 645 | 646 | #选项1.开始搭建编译环境与主菜单 647 | 648 | #判断代码 649 | description_if(){ 650 | cd 651 | clear 652 | echo "开始检测系统" 653 | curl_if=$(dpkg -l | grep -o "curl" |sed -n '1p' | wc -l) 654 | if [[ "$curl_if" == "0" ]]; then 655 | clear && echo "安装一下脚本用的依赖(注:不是openwrt的依赖而是脚本本身)" 656 | sudo apt update 657 | sudo apt install curl -y 658 | else 659 | clear && echo -e "$green已经安装curl$white" 660 | fi 661 | 662 | :<<'COMMENT' 663 | #解决golang下载慢的问题,来源:https://goproxy.cn/ 664 | if [[ ! "$GO111MODULE" == "no" ]]; thendescription_if 665 | echo "export GO111MODULE=on" | sudo tee -a /etc/profile 666 | echo "export GOPROXY=https://goproxy.cn" | sudo tee -a /etc/profile 667 | source /etc/profile 668 | fi 669 | COMMENT 670 | 671 | if [[ ! -d "$HOME/$OW/$SF/$OCS" ]]; then 672 | echo "开始创建主文件夹" 673 | mkdir -p $HOME/$OW/$SF/dl 674 | mkdir -p $HOME/$OW/$SF/My_config 675 | mkdir -p $HOME/$OW/$SF/tmp 676 | fi 677 | 678 | #清理一下之前的编译文件 679 | rm -rf $HOME/$OW/$SF/tmp/* 680 | 681 | #判断是否云编译 682 | workspace_home=`echo "$HOME" | grep gitpod | wc -l` 683 | if [[ "$workspace_home" == "1" ]]; then 684 | echo "$yellow请注意云编译已经放弃维护很久了description_if,不保证你能编译成功,太耗时耗力,你如果不信邪你可以回车继续$white" 685 | read a 686 | echo "开始添加云编译系统变量" 687 | Cloud_env=`gp env | grep -o "shfile" | wc -l ` 688 | if [[ "$Cloud_env" == "0" ]]; then 689 | eval $(gp env -e openwrt=$THEIA_WORKSPACE_ROOT/Openwrt/Script_File/OpenwrtCompileScript/openwrt.sh) 690 | eval $(gp env -e shfile=$THEIA_WORKSPACE_ROOT/Openwrt/Script_File/OpenwrtCompileScript) 691 | echo -e "系统变量添加完成,老样子启动 bash \$openwrt" 692 | Time 693 | fi 694 | HOME=`echo "$THEIA_WORKSPACE_ROOT"` 695 | else 696 | #添加系统变量 697 | openwrt_shfile_path=$(cat /etc/profile | grep -o shfile | wc -l) 698 | openwrt_script_path=$(cat /etc/profile | grep -o openwrt.sh | wc -l) 699 | if [[ "$openwrt_shfile_path" == "0" ]]; then 700 | echo "export shfile=$HOME/Openwrt/Script_File/OpenwrtCompileScript" | sudo tee -a /etc/profile 701 | echo -e "$green添加openwrt脚本变量成功,以后无论在那个目录输入 cd \$shfile 都可以进到脚本目录$white" 702 | #clear 703 | elif [[ "$openwrt_script_path" == "0" ]]; then 704 | echo "export openwrt=$HOME/Openwrt/Script_File/OpenwrtCompileScript/openwrt.sh" | sudo tee -a /etc/profile 705 | #clear 706 | echo "-----------------------------------------------------------------------" 707 | echo "" 708 | echo -e "$green添加openwrt变量成功,重启系统以后无论在那个目录输入 bash \$openwrt 都可以运行脚本$white" 709 | echo "" 710 | echo "" 711 | echo -e " $green回车重启你的操作系统!!!$white" 712 | echo "-----------------------------------------------------------------------" 713 | read a 714 | Time 715 | rm -rf `pwd`/$OCS 716 | reboot 717 | else 718 | echo "系统变量已经添加" 719 | fi 720 | 721 | fi 722 | 723 | if [[ -e $HOME/$OW/$SF/$OCS ]]; then 724 | echo "存在" 725 | else 726 | cd $HOME/$OW/$SF/ 727 | git clone https://github.com/openwrtcompileshell/OpenwrtCompileScript.git 728 | cd 729 | rm -rf `pwd`/$OCS 730 | cd $HOME/$OW/$SF/$OCS 731 | bash openwrt.sh 732 | fi 733 | 734 | :<<'COMMENT' 735 | #win10 736 | check_win10_system=$(cat /proc/version |grep -o Microsoft@Microsoft.com) 737 | check_win10_system01=$(cat /proc/version |grep -o microsoft-standard) 738 | if [[ "$check_win10_system" == "Microsoft@Microsoft.com" ]]; then 739 | win10 740 | elif [[ "$check_win10_system01" == "microsoft-standard" ]]; then 741 | win10 742 | else 743 | echo "不是win10系统" && clear 744 | fi 745 | 746 | 747 | 748 | clear 749 | 750 | if [[ -e $HOME/$OW/$SF/description ]]; then 751 | self_test 752 | main_interface 753 | else 754 | clear 755 | description 756 | echo "" 757 | read -p "请输入密码:" ps 758 | if [[ $ps == $by ]]; then 759 | description >> $HOME/$OW/$SF/description && clear && self_test && main_interface 760 | else 761 | clear && echo "+++++密码错误++++++" && Time && description_if 762 | fi 763 | fi 764 | COMMENT 765 | 766 | clear 767 | echo "" 768 | echo -e "$red图形界面编译已停止维护,请参考底下命令行进行编译$white" 769 | 770 | } 771 | 772 | win10() { 773 | export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games" 774 | if [[ -e /etc/apt/sources.list.back ]]; then 775 | clear && echo -e "$green源码已替换$white" 776 | else 777 | clear 778 | echo "-----------------------------------------------------------------" 779 | echo "+++检测到win10子系统+++" 780 | echo "" 781 | echo " win10子系统已知问题" 782 | echo " 1.IO很慢,编译很慢,不怕耗时间随意" 783 | echo " 2.win10对大小写不敏感,你需要百度如何开启win10子系统大小写敏感" 784 | echo " 3.需要替换子系统的linux源(脚本可以帮你搞定)" 785 | echo "-----------------------------------------------------------------" 786 | echo "" 787 | read -p "是否替换软件源然后进行编译(1.yes,2.no):" win10_select 788 | case "$win10_select" in 789 | 1) 790 | clear 791 | echo -e "$green开始替换软件源$white" && Time 792 | sudo cp /etc/apt/sources.list /etc/apt/sources.list.back 793 | sudo rm -rf /etc/apt/sources.list 794 | sudo cp $HOME/$OW/$SF/$OCS/ubuntu18.4_sources.list /etc/apt/sources.list 795 | sudo apt-get update 796 | sudo apt-get install git-core build-essential libssl-dev libncurses5-dev unzip 797 | ;; 798 | 2) 799 | clear 800 | echo "不做任何操作,即将进入主菜单" && Time 801 | ;; 802 | *) 803 | clear && echo "Error请输入正确的数字 [1-2]" && Time 804 | description_if 805 | ;; 806 | esac 807 | 808 | fi 809 | } 810 | 811 | self_test() { 812 | clear 813 | CheckUrl_google=$(curl -I -m 2 -s -w "%{http_code}\n" -o /dev/null www.google.com) 814 | 815 | if [[ "$CheckUrl_google" -eq "200" ]]; then 816 | Check_google=`echo -e "$green网络正常$white"` 817 | else 818 | Check_google=`echo -e "$red网络较差$white"` 819 | fi 820 | 821 | CheckUrl_baidu=$(curl -I -m 2 -s -w "%{http_code}\n" -o /dev/null www.baidu.com) 822 | if [[ "$CheckUrl_baidu" -eq "200" ]]; then 823 | Check_baidu=`echo -e "$green百度正常$white"` 824 | else 825 | Check_baidu=`echo -e "$red百度无法打开,请修复这个错误$white"` 826 | fi 827 | 828 | Root_detection=`id -u` # 学渣代码改良版 829 | if [[ "$Root_detection" -eq "0" ]]; then 830 | Root_run=`echo -e "$red请勿以root运行,请修复这个错误$white"` 831 | else 832 | Root_run=`echo -e "$green非root运行$white"` 833 | fi 834 | 835 | 836 | clear 837 | echo "稍等一下,正在取回远端脚本源码,用于比较现在脚本源码,速度看你网络" 838 | cd && cd $HOME/$OW/$SF/$OCS 839 | git fetch 840 | if [[ $? -eq 0 ]]; then 841 | echo "" 842 | else 843 | echo -e "$red>> 取回分支没有成功,重新执行代码$white" && Time 844 | self_test 845 | fi 846 | clear 847 | git_branch=$(git branch -v | grep -o 落后 ) 848 | if [[ "$git_branch" == "落后" ]]; then 849 | Script_status=`echo -e "$red建议更新$white"` 850 | else 851 | Script_status=`echo -e "$green最新$white"` 852 | fi 853 | 854 | echo " -------------------------------------------" 855 | echo " 【 Script Self-Test Program 】" 856 | echo "" 857 | echo " 检测是否root运行: $Root_run " 858 | echo "" 859 | echo " 检测与DL网络情况: $Check_google " 860 | echo " " 861 | echo " 检测百度是否正常: $Check_baidu " 862 | echo " " 863 | echo " 检测脚本是否最新: $Script_status " 864 | echo " " 865 | echo " -------------------------------------------" 866 | echo "" 867 | echo -e "$green 脚本问题反馈:https://github.com/openwrtcompileshell/OpenwrtCompileScript/issues或者加群反馈(群在github有)$white" 868 | echo "" 869 | echo " 请自行决定是否修复红字的错误,以保证编译顺利,你也可以直接回车进入菜单,但有可能会出现编译失败!!!如果都是绿色正常可以忽略此段话" 870 | read a 871 | } 872 | 873 | description() { 874 | echo " +++++++++++++++++++++++++++++++++++++++" 875 | echo " ++欢迎使用Openwrt-Compile-Script Ver $version ++" 876 | echo " +++++++++++++++++++++++++++++++++++++++" 877 | echo "" 878 | echo -e " 创建脚本的初衷是因($red I $white)为openwrt编译的时候有些东西太繁琐了,为了简化掉一些操作,使编译更加简单就有了此脚本($red T $white)的诞生,后面觉得好玩就分享给了大家一起玩耍,你需要清楚此脚本仅用于学习,有一定危险性,请勿进行商用,如果商用导致损失或者其他问题,均由使用者自行承担!!!" 879 | echo "" 880 | echo "下面简单给大家描述脚本的作用" 881 | echo -e " 1.协助你更快的搭建编译环境,小白($red d $white)建议学习一下再用会比较好" 882 | echo -e " 2.统一管理你的编译源,全部($red e $white)存放在Openwrt这个文件里面" 883 | echo " 3.你只要启动脚本就可以控制你的源,进行二次编译或者更新" 884 | echo "" 885 | echo -e "缺陷1:小白($red s $white)不太适合,因为他们不了解过程" 886 | echo -e "缺陷2:不能自定义openwrt代码或者修改,此脚本适合做重复的事情($red k $white)" 887 | echo "" 888 | echo "注:请自行将你系统的软件源更换为国内的服务器,不会请百度" 889 | echo "" 890 | echo "" 891 | echo "请阅读完上面的前言,()红字里面的就是密码,此界面只会出现一次,后面就不会了" 892 | } 893 | 894 | #主菜单 895 | main_interface() { 896 | clear 897 | echo " -------------------------------------" 898 | echo " 【 Openwrt Compile Script Ver ${version}版 】" 899 | echo "" 900 | echo " 1.搭建编译环境" 901 | echo "" 902 | echo " 2.二次编译固件" 903 | echo "" 904 | echo " 4.恢复编译环境" 905 | echo "" 906 | echo " 5.其他选项" 907 | echo "" 908 | echo " 9.更新脚本" 909 | echo "" 910 | echo " 0. EXIT" 911 | echo "" 912 | echo "" 913 | echo " PS:请先搭建好梯子再进行编译,不然很慢!" 914 | echo " By:ITdesk" 915 | echo " --------------------------------------" 916 | read -p "请输入数字:" num 917 | case "$num" in 918 | 1) 919 | system_install 920 | ;; 921 | 2) 922 | source_secondary_compilation 923 | ;; 924 | 4) 925 | source_RestoreFactory 926 | ;; 927 | 5) 928 | other 929 | ;; 930 | 9) 931 | update_script 932 | ;; 933 | 99) 934 | cd $HOME/$OW/lean/lede/ 935 | n1_builder 936 | ;; 937 | 0) 938 | exit 939 | ;; 940 | *) 941 | clear && echo "请输入正确的数字 [1-5,9,0]" && Time 942 | main_interface 943 | ;; 944 | esac 945 | } 946 | 947 | system_install() { 948 | clear 949 | echo -e "$green>> 是否要更新系统,首次搭建选择是,其余选否(1.是 2.否)$white" 950 | read -p "请输入你的决定:" system 951 | case "$system" in 952 | 1) 953 | update_system 954 | create_file 955 | ;; 956 | 2) 957 | create_file 958 | ;; 959 | *) 960 | clear && echo "请输入正确的数字 [1-2]" && Time 961 | system_install 962 | ;; 963 | esac 964 | } 965 | 966 | update_system() { 967 | clear 968 | clear && echo -e "$green >>准备更新系统 $white" && Time 969 | sudo apt-get update 970 | clear 971 | javahome=`echo "$JAVA_HOME" | grep gitpod | wc -l` 972 | if [[ "$javahome" == "1" ]]; then 973 | clear 974 | echo -e "$green >>检测到你是gitpod云编译主机,不需要安装依赖,直接创建文件夹即可 $white" && Time 975 | create_file 976 | else 977 | echo -e "$green >>准备安装依赖 $white" && Time 978 | rely_on 979 | if [[ $? -eq 0 ]]; then 980 | echo -e "$green >>安装完成 $white" && Time 981 | else 982 | clear 983 | echo -e "$red 依赖没有更新或安装成功,重新执行代码 $white" && Time 984 | update_system 985 | fi 986 | fi 987 | } 988 | 989 | create_file() { 990 | clear 991 | echo "----------------------------------------" 992 | echo -e " $green开始创建文件夹$white" 993 | echo "----------------------------------------" 994 | echo "" 995 | read -p "请输入你要创建的文件夹名(不要中文):" you_file 996 | 997 | if [[ -z "$you_file" ]];then 998 | echo -e "$red请不要输入空值!!!$white" 999 | Time 1000 | create_file 1001 | elif [[ -e $HOME/$OW/$you_file ]]; then 1002 | clear 1003 | echo -e "$green你输入的$yellow$you_file$green文件夹在$yellow$HOME/$OW$green已存在,请重新输入文件夹名$white" && Time 1004 | create_file 1005 | else 1006 | echo "开始创建文件夹" 1007 | mkdir $HOME/$OW/$you_file 1008 | cd $HOME/$OW/$you_file && clear 1009 | echo "$you_file" > $HOME/$OW/$SF/tmp/you_file 1010 | #source_download_select 1011 | source_download_openwrt 1012 | fi 1013 | } 1014 | 1015 | source_download_select() { 1016 | clear 1017 | echo " -----------------------------------------" 1018 | echo "" 1019 | echo " 选择你要编译的类型" 1020 | echo "" 1021 | echo " 1.Openwrt" 1022 | echo "" 1023 | echo " 2.Pandorabox_SDK" 1024 | echo "" 1025 | echo " ----------------------------------------" 1026 | read -p "请输入你要编译的类型:" Download_select 1027 | case "$Download_select" in 1028 | 1) 1029 | source_download_openwrt 1030 | ;; 1031 | 2) 1032 | source_download_pandorabox_sdk 1033 | ;; 1034 | 0) 1035 | exit 1036 | ;; 1037 | *) 1038 | clear && echo "请输入正确的数字(1-2,0)" && Time 1039 | source_download_select 1040 | ;; 1041 | esac 1042 | } 1043 | 1044 | source_download_openwrt() { 1045 | clear 1046 | echo " -----------------------------------------" 1047 | echo -e " $green准备下载openwrt代码$white" 1048 | #echo -e " $green默认下载:${yellow}Lean_master_source$white" 1049 | echo " -----------------------------------------" 1050 | echo "" 1051 | echo -e " 1.Lean_master_source $yellow(* 推荐,我个人用的比较多)$white" 1052 | echo "" 1053 | echo " 2.immortalwrt_openwrt-18.06-k5.4" 1054 | echo "" 1055 | read -p "请输入你要下载的源代码:" Download_source_openwrt 1056 | case "$Download_source_openwrt" in 1057 | 1) 1058 | git clone https://github.com/coolsnowwolf/lede.git lede 1059 | echo "lean" > $HOME/$OW/$SF/tmp/source_type 1060 | ;; 1061 | 2) 1062 | git clone -b openwrt-18.06-k5.4 --single-branch https://github.com/immortalwrt/immortalwrt lede 1063 | echo "immortalwrt" > $HOME/$OW/$SF/tmp/source_type 1064 | ;; 1065 | *) 1066 | clear && echo "请输入正确的数字(1-2)" && Time 1067 | source_download_openwrt 1068 | ;; 1069 | esac 1070 | 1071 | :<<'COMMENT' 1072 | echo "" 1073 | echo "" 1074 | echo " 1.Lean_lede-17.01_source(我很久没对这个进行测试了)" 1075 | echo "" 1076 | echo " 2.Lean_master_source" 1077 | echo "" 1078 | echo " 3.Lienol(dev-19.07)_source(我很久没对这个进行测试了)" 1079 | echo "" 1080 | echo " 4.openwrt17.1(stable version)_source(我很久没对这个进行测试了)" 1081 | echo "" 1082 | echo " 5.openwrt18.6(stable version)_source(我很久没对这个进行测试了)" 1083 | echo "" 1084 | echo " 6.openwrt19.7(stable version)_source(我很久没对这个进行测试了)" 1085 | echo "" 1086 | echo " 7.openwrt(Trunk)_source(我很久没对这个进行测试了)" 1087 | echo "" 1088 | echo " 0.exit" 1089 | echo "" 1090 | echo "我现在经常用lean的源码,并且我已很长时间没有维护这个互动界面了,你可以bash \$openwrt help查看命令用法" 1091 | echo " ----------------------------------------" 1092 | read -p "请输入你要下载的源代码:" Download_source_openwrt 1093 | case "$Download_source_openwrt" in 1094 | 1) 1095 | git clone -b lede-17.01 https://github.com/coolsnowwolf/openwrt.git lede 1096 | ;; 1097 | 2) 1098 | git clone https://github.com/coolsnowwolf/lede.git lede 1099 | ;; 1100 | 3) 1101 | git clone https://github.com/Lienol/openwrt.git lede 1102 | ;; 1103 | 4) 1104 | git clone -b lede-17.01 https://github.com/openwrt/openwrt.git lede 1105 | ;; 1106 | 5) 1107 | git clone -b openwrt-18.06 https://github.com/openwrt/openwrt.git lede 1108 | ;; 1109 | 6) 1110 | git clone -b openwrt-19.07 https://github.com/openwrt/openwrt.git lede 1111 | ;; 1112 | 7) 1113 | git clone https://github.com/openwrt/openwrt.git lede 1114 | ;; 1115 | 0) 1116 | exit 1117 | ;; 1118 | *) 1119 | clear && echo "请输入正确的数字(1-6,0)" && Time 1120 | source_download_openwrt 1121 | ;; 1122 | esac 1123 | COMMENT 1124 | echo -e "$green你的源码已经为你下载到了$yellow$HOME/$OW/$you_file$white" 1125 | Time 1126 | source_download_if 1127 | } 1128 | 1129 | source_download_pandorabox_sdk() { 1130 | clear 1131 | echo " ----------------------------------------" 1132 | echo "" 1133 | echo " 准备下载Pandorabox_SDK代码" 1134 | echo "" 1135 | echo " 1.PandoraBox-SDK-ralink-mt7621" 1136 | echo "" 1137 | echo " 0.exit" 1138 | echo "" 1139 | echo "" 1140 | echo " 注:此源码只是SDK用于编译Pandorabox的插件" 1141 | echo " 并不是Pandorabox的源码.不懂百度" 1142 | #echo "PS:为什么不顺便放Openwrt的SDK呢,因为他的平台太多了,工程量巨大,先不考虑" 1143 | echo " ----------------------------------------" 1144 | read -p "请输入你要下载的源代码:" Download_source_pandorabox_sdk 1145 | case "$Download_source_pandorabox_sdk" in 1146 | 1) 1147 | wget --no-check-certificate http://downloads.pangubox.com:6380/sdk_for_pear/PandoraBox-SDK-ralink-mt7621_gcc-5.5.0_uClibc-1.0.x.Linux-x86_64.tar.xz 1148 | tar -xvJf PandoraBox-SDK-ralink-mt7621_gcc-5.5.0_uClibc-1.0.x.Linux-x86_64.tar.xz 1149 | mv PandoraBox-SDK-ralink-mt7621_gcc-5.5.0_uClibc-1.0.x.Linux-x86_64 lede 1150 | rm -rf PandoraBox-SDK-ralink-mt7621_gcc-5.5.0_uClibc-1.0.x.Linux-x86_64.tar.xz 1151 | rm -rf lede/dl 1152 | ln -s $HOME/$OW/$SF/dl $HOME/$OW/$you_file/lede/dl 1153 | wget --no-check-certificate https://raw.githubusercontent.com/coolsnowwolf/lede/master/feeds.conf.default -O $HOME/$OW/$you_file/lede/feeds.conf.default 1154 | source_lean_package 1155 | cd $HOME/$OW/$you_file/lede 1156 | source_Soft_link 1157 | update_feeds 1158 | make_defconfig 1159 | ;; 1160 | 0) 1161 | exit 1162 | ;; 1163 | *) 1164 | clear && echo "请输入正确的数字(1,0)" && Time 1165 | source_download_pandorabox_sdk 1166 | ;; 1167 | esac 1168 | source_download_if 1169 | } 1170 | 1171 | source_download_if() { 1172 | if [[ -e $HOME/$OW/$you_file/lede ]]; then 1173 | cd $HOME/$OW/$you_file/lede 1174 | source_download_ok 1175 | ecc 1176 | else 1177 | echo "" 1178 | echo "源码下载失败,请检查你的网络,回车重新选择下载" && read a && Time 1179 | cd $HOME/$OW/$you_file 1180 | source_download_select 1181 | fi 1182 | } 1183 | 1184 | source_download_ok() { 1185 | #source_if 1186 | source_Soft_link 1187 | update_feeds 1188 | #source_openwrt 1189 | source_lean 1190 | #source_lienol 1191 | source_Setting_Public 1192 | make_defconfig 1193 | } 1194 | 1195 | source_if() { 1196 | #检测源码属于那个版本 1197 | source_git_branch=$(git branch | sed 's/* //g') 1198 | if [[ `git remote -v | grep -o https://github.com/openwrt/openwrt.git | wc -l` == "2" ]]; then 1199 | echo "openwrt" > $HOME/$OW/$SF/tmp/source_type 1200 | if [[ $source_git_branch == "lede-17.01" ]]; then 1201 | echo "lede-17.01" > $HOME/$OW/$SF/tmp/source_branch 1202 | elif [[ $source_git_branch == "openwrt-18.06" ]]; then 1203 | echo "openwrt-18.06" > $HOME/$OW/$SF/tmp/source_branch 1204 | elif [[ $source_git_branch == "openwrt-19.07" ]]; then 1205 | echo "openwrt-19.07" > $HOME/$OW/$SF/tmp/source_branch 1206 | elif [[ $source_git_branch == "master" ]]; then 1207 | echo "master" > $HOME/$OW/$SF/tmp/source_branch 1208 | fi 1209 | elif [[ `git remote -v | grep -o https://github.com/coolsnowwolf/openwrt.git | wc -l` == "2" ]]; then 1210 | echo "lean" > $HOME/$OW/$SF/tmp/source_type 1211 | echo "lede-17.01" > $HOME/$OW/$SF/tmp/source_branch 1212 | 1213 | elif [[ `git remote -v | grep -o https://github.com/coolsnowwolf/lede.git | wc -l` == "2" ]]; then 1214 | echo "lean" > $HOME/$OW/$SF/tmp/source_type 1215 | if [[ $source_git_branch == "master" ]]; then 1216 | echo "master" > $HOME/$OW/$SF/tmp/source_branch 1217 | elif [[ $source_git_branch == "lede-17.01" ]]; then 1218 | echo "lede-17.01" > $HOME/$OW/$SF/tmp/source_branch 1219 | fi 1220 | 1221 | elif [[ `git remote -v | grep -o https://github.com/Lienol/openwrt.git | wc -l` == "2" ]]; then 1222 | echo "lienol" > $HOME/$OW/$SF/tmp/source_type 1223 | if [[ $source_git_branch == "my-19.07-full" ]]; then 1224 | echo "my-19.07-full" > $HOME/$OW/$SF/tmp/source_branch 1225 | fi 1226 | 1227 | else 1228 | echo -e "检查到你的源码是:$red未知源码$white" 1229 | echo -e "是否继续运行脚本!!!运行请回车,不运行请终止脚本" 1230 | echo "unknown" > $HOME/$OW/$SF/tmp/source_type 1231 | read a 1232 | fi 1233 | } 1234 | 1235 | 1236 | source_Soft_link() { 1237 | #1 1238 | if [[ -e $HOME/$OW/$SF/description ]]; then 1239 | echo "" 1240 | else 1241 | description >> $HOME/$OW/$SF/description 1242 | fi 1243 | 1244 | #2 1245 | if [[ -e $HOME/$OW/$you_file/lede/dl ]]; then 1246 | echo "" 1247 | else 1248 | ln -s $HOME/$OW/$SF/dl $HOME/$OW/$you_file/lede/dl 1249 | fi 1250 | 1251 | #3 1252 | if [[ -e $HOME/$OW/$you_file/lede/My_config ]]; then 1253 | echo "" 1254 | else 1255 | ln -s $HOME/$OW/$SF/My_config $HOME/$OW/$you_file/lede/My_config 1256 | fi 1257 | 1258 | #4 1259 | if [[ -e $HOME/$OW/$you_file/lede/openwrt.sh ]]; then 1260 | echo "" 1261 | else 1262 | ln -s $HOME/$OW/$SF/$OCS/openwrt.sh $HOME/$OW/$you_file/lede/openwrt.sh 1263 | fi 1264 | 1265 | } 1266 | 1267 | 1268 | source_openwrt() { 1269 | clear 1270 | source_type=`cat "$HOME/$OW/$SF/tmp/source_type"` 1271 | if [[ `echo "$source_type" | grep openwrt | wc -l` == "1" ]]; then 1272 | rm -rf package/lean 1273 | source_openwrt_Setting 1274 | elif [[ `echo "$source_type" | grep lean | wc -l` == "1" ]]; then 1275 | echo "" 1276 | fi 1277 | 1278 | } 1279 | 1280 | source_openwrt_Setting() { 1281 | source_type=`cat "$HOME/$OW/$SF/tmp/source_type"` 1282 | if [[ "$source_type" == "openwrt-18.06" ]]; then 1283 | source_openwrt_Setting_18 1284 | fi 1285 | #下载lean插件 1286 | source_lean_package 1287 | echo -e ">>$green openwrt官方源码开始配置优化$white" 1288 | Time 1289 | itdesk_default_packages="block-mount coremark kmod-nf-nathelper kmod-nf-nathelper-extra kmod-ipt-raw wget libustream-openssl ca-certificates default-settings luci luci-app-ddns luci-app-upnp luci-app-autoreboot luci-app-webadmin luci-app-serverchan luci-app-diskman luci-app-passwall luci-app-fileassistant luci-app-jd-dailybonus luci-app-wrtbwmon luci-app-filetransfer luci-app-vsftpd luci-app-ssr-plus luci-app-unblockmusic luci-app-arpbind luci-app-vlmcsd luci-app-wol luci-app-ramfree luci-app-sfe luci-app-nlbwmon luci-app-accesscontrol luci-app-frpc luci-app-ttyd luci-app-netdata ddns-scripts_aliyun ddns-scripts_dnspod #tr_ok " 1290 | lean_packages_nas="DEFAULT_PACKAGES.nas:=fdisk lsblk mdadm automount autosamba" 1291 | 1292 | #修改target.mk 1293 | if [[ `grep -o "#tr_ok" include/target.mk | wc -l ` == "1" ]]; then 1294 | echo "" 1295 | else 1296 | #(DEFAULT_PACKAGES) 1297 | if [[ "$(grep -o "urngd" include/target.mk_back )" == "urngd" ]]; then 1298 | #19.7 and master (PACKAGES) 1299 | sed -i "s/urandom-seed urngd/urandom-seed urngd $itdesk_default_packages/g" include/target.mk 1300 | else 1301 | #17.1 and 18.6 (PACKAGES) 1302 | sed -i "s/uclient-fetch logd/uclient-fetch logd $itdesk_default_packages/g" include/target.mk 1303 | fi 1304 | 1305 | #17.1-master (PACKAGES.nas) 1306 | #sed -i "s/DEFAULT_PACKAGES.nas:=block-mount fdisk lsblk mdadm/$lean_packages_nas/g" include/target.mk 1307 | fi 1308 | 1309 | #x86_makefile 1310 | x86_makefile="partx-utils mkf2fs fdisk e2fsprogs wpad kmod-usb-hid kmod-mmc-spi kmod-sdhci kmod-ath5k kmod-ath9k kmod-ath9k-htc kmod-ath10k kmod-rt2800-usb kmod-e1000e kmod-igb kmod-igbvf kmod-ixgbe kmod-pcnet32 kmod-tulip kmod-vmxnet3 kmod-i40e kmod-i40evf kmod-r8125 kmod-8139cp kmod-8139too kmod-fs-f2fs kmod-sound-hda-core kmod-sound-hda-codec-realtek kmod-sound-hda-codec-via kmod-sound-via82xx kmod-sound-hda-intel kmod-sound-hda-codec-hdmi kmod-sound-i8x0 kmod-usb-audio kmod-usb-net kmod-usb-net-asix kmod-usb-net-asix-ax88179 kmod-usb-net-rtl8150 kmod-usb-net-rtl8152 kmod-r8168 kmod-mlx4-core kmod-mlx5-core kmod-drm-amdgpu ath10k-firmware-qca988x ath10k-firmware-qca9888 ath10k-firmware-qca9984 brcmfmac-firmware-43602a1-pcie htop lm-sensors automount autosamba luci-app-frps luci-app-hd-idle luci-app-dockerman iperf iperf3 luci-app-ddns luci-app-sqm ca-certificates #autocore" 1311 | FEATURES="squashfs vdi vmdk pcmcia fpu boot-part rootfs-part ext4 targz" 1312 | if [[ `grep -o "$x86_makefile" target/linux/x86/Makefile ` == "$x86_makefile" ]]; then 1313 | echo -e "$green x86_makefile配置已经修改,不做其他操作$white" 1314 | else 1315 | sed -i "s/partx-utils mkf2fs e2fsprogs/$x86_makefile/g" target/linux/x86/Makefile 1316 | fi 1317 | 1318 | #enable KERNEL_MIPS_FPU_EMULATOR 1319 | sed -i 's/default y if TARGET_pistachio/default y/g' config/Config-kernel.in 1320 | 1321 | #应用fullconenat 1322 | #rm -rf package/network/config/firewall 1323 | #svn checkout https://github.com/coolsnowwolf/lede/trunk/package/network/config/firewall package/network/config/firewall 1324 | 1325 | #docekr-ce 1326 | if [[ -e package/other-plugins/docker-ce ]]; then 1327 | rm -rf package/other-plugins/docker-ce 1328 | svn checkout https://github.com/coolsnowwolf/packages/trunk/utils/docker-ce $HOME/$OW/$you_file/lede/package/other-plugins/docker-ce 1329 | cd $HOME/$OW/$you_file/lede/ 1330 | else 1331 | svn checkout https://github.com/coolsnowwolf/packages/trunk/utils/docker-ce $HOME/$OW/$you_file/lede/package/other-plugins/docker-ce 1332 | fi 1333 | 1334 | #添加库 1335 | echo "src-git helloworld https://github.com/fw876/helloworld" >> feeds.conf.default && update_feeds 1336 | 1337 | 1338 | #活动连接数 1339 | sed -i 's/16384/65536/g' package/kernel/linux/files/sysctl-nf-conntrack.conf 1340 | 1341 | #删除lean_frp 1342 | #rm -rf package/lean/frp 1343 | #rm -rf package/lean/luci-app-frpc 1344 | 1345 | #取消官方源码强制https 1346 | sed -i '09s/\(.\{1\}\)/\#/' package/network/services/uhttpd/files/uhttpd.config 1347 | sed -i '10s/\(.\{1\}\)/\#/' package/network/services/uhttpd/files/uhttpd.config 1348 | sed -i 's/option redirect_https\s1/option redirect_https 0/g' package/network/services/uhttpd/files/uhttpd.config 1349 | sed -i '46s/\(.\{1\}\)/\#/' package/network/services/uhttpd/files/uhttpd.init 1350 | sed -i '47s/\(.\{1\}\)/\#/' package/network/services/uhttpd/files/uhttpd.init 1351 | sed -i '53s/\(.\{1\}\)/\#/' package/network/services/uhttpd/files/uhttpd.init 1352 | 1353 | #upx ucl 1354 | if [[ $(grep -o "upx" tools/Makefile | wc -l) == "1" ]]; then 1355 | echo "" 1356 | else 1357 | sed -i '31a\tools-y += ucl upx' tools/Makefile 1358 | svn checkout https://github.com/coolsnowwolf/lede/trunk/tools/upx $HOME/$OW/$you_file/lede/tools/upx 1359 | svn checkout https://github.com/coolsnowwolf/lede/trunk/tools/ucl $HOME/$OW/$you_file/lede/tools/ucl 1360 | 1361 | fi 1362 | echo "" > $HOME/$OW/$SF/tmp/source_branch 1363 | other_plugins 1364 | echo -e ">>$green openwrt官方源码配置优化完成$white" 1365 | } 1366 | 1367 | source_openwrt_Setting_18() { 1368 | clear 1369 | echo -e ">>$green针对18.6版本开始配置优化$white" 1370 | Time 1371 | 1372 | #修改x86启动等待时间成0秒(by:左右) 1373 | sed -i 's/default "5"/default "0"/g' $HOME/$OW/$you_file/lede/config/Config-images.in 1374 | 1375 | #去掉IPV6(by:左右) 1376 | sed -i 's/+IPV6:luci-proto-ipv6 //g' $HOME/$OW/$you_file/lede/feeds/luci/collections/luci/Makefile 1377 | 1378 | #修改exfat支持(by:左右) 1379 | sed -i 's/+kmod-nls-base @BUILD_PATENTED/+kmod-nls-base/g' $HOME/$OW/$you_file/lede/feeds/packages/kernel/exfat-nofuse/Makefile 1380 | 1381 | #修改KB成MB(by:左右) 1382 | sed -i 's/1024) + " <%:k/1048576) + " <%:M/g' feeds/luci/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm 1383 | sed -i 's/(info.memory/Math.floor(info.memory/g' feeds/luci/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm 1384 | sed -i 's/(Math.floor/Math.floor(/g' feeds/luci/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm 1385 | sed -i 's/(info.swap/Math.floor(info.swap/g' feeds/luci/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm 1386 | 1387 | echo -e ">>$green针对18.6版本配置优化完成$white" 1388 | } 1389 | 1390 | source_lean() { 1391 | source_type=`git remote show origin | grep "coolsnowwolf" | wc -l` 1392 | if [[ "$source_type" == "2" ]]; then 1393 | clear 1394 | echo -e ">>$green针对lean版本开始配置优化$white" && Time 1395 | 1396 | #添加helloworld库 1397 | echo "src-git helloworld https://github.com/fw876/helloworld" >> feeds.conf.default 1398 | 1399 | 1400 | #target.mk 1401 | target_mk="luci-app-serverchan luci-app-diskman luci-app-wrtbwmon luci-app-frpc luci-app-frps luci-app-wol luci-app-dockerman luci-theme-argon luci-app-passwall luci-app-fileassistant luci-app-ipsec-vpnd luci-app-ttyd luci-app-vnstat luci-app-diag-core luci-app-ssr-plus luci-app-turboacc lm-sensors openssh-sftp-server iperf iperf3 ipv6helper #tr_ok" 1402 | if [[ `grep -o "#tr_ok" include/target.mk | wc -l ` == "1" ]]; then 1403 | echo "" 1404 | else 1405 | sed -i "s/luci-app-autoreboot/luci-app-autoreboot $target_mk/g" include/target.mk 1406 | 1407 | fi 1408 | 1409 | #修改X86默认固件大小 1410 | if [[ `grep -o "default 448" config/Config-images.in | wc -l` == "1" ]]; then 1411 | sed -i 's\default 448\default 1024\g' config/Config-images.in 1412 | #传统模式 1413 | grub_position=$(cat config/Config-images.in | grep -n "Build GRUB images" | awk '{print $1}' | sed "s/://") 1414 | del_num=$(($grub_position + 4)) 1415 | add_num=$(($grub_position + 3)) 1416 | sed -i "$del_num d" config/Config-images.in 1417 | sed -i "$add_num a\default y" config/Config-images.in 1418 | else 1419 | echo "" 1420 | fi 1421 | 1422 | #默认对x86首页下手,其他的你们安全了 1423 | x86indexif=$(grep -o "Local Weather" package/lean/autocore/files/x86/index.htm) 1424 | if [[ "$x86indexif" == "Local Weather" ]]; then 1425 | echo "已经替换X86首页文件" 1426 | else 1427 | rm -rf package/lean/autocore/files/x86/index.htm 1428 | cp $HOME/$OW/$SF/$OCS/Warehouse/index_Weather/x86_index.htm package/lean/autocore/files/x86/index.htm 1429 | fi 1430 | 1431 | base_zh_po_if=$(grep -o "#天气预报" feeds/luci/modules/luci-base/po/zh_Hans/base.po) 1432 | if [[ "$base_zh_po_if" == "#天气预报" ]]; then 1433 | echo "已添加天气预报翻译" 1434 | else 1435 | sed -i '$a \#天气预报\nmsgid "Weather"\nmsgstr "天气"\n\nmsgid "Local Weather"\nmsgstr "本地天气"\n ' feeds/luci/modules/luci-base/po/zh_Hans/base.po 1436 | fi 1437 | 1438 | #首页显示编译时间 1439 | Compile_time_if=$(grep -o "#首页显示编译时间" feeds/luci/modules/luci-base/po/zh_Hans/base.po) 1440 | if [[ "$Compile_time_if" == "#首页显示编译时间" ]]; then 1441 | echo "已添加首页显示编译时间" 1442 | else 1443 | sed -i '$a \#首页显示编译时间\nmsgid "Compile_time"\nmsgstr "固件编译时间"\n' feeds/luci/modules/luci-base/po/zh_Hans/base.po 1444 | sed -i '$d' package/lean/default-settings/files/zzz-default-settings 1445 | sed -i '$d' package/lean/default-settings/files/zzz-default-settings 1446 | echo "echo \"`date "+%Y-%m-%d %H:%M"` (commit:`git log -1 --format=format:'%C(bold white)%h%C(reset)'`)\" >> /etc/Compile_time" >> package/lean/default-settings/files/zzz-default-settings 1447 | echo "exit 0" >> package/lean/default-settings/files/zzz-default-settings 1448 | fi 1449 | 1450 | :<<'COMMENT' 1451 | #修改x86内核 1452 | if [[ `grep -o "KERNEL_PATCHVER:=5.4" target/linux/x86/Makefile | wc -l` == "1" ]]; then 1453 | sed -i 's\KERNEL_PATCHVER:=5.4\KERNEL_PATCHVER:=4.19\g' target/linux/x86/Makefile 1454 | sed -i 's\KERNEL_TESTING_PATCHVER:=5.4\KERNEL_TESTING_PATCHVER:=4.19\g' target/linux/x86/Makefile 1455 | else 1456 | echo "" 1457 | fi 1458 | COMMENT 1459 | #ipq806x_makefile 1460 | ipq806x_makefile="kmod-ath10k-ct wpad-openssl jd_openwrt_script" 1461 | #ipq806x_makefile="kmod-ath10k-ct wpad-openssl kmod-qca-nss-drv kmod-qca-nss-drv-qdisc kmod-qca-nss-ecm-standard kmod-qca-nss-gmac kmod-nss-ifb iptables-mod-physdev kmod-ipt-physdev kmod-qca-nss-drv-pppoe MAC80211_NSS_SUPPORT luci-app-cpufreq jd_openwrt_script" 1462 | if [[ `grep -o "$ipq806x_makefile" target/linux/ipq806x/Makefile ` == "$ipq806x_makefile" ]]; then 1463 | echo -e "$green ipq806x_makefile配置已经修改,不做其他操作$white" 1464 | else 1465 | sed -i "s/kmod-ath10k-ct wpad-openssl/$ipq806x_makefile/g" target/linux/ipq806x/Makefile 1466 | fi 1467 | 1468 | 1469 | #rockchip_makefile 1470 | rockchip_makefile="luci-app-vsftpd ipv6helper autocore-arm jd_openwrt_script luci-app-frps luci-app-hd-idle luci-app-openvpn-server luci-app-ssrserver-python luci-app-transmission luci-app-zerotier wget" 1471 | if [[ `grep -o "$rockchip_makefile" target/linux/rockchip/Makefile ` == "$rockchip_makefile" ]]; then 1472 | echo -e "$green rockchip_makefile配置已经修改,不做其他操作$white" 1473 | else 1474 | sed -i "s/luci-app-zerotier/$rockchip_makefile/g" target/linux/rockchip/Makefile 1475 | 1476 | fi 1477 | 1478 | #修改网易云启用node.js 1479 | #sed -i "s/default n/default y/g" feeds/luci/applications/luci-app-unblockmusic/Makefile 1480 | 1481 | #将diskman选项启用 1482 | sed -i "s/default n/default y/g" feeds/luci/applications/luci-app-diskman/Makefile 1483 | 1484 | #下载插件 1485 | update_feeds 1486 | other_plugins 1487 | 1488 | #删除这个,解决报错问题 1489 | rm -rf dl/go-mod-cache && rm -rf ./tmp 1490 | 1491 | echo -e ">>$green lean版本配置优化完成$white" 1492 | 1493 | fi 1494 | 1495 | } 1496 | 1497 | other_plugins() { 1498 | 1499 | #other-plugins 1500 | if [[ -e package/other-plugins ]]; then 1501 | echo "" 1502 | else 1503 | mkdir package/other-plugins 1504 | fi 1505 | 1506 | 1507 | #需要删除的前置 1508 | 1509 | #采用lisaac的luci-app-dockerman 1510 | if [[ -e package/lean/luci-app-dockerman ]]; then 1511 | rm -rf package/lean/luci-app-dockerman 1512 | fi 1513 | 1514 | 1515 | #中部 1516 | 1517 | cat >/tmp/other-plugins.txt </tmp/passwall_luci_set </tmp/helloworld_set <>feeds.conf.default 1612 | ./scripts/feeds update node 1613 | rm ./package/feeds/packages/node 1614 | rm ./package/feeds/packages/node-* 1615 | ./scripts/feeds install -a -p node 1616 | fi 1617 | 1618 | :<<"no_print" 1619 | #下载luci-app-ssr-plus 1620 | if [[ -e package/other-plugins/luci-app-ssr-plus ]]; then 1621 | rm -rf package/other-plugins/luci-app-ssr-plus 1622 | svn checkout https://github.com/fw876/helloworld/trunk/luci-app-ssr-plus package/other-plugins/luci-app-ssr-plus 1623 | svn checkout https://github.com/fw876/helloworld/trunk/lua-neturl package/other-plugins/lua-neturl 1624 | svn checkout https://github.com/fw876/helloworld/trunk/shadow-tls package/other-plugins/shadow-tls 1625 | svn checkout https://github.com/fw876/helloworld/trunk/redsocks2 package/other-plugins/redsocks2 1626 | else 1627 | svn checkout https://github.com/fw876/helloworld/trunk/luci-app-ssr-plus package/other-plugins/luci-app-ssr-plus 1628 | svn checkout https://github.com/fw876/helloworld/trunk/lua-neturl package/other-plugins/lua-neturl 1629 | svn checkout https://github.com/fw876/helloworld/trunk/shadow-tls package/other-plugins/shadow-tls 1630 | svn checkout https://github.com/fw876/helloworld/trunk/redsocks2 package/other-plugins/redsocks2 1631 | fi 1632 | 1633 | #frp修改 1634 | sed -i "s/0.51.3/0.49.0/g" ./feeds/packages/net/frp/Makefile 1635 | sed -i "s/83032399773901348c660d41c967530e794ab58172ccd070db89d5e50d915fef/8ff92d4f763d596bee35efe17f0729d36e584b93c49a7671cebde4bb318b458f/g" ./feeds/packages/net/frp/Makefile 1636 | 1637 | 1638 | #将golang退回1.20 1639 | if [ -f golang.zip ];then 1640 | rm -rf ./feeds/packages/lang/golang/* 1641 | unzip golang.zip -d ./feeds/packages/lang/golang 1642 | ./scripts/feeds install -a -p golang 1643 | else 1644 | wget https://github.com/xiaorouji/openwrt-passwall/files/12568587/golang.zip 1645 | rm -rf ./feeds/packages/lang/golang/* 1646 | unzip golang.zip -d ./feeds/packages/lang/golang 1647 | ./scripts/feeds install -a -p golang 1648 | fi 1649 | no_print 1650 | update_feeds 1651 | } 1652 | 1653 | #Public配置 1654 | source_Setting_Public() { 1655 | echo -e ">>$green Public配置$white" 1656 | #隐藏首页显示用户名(by:kokang) 1657 | sed -i 's/name="luci_username" value="<%=duser%>"/name="luci_username"/g' feeds/luci/modules/luci-base/luasrc/view/sysauth.htm 1658 | 1659 | #移动光标至第一格(by:kokang) 1660 | sed -i "s/'luci_password'/'luci_username'/g" feeds/luci/modules/luci-base/luasrc/view/sysauth.htm 1661 | 1662 | #修改固件生成名字,增加当天日期(by:左右) 1663 | sed -i 's/IMG_PREFIX:=$(VERSION_DIST_SANITIZED)/IMG_PREFIX:=[$(shell date +%Y%m%d)]-$(VERSION_DIST_SANITIZED)/g' include/image.mk 1664 | 1665 | sed -i "s/*\/\$time \* /0 *\/2 /g" feeds/luci/applications/luci-app-frpc/root/etc/init.d/frp 1666 | 1667 | echo -e ">>$green Public配置完成$white" 1668 | } 1669 | 1670 | update_feeds() { 1671 | echo "---------------------------" 1672 | echo -e " $green更新Feeds代码$white" 1673 | echo "---------------------------" 1674 | ./scripts/feeds update -a && ./scripts/feeds install -a 1675 | if [[ $? -eq 0 ]]; then 1676 | echo "" 1677 | else 1678 | clear 1679 | echo "Feeds没有更新或安装成功,重新执行代码" && Time 1680 | update_feeds 1681 | fi 1682 | } 1683 | 1684 | make_defconfig() { 1685 | clear 1686 | echo "---------------------------" 1687 | echo "" 1688 | echo "" 1689 | echo -e " $green测试编译环境$white" 1690 | echo "" 1691 | echo "" 1692 | echo "--------------------------" 1693 | make defconfig 1694 | } 1695 | 1696 | dl_download() { 1697 | #检测dl包完整性(by:P3TERX) 1698 | if [[ -e $HOME/$OW/$you_file/lede/dl ]]; then 1699 | cd $HOME/$OW/$you_file/lede/dl 1700 | find . -size -1024c -exec ls -l {} \; 1701 | find . -size -1024c -exec rm -f {} \; 1702 | cd $HOME/$OW/$you_file/lede 1703 | else 1704 | echo "" 1705 | fi 1706 | clear 1707 | echo "----------------------------------------------" 1708 | echo -e "$green# 开始下载DL,如果出现下载很慢,请检查你的梯子 #$white" 1709 | echo "" 1710 | echo -e "$green你的CPU核数为:$cpu_cores $white" 1711 | echo -e "$yellow自动执行make download -j$cpu_cores V=s加快下载速度$white" 1712 | echo "" 1713 | echo "ps:全速下载可能会导致系统反应慢点,稍等一下就好" 1714 | echo "----------------------------------------------" 1715 | Time 1716 | make download -j$cpu_cores V=s 1717 | if [[ $? -eq 0 ]]; then 1718 | echo "" 1719 | else 1720 | dl_error 1721 | fi 1722 | 1723 | } 1724 | 1725 | dl_error() { 1726 | echo "----------------------------------------" 1727 | echo -e " $yellow你的dl下载报错了$white" 1728 | echo " 1.重新下载" 1729 | echo " 2.不理直接编译" 1730 | echo "----------------------------------------" 1731 | read -p "请输入你的决定:" dl_dw 1732 | case "$dl_dw" in 1733 | 1) 1734 | dl_download 1735 | ;; 1736 | 2) 1737 | echo "" 1738 | ;; 1739 | *) 1740 | clear && echo "Error请输入正确的数字 [1-2]" && Time 1741 | clear && dl_error 1742 | ;; 1743 | esac 1744 | } 1745 | 1746 | ecc() { 1747 | clear 1748 | echo " -----------------------------------------------" 1749 | echo "" 1750 | echo -e " $green【××编译环境搭建成功××】$white" 1751 | echo "" 1752 | echo " 1.请回车进入编译菜单,第一次回车较慢稍等" 1753 | echo " 2.进去编译菜单选择你要的功能完成以后Save" 1754 | echo " 3.菜单Exit以后会自动开始编译" 1755 | echo "" 1756 | echo " 注:如果不需要编译 Ctrl+c退出" 1757 | echo " -------------------------------------------------" 1758 | read a 1759 | make menuconfig 1760 | if [[ $? -eq 0 ]]; then 1761 | #Save_My_Config_luci 1762 | #make_firmware_or_plugin 1763 | make_compile_firmware 1764 | else 1765 | echo "" 1766 | echo -e "$redError,请查看上面报错,回车重新执行命令$white" 1767 | echo "" && read a 1768 | ecc 1769 | fi 1770 | } 1771 | 1772 | make_firmware_or_plugin() { 1773 | clear 1774 | calculating_time_start 1775 | echo "----------------------------------------" 1776 | echo "请选择编译固件 OR 编译插件" 1777 | echo " 1.编译固件" 1778 | echo " 2.编译插件" 1779 | echo " 3.回退到加载配置选项(可以重新选择你的配置)" 1780 | echo "----------------------------------------" 1781 | read -p "请输入你的决定:" mk_value 1782 | case "$mk_value" in 1783 | 1) 1784 | make_compile_firmware 1785 | ;; 1786 | 2) 1787 | make_Compile_plugin 1788 | ;; 1789 | 3) 1790 | source_config 1791 | ;; 1792 | *) 1793 | clear && echo "Error请输入正确的数字 [1-2]" && Time 1794 | clear && make_firmware_or_plugin 1795 | ;; 1796 | esac 1797 | 1798 | 1799 | } 1800 | 1801 | make_compile_firmware() { 1802 | rm -rf /tmp/compile.log 1803 | calculating_time_start 1804 | clear 1805 | echo "--------------------------------------------------------" 1806 | echo -e "$green++编译固件是否要使用多线程编译++$white" 1807 | echo "" 1808 | echo " 首次编译不建议-j,具体用几线程看你电脑j有机会编译失败," 1809 | echo "不懂回车默认运行make V=s" 1810 | echo "" 1811 | echo -e "温馨提醒你的cpu核心数为:$green $cpu_cores $white" 1812 | echo -e "可用多线程例子:$yellow make -j$cpu_cores V=s $white(黄色字体这段完整的输进去)" 1813 | echo "" 1814 | echo -e "$red!!!请不要在输入参数这行直接输数字,把命令敲全,不懂就直接回车!!!$white" 1815 | echo "--------------------------------------------------------" 1816 | read -p "请输入你的参数(回车默认:make V=s):" mk_f 1817 | if [[ -z $mk_f ]];then 1818 | clear && echo "开始执行编译" && Time 1819 | dl_download 1820 | make V=s >>/tmp/compile.log & 1821 | tail -f /tmp/compile.log & 1822 | else 1823 | dl_download 1824 | clear 1825 | echo -e "你输入的命令是:$green$mk_f$white" 1826 | echo "准备开始执行编译" && Time 1827 | $mk_f >>/tmp/compile.log & 1828 | tail -f /tmp/compile.log & 1829 | fi 1830 | 1831 | if_make 1832 | } 1833 | 1834 | if_make() { 1835 | #set -x 1836 | if [[ `cat /tmp/compile.log |grep "make\[1\]: Leaving directory" | wc -l` == "1" ]];then 1837 | kill_tail=$(ps -an | grep tail | grep -v grep | awk '{print $1}') 1838 | kill -9 $kill_tail 1839 | if_wo 1840 | calculating_time_end 1841 | else 1842 | if [[ `cat /tmp/compile.log |grep "make\: \*\*\* \[world\] Error 2" | wc -l ` == "1" ]]; then 1843 | kill_tail=$(ps -an | grep tail | grep -v grep | awk '{print $1}') 1844 | kill -9 $kill_tail 1845 | echo -e "$red>> 固件编译失败,请查询上面报错代码$white" 1846 | make_continue_to_compile 1847 | else 1848 | sleep 2 1849 | if_make 1850 | fi 1851 | fi 1852 | 1853 | #by:BoomLee ITdesk 1854 | } 1855 | 1856 | if_wo() { 1857 | if [[ $? -eq 0 ]]; then 1858 | #复制编译好的固件过去 1859 | workspace_if=`echo $HOME | grep workspace | wc -l ` 1860 | if [[ "$workspace_if" == "1" ]]; then 1861 | da=`date +%Y%m%d` 1862 | HOME=`echo "$THEIA_WORKSPACE_ROOT"` 1863 | source_type=`cat $HOME/$OW/$SF/tmp/source_type` 1864 | you_file=`cat $HOME/$OW/$SF/tmp/you_file` 1865 | 1866 | if [[ -e $HOME/bin ]]; then 1867 | echo "" 1868 | else 1869 | mkdir -p $HOME/bin 1870 | fi 1871 | 1872 | cd && cd $HOME 1873 | \cp -rf $HOME/$OW/$you_file/lede/bin/targets/ $HOME/bin/$da-$source_type 1874 | echo -e "本次编译完成的固件已经copy到$green $HOME/bin/$da-$source_type $white" 1875 | fi 1876 | else 1877 | echo "---------------------------------------------------" 1878 | echo -e "$red>> 固件编译失败,请查看报错代码$white" 1879 | cat /tmp/compile.log | grep -E "ERROR/|failed" 1880 | echo -e "$yellow >>更多编译过程可以查看 $green/tmp/compile.log$yellow 方便你查看错误发生过程" 1881 | echo ---------------------------------------------------- 1882 | 1883 | make_continue_to_compile 1884 | fi 1885 | } 1886 | 1887 | 1888 | 1889 | make_Compile_plugin() { 1890 | clear 1891 | echo "--------------------------------------------------------" 1892 | echo "编译插件" 1893 | echo "" 1894 | echo -e "$yellow例子:make package/插件名字/compile V=99$white" 1895 | echo "" 1896 | echo "PS:Openwrt首次git clone仓库不要用此功能,绝对失败!!!" 1897 | echo "--------------------------------------------------------" 1898 | read -p "请输入你的参数:" mk_p 1899 | clear 1900 | echo -e "你输入的参数是:$green$mk_p$white" 1901 | echo "准备开始执行编译" && Time 1902 | $mk_p 1903 | 1904 | if [[ $? -eq 0 ]]; then 1905 | echo "" 1906 | echo "" 1907 | echo "---------------------------------------------------------------------" 1908 | echo "" 1909 | echo -e " 潘多拉编译完成的插件在$yellow/Openwrt/文件名/lede/bin/packages/你的平台/base$white,如果还是找不到的话,看下有没有报错,善用搜索 " 1910 | echo "" 1911 | echo "回车可以继续编译插件,或者Ctrl + c终止操作" 1912 | echo "" 1913 | echo "---------------------------------------------------------------------" 1914 | read a 1915 | make_Continue_compiling_the_plugin 1916 | calculating_time_end 1917 | else 1918 | echo -e "$red>> 固件编译失败,请查询上面报错代码$white" 1919 | make_continue_to_compile 1920 | fi 1921 | #by:BoomLee ITdesk 1922 | } 1923 | 1924 | make_Continue_compiling_the_plugin() { 1925 | clear 1926 | echo "----------------------------------------" 1927 | echo "是否需要继续编译插件" 1928 | echo " 1.继续编译插件" 1929 | echo " 2.不需要了" 1930 | echo "----------------------------------------" 1931 | read -p "请输入你的决定:" mk_value 1932 | case "$mk_value" in 1933 | 1) 1934 | make_Compile_plugin 1935 | ;; 1936 | 2) 1937 | exit 1938 | ;; 1939 | *) 1940 | clear && echo "Error请输入正确的数字 [1-2]" && Time 1941 | clear && make_Continue_compiling_the_plugin 1942 | ;; 1943 | esac 1944 | } 1945 | 1946 | make_continue_to_compile() { 1947 | echo "---------------------------------------------------------------------" 1948 | echo -e "你的编译出错了是否要继续编译" 1949 | echo "" 1950 | echo -e "$green 1.是(默认执行make clean && make V=s,以方便查出具体报错问题)$white" 1951 | echo "" 1952 | echo -e "$red 2.否 (直接退出脚本)$white" 1953 | echo "" 1954 | echo -e "$yellow温馨提醒,编译失败一般有以下几种可能$white" 1955 | echo "1. 网络(需要科学上网)" 1956 | echo "2. Dl库没有下载完整(跟网络很大关系)" 1957 | echo "3. -j 多线程编译" 1958 | echo "4. 内存太少,在-j的时候容易报错" 1959 | echo "5. 空间不足(至少40G空间)" 1960 | echo "---------------------------------------------------------------------" 1961 | read -p "请输入你的决定:" continue_to_compile 1962 | case "$continue_to_compile" in 1963 | 1) 1964 | cd $HOME/$OW/$you_file/lede 1965 | make clean && make V=s 1966 | #make_firmware_or_plugin 1967 | ;; 1968 | 2) 1969 | exit 1970 | ;; 1971 | *) 1972 | clear && echo "Error请输入正确的数字 [1-2]" && Time 1973 | clear && make_continue_to_compile 1974 | ;; 1975 | esac 1976 | } 1977 | 1978 | #单独的命令模块 1979 | make_j() { 1980 | make_compile_firmware 1981 | #dl_download 1982 | #calculating_time_start 1983 | #make -j$(nproc) V=s 1984 | #calculating_time_end 1985 | #n1_builder 1986 | } 1987 | 1988 | new_source_make() { 1989 | system_install 1990 | } 1991 | 1992 | clean_make() { 1993 | clear &&echo -e "$green>>执行make clean$white" 1994 | make clean 1995 | noclean_make 1996 | } 1997 | 1998 | noclean_make() { 1999 | clear && echo -e "$green>>不执行make clean$white" 2000 | source_config && make menuconfig && make_j 2001 | } 2002 | 2003 | update_clean_make() { 2004 | clear 2005 | cd $HOME/$OW/$you_file/lede 2006 | file_patch="$HOME/$OW/$you_file/lede" 2007 | echo -e "$green>>文件夹:$yellow$file_patch$green 执行make clean$white" && sleep 3 2008 | make clean && rm -rf .config && rm -rf ./tmp/ && rm -rf ./feeds 2009 | echo -e "$green>>文件夹:$yellow$file_patch$green 执行git pull$white" && sleep 3 2010 | source_update_No_git_pull 2011 | echo -e "$green>>文件夹:$yellow$file_patch$green 执行常用设置$white" && sleep 3 2012 | source_download_ok 2013 | echo -e "$green>>文件夹:$yellow$file_patch$green 执行make menuconfig $white" && sleep 3 2014 | if [ "$action3" == "auto" ];then 2015 | echo -e "$green>检测到$yellow$action3$green,开始自动运行编译$white" && sleep 3 2016 | else 2017 | make menuconfig 2018 | fi 2019 | echo -e "$green>>文件夹:$yellow$file_patch$green 执行make download 和make -j $white" && sleep 3 2020 | if [ "$action3" == "auto" ];then 2021 | make -j${cpu_cores} V=s 2022 | else 2023 | make_j 2024 | fi 2025 | if [[ $? -eq 0 ]]; then 2026 | echo "" 2027 | else 2028 | echo -e "$red>>文件夹:$action1 编译失败了,请检查上面的报错,然后重新进行编译 $white" 2029 | echo "" 2030 | echo -e "$green 可以采用以下命令重新进行编译" 2031 | echo -e "$green bash \$openwrt $action1 make_j " 2032 | fi 2033 | } 2034 | 2035 | update_clean_make_kernel() { 2036 | update_clean_make 2037 | make kernel_menuconfig 2038 | make_j 2039 | } 2040 | 2041 | update_script_rely() { 2042 | update_script 2043 | rely_on 2044 | if [[ $? -eq 0 ]]; then 2045 | echo -e "$green >>依赖安装完成 $white" && Time 2046 | else 2047 | clear 2048 | echo -e "$red 依赖没有更新或安装成功,重新执行代码 $white" && Time 2049 | update_script_rely 2050 | fi 2051 | } 2052 | 2053 | actions_openwrt() { 2054 | HOME=$(pwd) 2055 | file=lean 2056 | if [[ ! -d "$HOME/$OW/$SF/$OCS" ]]; then 2057 | echo -e "开始创建主文件夹" 2058 | mkdir -p $HOME/$OW/$SF/dl 2059 | mkdir -p $HOME/$OW/$SF/My_config 2060 | mkdir -p $HOME/$OW/$SF/tmp 2061 | fi 2062 | 2063 | echo "开始创建编译文件夹" 2064 | mkdir $HOME/$OW/$you_file 2065 | git clone https://github.com/coolsnowwolf/lede.git $HOME/$OW/$you_file/lede 2066 | cd $HOME/$OW/$you_file/lede 2067 | source_download_ok 2068 | make_j 2069 | } 2070 | 2071 | file_help() { 2072 | echo "---------------------------------------------------------------------" 2073 | echo " 【 Openwrt Compile Script编译脚本 Ver ${version}版 】" 2074 | echo " By:ITdesk" 2075 | echo "---------------------------------------------------------------------" 2076 | echo "" 2077 | echo -e "$green用法: bash \$openwrt [文件夹] [命令] $white" 2078 | echo -e "$green脚本创建文件夹目录结构:$HOME/$OW/$yellow你起的文件夹名$green/lede $white" 2079 | echo "" 2080 | echo -e "$yellow首次编译建议:$white" 2081 | echo -e "$green new_source_make $white 脚本新建一个文件夹下载你需要的源码并进行编译 " 2082 | echo "" 2083 | echo -e "$yellow二次编译建议:$white" 2084 | #echo -e "$green make_j $white 执行make download 和make -j V=s " 2085 | echo -e "$green noclean_make $white 不执行make clean清理一下源码然后再进行编译" 2086 | echo -e "$green clean_make $white 执行make clean清理一下源码然后再进行编译" 2087 | echo -e "$green update_clean_make $white 执行make clean 并同步最新的源码 再进行编译" 2088 | #echo -e "$green update_clean_make_kernel $white 编译完成以后执行make kernel_menuconfig($red危险操作$white)" 2089 | echo -e "$green update_script $white 将脚本同步到最新" 2090 | echo -e "$green update_script_rely $white将脚本和源码依赖同步到最新" 2091 | #echo -e "$green help $white 查看帮助" 2092 | echo "" 2093 | echo -e "$yellow例子: $white " 2094 | echo -e "$yellow 1.新建一个文件夹下载你需要的源码并进行编译(适合首次编译) $white " 2095 | echo -e "$green bash \$openwrt new_source_make $white " 2096 | echo "" 2097 | echo -e "$yellow 2.不执行clean,执行make download 和make -j V=s(适合二次编译) $white " 2098 | echo -e "$green bash \$openwrt $yellow你起的文件夹名$green noclean_make $white " 2099 | echo "" 2100 | echo -e "$yellow 3.清理编译文件,再重新编译(适合二次编译) $white " 2101 | echo -e "$green bash \$openwrt $yellow你起的文件夹名$green clean_make $white " 2102 | echo "" 2103 | echo -e "$yellow 4.同步最新的源码清理编译文件再编译(适合二次编译) $white" 2104 | echo -e "$green bash \$openwrt $yellow你起的文件夹名$green update_clean_make $white " 2105 | echo "" 2106 | echo -e "$green bash \$openwrt help $white 查看帮助 " 2107 | echo -e "$green bash \$openwrt update_script $white 将脚本同步到最新 " 2108 | echo "" 2109 | echo "---------------------------------------------------------------------" 2110 | 2111 | } 2112 | 2113 | action1_if() { 2114 | if [[ -e $HOME/$OW/$action1 ]]; then 2115 | action2_if 2116 | else 2117 | echo "" 2118 | echo -e "$red>>文件夹不存在,使用方法参考以下!!!$white" 2119 | file_help 2120 | fi 2121 | } 2122 | 2123 | action2_if() { 2124 | if [[ -z $action2 ]]; then 2125 | echo "" 2126 | echo -e "$red>>命令参数不能为空!$white" 2127 | file_help 2128 | else 2129 | you_file=$action1 2130 | cd $HOME/$OW/$you_file/lede 2131 | rm -rf $HOME/$OW/$SF/tmp/* 2132 | case "$action2" in 2133 | other_plugins|make_j|new_source_make|clean_make|noclean_make|update_clean_make|update_clean_make_kernel|update_script_rely|n1_builder) 2134 | $action2 2135 | action3_if 2136 | ;; 2137 | *) 2138 | echo "" 2139 | echo -e "$red 命令不存在,使用方法参考以下!!!$white" 2140 | file_help 2141 | ;; 2142 | esac 2143 | fi 2144 | } 2145 | 2146 | action3_if() { 2147 | if [[ -z $action3 ]]; then 2148 | echo "" 2149 | else 2150 | you_file=$action1 2151 | cd $HOME/$OW/$you_file/lede 2152 | rm -rf $HOME/$OW/$SF/tmp/* 2153 | case "$action3" in 2154 | other_plugins|make_j|new_source_make|clean_make|noclean_make|update_clean_make|update_clean_make_kernel|update_script_rely|n1_builder) 2155 | $action3 2156 | ;; 2157 | auto) 2158 | echo "" 2159 | ;; 2160 | *) 2161 | echo "" 2162 | echo -e "$red 命令不存在,使用方法参考以下!!!$white" 2163 | file_help 2164 | ;; 2165 | esac 2166 | fi 2167 | } 2168 | 2169 | 2170 | if [[ $(users) == "root" ]];then 2171 | echo -e "${red}请勿使用root进行编译!!!${white}" 2172 | exit 0 2173 | fi 2174 | 2175 | cd $shfile 2176 | git_branch=$(git fetch --all | git branch -v| grep -o "落后") 2177 | if [[ "$git_branch" == "落后" ]]; then 2178 | echo -e "$yellow>>当前你的脚本不是最新$white"  2179 | echo -e "$yellow开始更新到最新版本。。。$white"&& sleep 3 2180 | update_script 2181 | else 2182 | echo -e "$green脚本已经最新$white" && sleep 2 2183 | fi 2184 | 2185 | 2186 | 2187 | #copy by:Toyo modify:ITdesk 2188 | action1="$1" 2189 | action2="$2" 2190 | action3="$3" 2191 | 2192 | 2193 | 2194 | if [[ -z $action1 ]]; then 2195 | description_if 2196 | file_help 2197 | else 2198 | case "$action1" in 2199 | help) 2200 | file_help 2201 | ;; 2202 | update_script) 2203 | update_script 2204 | ;; 2205 | new_source_make) 2206 | new_source_make 2207 | ;; 2208 | actions_openwrt) 2209 | actions_openwrt 2210 | ;; 2211 | *) 2212 | action1_if 2213 | ;; 2214 | esac 2215 | fi 2216 | 2217 | --------------------------------------------------------------------------------