{"id":141,"date":"2018-12-01T00:06:24","date_gmt":"2018-11-30T16:06:24","guid":{"rendered":"http:\/\/www.zhangyijun.com\/?p=141"},"modified":"2018-12-01T00:06:24","modified_gmt":"2018-11-30T16:06:24","slug":"linux-vps-debianubuntu%e7%bd%91%e7%bb%9c%e5%ae%89%e8%a3%85-%e9%87%8d%e8%a3%85%e7%b3%bb%e7%bb%9f%e4%b8%80%e9%94%ae%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"http:\/\/www.zhangyijun.com\/?p=141","title":{"rendered":"[ Linux VPS ] Debian(Ubuntu)\u7f51\u7edc\u5b89\u88c5\/\u91cd\u88c5\u7cfb\u7edf\u4e00\u952e\u811a\u672c"},"content":{"rendered":"<p>\t\t\t\thttps:\/\/moeclub.org\/2017\/03\/25\/82\/?v=774<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li><strong>\u80cc\u666f<\/strong>:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u9002\u7528\u4e8e\u7531GRUB\u5f15\u5bfc\u7684CentOS,Ubuntu,Debian\u7cfb\u7edf.<br \/>\n\u4f7f\u7528\u5b98\u65b9\u53d1\u884c\u7248\u53bb\u6389\u6a21\u677f\u9884\u88c5\u7684\u8f6f\u4ef6.<br \/>\n\u540c\u65f6\u4e5f\u53ef\u4ee5\u89e3\u51b3\u5185\u6838\u7248\u672c\u4e0e\u8f6f\u4ef6\u4e0d\u517c\u5bb9\u7684\u95ee\u9898\u3002<br \/>\n\u53ea\u8981\u6709root\u6743\u9650,\u8fd8\u60a8\u4e00\u4e2a\u7eaf\u51c0\u7684\u7cfb\u7edf\u3002<\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li><strong>\u76f8\u5173\u6587\u7ae0<\/strong>:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong><a href=\"https:\/\/moeclub.org\/2018\/03\/26\/597\/\"><u>[ Linux VPS ] CentOS \u7f51\u7edc\u5b89\u88c5\/\u91cd\u88c5\u7cfb\u7edf\u4e00\u952e\u811a\u672c \u7eaf\u51c0\u5b89\u88c5<\/u><\/a><\/strong><\/p>\n<hr \/>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li><strong>\u6ce8\u610f<\/strong>:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u5168\u81ea\u52a8\u5b89\u88c5\u9ed8\u8ba4root\u5bc6\u7801:<code>Vicer<\/code>,\u5b89\u88c5\u5b8c\u6210\u540e\u8bf7\u7acb\u5373\u66f4\u6539\u5bc6\u7801.<br \/>\n\u8bf7\u4f7f\u7528\u00a0<code>passwd root<\/code>\u00a0\u547d\u4ee4\u66f4\u6539\u5bc6\u7801.<br \/>\n<strong>\u7279\u522b\u6ce8\u610f:<em><code>OpenVZ<\/code>\u6784\u67b6\u4e0d\u9002\u7528.<\/em><\/strong><\/p>\n<hr \/>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li><strong>\u66f4\u65b0<\/strong>:\n<ul>\n<li>[2018.04.03]<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u529f\u80fd\u5408\u5e76:<br \/>\n<strong><a href=\"https:\/\/moeclub.org\/2018\/04\/03\/603\/\" target=\"_blank\" rel=\"noopener noreferrer\"><u>[ Linux VPS ] Debian\/Ubuntu\/CentOS \u7f51\u7edc\u5b89\u88c5\/\u91cd\u88c5\u7cfb\u7edf\/\u7eaf\u51c0\u5b89\u88c5 \u4e00\u952e\u811a\u672c<\/u><\/a><\/strong><\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li>[2018.03.30]<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u4f18\u5316GRUB\u68c0\u6d4b\u6d4b\u903b\u8f91.<br \/>\n\u6dfb\u52a0\u7ec4\u4ef6\u4f9d\u8d56\u68c0\u6d4b.<br \/>\n\u4fee\u590d\u4e00\u4e9b\u5df2\u77e5BUG.<\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li>[2018.03.25]<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u4f18\u5316\u5224\u65ad\u903b\u8f91.<br \/>\n\u589e\u52a0\u624b\u52a8\u6307\u5b9a\u7f51\u7edc\u53c2\u6570\u9009\u9879,\u53ef\u6709\u6548\u907f\u514d\u81ea\u52a8\u83b7\u53d6\u7f51\u7edc\u53c2\u6570\u65e0\u6548\u9020\u6210\u65e0\u6cd5\u76f4\u63a5\u8054\u7f51\u7684\u95ee\u9898.<\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li>[2017.11.25]<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u91cd\u65b0\u89c4\u8303\u53c2\u6570<code>-d<\/code>\/<code>-u<\/code>.<\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li>[2017.11.22]<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u589e\u52a0\u81ea\u52a8dd\u5b89\u88c5Windows\u529f\u80fd,<a href=\"https:\/\/moeclub.org\/2017\/11\/19\/483\/\" target=\"_blank\" rel=\"noopener noreferrer\"><u>\u70b9\u51fb\u67e5\u770b\u8be6\u60c5<\/u><\/a>.<\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li>[2017.08.06]<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u589e\u52a0\u652f\u6301\u91cd\u88c5\u4e3aUbuntu\u7cfb\u7edf<br \/>\n<strong>\u5b89\u88c5Ubuntu\u65f6,\u5fc5\u987b\u4f7f\u7528<em>\u7248\u672c\u4ee3\u53f7<\/em>.<\/strong><br \/>\n\u5982\u6709\u5fc5\u8981,\u8bf7\u4f7f\u7528<code>--mirror<\/code>\u81ea\u884c\u66f4\u6362\u8f6f\u4ef6\u6e90.<br \/>\n\u4f7f\u7528\u65b9\u6cd5\u793a\u4f8b:<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>\u4ee5\u81ea\u52a8\u6a21\u5f0f\u5b89\u88c5<code>Ubuntu 16.04 64\u4f4d<\/code>\u4e3a\u4f8b:<\/li>\n<\/ul>\n<\/li>\n<li>\n<pre class=\"pure-highlightjs\"><code class=\"\" null=\"\">bash DebianNET.sh -u xenial -v 64 -a<\/code><\/pre>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>[2017.07.05]<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u4fee\u590d\u5728\u72ec\u670d\u4e0a\u5b89\u88c5\u7684\u4e00\u4e9b\u7531\u786c\u76d8\u5f15\u8d77\u7684\u95ee\u9898.<br \/>\n\u4fee\u590d\u5728<code>CentOS6<\/code>\u4e0a\u5224\u65ad\u7f51\u5361\u51fa\u9519\u7684\u95ee\u9898.<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>[2017.06.25]<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><em>\u9002\u914d\u4e86\u7531\u8f83\u8001GRUB\u7248\u672c\u5f15\u5bfc\u7684<code>CentOS6<\/code>\u7b49\u7cfb\u7edf.<\/em><br \/>\n\u53bb\u9664<code>-cn<\/code>\u53c2\u6570,\u6b64\u53c2\u6570\u4f5c\u7528\u4e0d\u5927.<br \/>\n<em>\u6dfb\u52a0<code>-apt\/--mirror<\/code>\u53c2\u6570,\u7528\u4e8e\u6307\u5b9a\u6e90(\u9700\u5b8c\u6574\u7684\u955c\u50cf\u6e90\u5730\u5740).<\/em><br \/>\n\u7528\u6cd5\u793a\u4f8b:<\/p>\n<div id=\"crayon-5c015d4e159bd530019445\" class=\"crayon-syntax crayon-theme-amity crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped\" data-settings=\" no-popup minimize scroll-mouseover wrap\">\n<div class=\"crayon-plain-wrap\"><\/div>\n<div class=\"crayon-main\">\n<pre class=\"pure-highlightjs\"><code class=\"\" null=\"\">--mirror 'http:\/\/ftp.riken.jp\/Linux\/debian\/debian\/'\n--mirror 'http:\/\/mirrors.ustc.edu.cn\/debian\/'<\/code><\/pre>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>[2017.06.24]<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u7531\u516c\u7f51\u63a2\u6d4bIP\u5730\u5740,\u6539\u4e3a\u672c\u673a\u63a2\u6d4bIP\u5730\u5740.\u9002\u914d\u66f4\u52a0\u5e7f\u6cdb.<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>[2017.06.23]<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u4fee\u590d<code>Debian9<\/code>\u4e0d\u80fd\u4f7f\u7528root\u767b\u9646\u7684\u95ee\u9898.<br \/>\n\u79fb\u9664\u5bf9\u4e8e<code>route<\/code>\u547d\u4ee4\u7684\u4f9d\u8d56,\u4f7f\u7528<code>ip<\/code>\u547d\u4ee4\u5e76\u8ba1\u7b97\u5b50\u7f51\u63a9\u7801.<br \/>\n\u4fee\u590d\u4f7f\u7528<code>ls<\/code>\u547d\u4ee4\u65f6\u7684\u4e00\u4e2a\u9519\u8bef\u8b66\u544a.<br \/>\n\u589e\u52a0<code>-cn<\/code>\u53c2\u6570,\u4f7f\u56fd\u5185\u673a\u5668\u4e0b\u8f7d\u6240\u9700\u8d44\u6e90\u66f4\u52a0\u8fc5\u901f.<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>[2017.06.20]<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u589e\u52a0\u5bf9<code>Debian9<\/code>\u7684\u652f\u6301,\u652f\u6301\u5168\u81ea\u52a8\u5316\u5b89\u88c5.<br \/>\n\u672a\u505a\u5927\u91cf\u6d4b\u8bd5,\u6709\u95ee\u9898\u8bf7\u53cd\u9988.<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>[2017.06.09]<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u6dfb\u52a0\u652f\u6301\u4ece<code>CentOS7<\/code>\u8fd0\u884c\u5168\u81ea\u52a8\u5316\u5b89\u88c5<code>Debian<\/code>.<br \/>\n\u7406\u8bba\u4e0a\u652f\u6301\u7531<code>grub2<\/code>\u5f15\u5bfc\u7684\u7cfb\u7edf(<code>CentOS6<\/code>\u7531<code>grub<\/code>\u5f15\u5bfc,\u6545\u4e0d\u652f\u6301.).<br \/>\n\u4f18\u5316\u5224\u65ad\u903b\u8f91,\u5220\u9664<code>\t-t<\/code>\u53c2\u6570.<br \/>\n\u6dfb\u52a0<code>-a<\/code>\u53c2\u6570<em>(\u5168\u81ea\u52a8\u5316\u5b89\u88c5)<\/em>\u548c<code>-m<\/code>\u53c2\u6570<em>(\u4eceVNC\u6a21\u5f0f\u5b89\u88c5)<\/em><\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>[2017.06.05]<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u4fee\u590d\u5168\u81ea\u52a8\u5b89\u88c5Debian8\u4f1a\u51fa\u73b0\u5361\u4f4f\u548c\u4e0d\u80fd\u4f7f\u7528root\u5bc6\u7801\u767b\u9646\u7684\u95ee\u9898.<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>[2017.06.04]<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u589e\u52a0\u5168\u81ea\u52a8\u65b9\u5f0f\u5b89\u88c5,\u5b9e\u73b0\u5728\u65e0\u6551\u63f4\u6a21\u5f0f,\u65e0VNC\u7684\u60c5\u51b5\u4e0b\u5b89\u88c5Debian.<br \/>\n\u5df2\u5728AWS Lightsail(Ubuntu),DigitalOcean,UltraVPS.eu\u901a\u8fc7\u6d4b\u8bd5.<br \/>\n\u9ed8\u8ba4root\u5bc6\u7801:<code>Vicer<\/code>,\u5b89\u88c5\u5b8c\u6210\u540e\u8bf7\u7acb\u5373\u66f4\u6539\u5bc6\u7801.<br \/>\n\u4f7f\u7528\u00a0<code>passwd root<\/code>\u00a0\u547d\u4ee4\u66f4\u6539\u5bc6\u7801.<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>[2017.03.28]<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u589e\u52a0\u4e86\u4e00\u4e2a\u4e4b\u53c2\u6570\u9009\u9879\uff1b<br \/>\n\u6b64\u53c2\u6570\u7528\u4e8e\u624b\u52a8\u6307\u5b9a\u673a\u5668\u7684\u865a\u62df\u5316\u7c7b\u578b\u3002<br \/>\n\u4e00\u822c\u60c5\u51b5\u4e0b\u4e0d\u9700\u8981\u6307\u5b9a\u6b64\u53c2\u6570\u3002<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>[2017.03.25]<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u4fee\u590d\u4e86\u4e00\u4e9b\u5df2\u77e5\u95ee\u9898\u3002<\/p>\n<hr \/>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li><strong>\u9700\u8981<\/strong>:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>1.<code>Debian\/Ubuntu\/CentOS<\/code>\u00a0\u7cfb\u7edf(\u7531<code>GRUB<\/code>\u5f15\u5bfc)\uff1b<br \/>\n2.<code>wget<\/code>\u00a0\u7528\u6765\u4e0b\u8f7d\u6587\u4ef6\uff0c\u83b7\u53d6\u516c\u7f51IP;<br \/>\n3.<code>ip<\/code>\u00a0\u83b7\u53d6\u7f51\u5173\uff0c\u63a9\u7801\u7b49;<br \/>\n4.<code>sed awk grep<\/code>\u00a0\u5904\u7406\u6587\u672c\u6d41\uff1b<br \/>\n5.<code>VNC<\/code>\u00a0\u5b89\u88c5\u7cfb\u7edf(\u6b64\u9879\u4e3a\u53ef\u9009)\u3002<\/p>\n<hr \/>\n<hr \/>\n<ul>\n<li><strong>\u786e\u4fdd\u5b89\u88c5\u4e86\u6240\u9700\u8f6f\u4ef6<\/strong>:<\/li>\n<\/ul>\n<pre class=\"pure-highlightjs\"><code class=\"\" null=\"\">#Debian\/Ubuntu:\napt-get install -y gawk sed grep\n \n#RedHat\/CentOS:\nyum install -y gawk sed grep<\/code><\/pre>\n<ul>\n<li><strong>\u5982\u679c\u51fa\u73b0\u4e86\u9519\u8bef,\u8bf7\u8fd0\u884c<\/strong>:<\/li>\n<\/ul>\n<pre class=\"pure-highlightjs\"><code class=\"\" null=\"\">#Debian\/Ubuntu:\napt-get update\n \n#RedHat\/CentOS:\nyum update<\/code><\/pre>\n<ul>\n<li><strong>\u4e00\u952e\u4e0b\u8f7d\u53ca\u4f7f\u7528<\/strong>:<\/li>\n<\/ul>\n<pre class=\"pure-highlightjs\"><code class=\"\" null=\"\">wget --no-check-certificate -qO DebianNET.sh 'https:\/\/moeclub.org\/attachment\/LinuxShell\/DebianNET.sh' &amp;&amp; chmod a+x DebianNET.sh<\/code><\/pre>\n<pre class=\"pure-highlightjs\"><code class=\"\" null=\"\">Usage:\n        bash DebianNET.sh       -d\/--debian [dist-name]\n                                -u\/--ubuntu [dist-name]\n                                -v\/--ver [32\/i386|64\/amd64]\n                                --ip-addr\/--ip-gate\/--ip-mask\n                                -apt\/--mirror\n                                -dd\/--image\n                                -a\/-m<\/code><\/pre>\n<ul>\n<li><strong>\u5168\u81ea\u52a8\/\u975e\u5168\u81ea\u52a8\u793a\u4f8b<\/strong>:\n<ul>\n<li>\u5168\u81ea\u52a8\u5b89\u88c5:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre class=\"pure-highlightjs\"><code class=\"\" null=\"\">bash DebianNET.sh -d wheezy -v i386 -a<\/code><\/pre>\n<ul>\n<li>VNC\u624b\u52a8\u5b89\u88c5:<\/li>\n<li>\n<pre class=\"pure-highlightjs\"><code class=\"\" null=\"\">bash DebianNET.sh -d wheezy -v i386 -m<\/code><\/pre>\n<ul>\n<li>\u5168\u81ea\u52a8\u5b89\u88c5(\u6307\u5b9a\u7f51\u7edc\u53c2\u6570):<\/li>\n<\/ul>\n<\/li>\n<li>\n<pre class=\"pure-highlightjs\"><code class=\"\" null=\"\"># \u5c06X.X.X.X\u66ff\u6362\u4e3a\u81ea\u5df1\u7684\u7f51\u7edc\u53c2\u6570.\n# --ip-addr :IP Address\/IP\u5730\u5740\n# --ip-gate :Gateway   \/\u7f51\u5173\n# --ip-mask :Netmask   \/\u5b50\u7f51\u63a9\u7801\n#bash DebianNET.sh -d wheezy -v i386 -a --ip-addr X.X.X.X --ip-mask X.X.X.X --ip-gate X.X.X.X<\/code><\/pre>\n<ul>\n<li><strong>\u4f7f\u7528\u793a\u4f8b<\/strong>:\n<ul>\n<li>\u3010\u9ed8\u8ba4\u3011\u5b89\u88c5Debian 7 x32\uff1a<\/li>\n<\/ul>\n<\/li>\n<li>\n<pre class=\"pure-highlightjs\"><code class=\"\" null=\"\">bash DebianNET.sh -d wheezy -v i386\n\nbash DebianNET.sh -d 7 -v 32<\/code><\/pre>\n<ul>\n<li>\u5b89\u88c5Debian 8 x64\uff1a<\/li>\n<\/ul>\n<\/li>\n<li>\n<pre class=\"pure-highlightjs\"><code class=\"\" null=\"\">bash DebianNET.sh -d jessie -v amd64<\/code><\/pre>\n<pre class=\"pure-highlightjs\"><code class=\"\" null=\"\">bash DebianNET.sh -d 8 -v 64<\/code><\/pre>\n<p>&nbsp;<\/li>\n<li>\u5b89\u88c5Debian 9 x64\uff1a<\/li>\n<\/ul>\n<\/li>\n<li>\n<pre class=\"pure-highlightjs\"><code class=\"\" null=\"\">bash DebianNET.sh -d stretch -v amd64<\/code><\/pre>\n<pre class=\"pure-highlightjs\"><code class=\"\" null=\"\">bash DebianNET.sh -d 9 -v 64<\/code><\/pre>\n<ul>\n<li>\u5b89\u88c5Ubuntu 14.04 x64\uff1a<\/li>\n<\/ul>\n<\/li>\n<li>\n<pre class=\"pure-highlightjs\"><code class=\"\" null=\"\">bash DebianNET.sh -u trusty -v 64<\/code><\/pre>\n<ul>\n<li>\u5b89\u88c5Ubuntu 16.04 x64\uff1a<\/li>\n<\/ul>\n<\/li>\n<li>\n<pre class=\"pure-highlightjs\"><code class=\"\" null=\"\">bash DebianNET.sh -u xenial -v 64<\/code><\/pre>\n<ul>\n<li>\u5b89\u88c5Ubuntu 18.04 x64\uff1a<\/li>\n<\/ul>\n<\/li>\n<li>\n<pre class=\"pure-highlightjs\"><code class=\"\" null=\"\">bash DebianNET.sh -u bionic -v 64<\/code><\/pre>\n<ul>\n<li><strong>\u3010\u9ed8\u8ba4\u3011\u9884\u89c8<\/strong>:<\/li>\n<li><strong>\u5b8c\u6574\u4ee3\u7801<\/strong>:<\/li>\n<li>\n<pre class=\"pure-highlightjs\"><code class=\"\" null=\"\">#!\/bin\/bash\n \nexport tmpVER=''\nexport tmpDIST=''\nexport tmpURL=''\nexport tmpWORD=''\nexport tmpMirror=''\nexport tmpSSL=''\nexport tmpINS=''\nexport tmpFW=''\nexport ipAddr=''\nexport ipMask=''\nexport ipGate=''\nexport linuxdists=''\nexport ddMode='0'\nexport setNet='0'\nexport isMirror='0'\nexport FindDists='0'\n \nwhile [[ $# -ge 1 ]]; do\n  case $1 in\n    -v|--ver)\n      shift\n      tmpVER=\"$1\"\n      shift\n      ;;\n    -d|--debian)\n      shift\n      linuxdists='debian'\n      tmpDIST=\"$1\"\n      shift\n      ;;\n    -u|--ubuntu)\n      shift\n      linuxdists='ubuntu'\n      tmpDIST=\"$1\"\n      shift\n      ;;\n    -dd|--image)\n      shift\n      ddMode='1'\n      tmpURL=\"$1\"\n      shift\n      ;;\n    -p|--password)\n      shift\n      tmpWORD=\"$1\"\n      shift\n      ;;\n    --ip-addr)\n      shift\n      ipAddr=\"$1\"\n      shift\n      ;;\n    --ip-mask)\n      shift\n      ipMask=\"$1\"\n      shift\n      ;;\n    --ip-gate)\n      shift\n      ipGate=\"$1\"\n      shift\n      ;;\n    -a|--auto)\n      shift\n      tmpINS='auto'\n      ;;\n    -m|--manual)\n      shift\n      tmpINS='manual'\n      ;;\n    -apt|--mirror)\n      shift\n      isMirror='1'\n      tmpMirror=\"$1\"\n      shift\n      ;;\n    -ssl)\n      shift\n      tmpSSL=\"$1\"\n      shift\n      ;;\n    --firmware)\n      shift\n      tmpFW='1'\n      ;;\n    *)\n      echo -ne \" Usage:\\n\\tbash DebianNET.sh\\t-d\/--debian [\\033[33m\\033[04mdists-name\\033[0m]\\n\\t\\t\\t\\t-u\/--ubuntu [\\033[04mdists-name\\033[0m]\\n\\t\\t\\t\\t-v\/--ver [32\/\\033[33m\\033[04mi386\\033[0m|64\/amd64]\\n\\t\\t\\t\\t--ip-addr\/--ip-gate\/--ip-mask\\n\\t\\t\\t\\t-apt\/--mirror\\n\\t\\t\\t\\t-dd\/--image\\n\\t\\t\\t\\t-a\/--auto\\n\\t\\t\\t\\t-m\/--manual\\n\"\n      exit 1;\n      ;;\n    esac\n  done\n \n[[ \"$EUID\" -ne '0' ]] &amp;&amp; echo \"Error:This script must be run as root!\" &amp;&amp; exit 1;\n \nfunction CheckDependence(){\nFullDependence='0';\nfor BIN_DEP in `echo \"$1\" |sed 's\/,\/\\n\/g'`\n  do\n    if [[ -n \"$BIN_DEP\" ]]; then\n      Founded='0';\n      for BIN_PATH in `echo \"$PATH\" |sed 's\/:\/\\n\/g'`\n        do\n          ls $BIN_PATH\/$BIN_DEP &gt;\/dev\/null 2&gt;&amp;1;\n          if [ $? == '0' ]; then\n            Founded='1';\n            break;\n          fi\n        done\n      if [ \"$Founded\" == '1' ]; then\n        echo -en \"$BIN_DEP\\t\\t[\\033[32mok\\033[0m]\\n\";\n      else\n        FullDependence='1';\n        echo -en \"$BIN_DEP\\t\\t[\\033[31mfail\\033[0m]\\n\";\n      fi\n    fi\n  done\nif [ \"$FullDependence\" == '1' ]; then\n  exit 1;\nfi\n}\n \nclear &amp;&amp; echo -e \"\\n\\033[36m# Check Dependence\\033[0m\\n\"\nCheckDependence wget,awk,grep,sed,cut,cat,cpio,gzip\n \n[ \"$ddMode\" == '1' ] &amp;&amp; {\nCheckDependence iconv\n}\n \n[[ -f '\/boot\/grub\/grub.cfg' ]] &amp;&amp; GRUBOLD='0' &amp;&amp; GRUBDIR='\/boot\/grub' &amp;&amp; GRUBFILE='grub.cfg';\n[[ -z \"$GRUBDIR\" ]] &amp;&amp; [[ -f '\/boot\/grub2\/grub.cfg' ]] &amp;&amp; GRUBOLD='0' &amp;&amp; GRUBDIR='\/boot\/grub2' &amp;&amp; GRUBFILE='grub.cfg';\n[[ -z \"$GRUBDIR\" ]] &amp;&amp; [[ -f '\/boot\/grub\/grub.conf' ]] &amp;&amp; GRUBOLD='1' &amp;&amp; GRUBDIR='\/boot\/grub' &amp;&amp; GRUBFILE='grub.conf';\n[ -z \"$GRUBDIR\" -o -z \"$GRUBFILE\" ] &amp;&amp; echo -ne \"Error! \\nNot Found grub path.\\n\" &amp;&amp; exit 1;\n \n[[ -n \"$tmpVER\" ]] &amp;&amp; {\n  [ \"$tmpVER\" == '32' -o \"$tmpVER\" == 'i386' ] &amp;&amp; VER='i386';\n  [ \"$tmpVER\" == '64' -o \"$tmpVER\" == 'amd64' ] &amp;&amp; VER='amd64';\n}\n[[ -z \"$VER\" ]] &amp;&amp; VER='i386';\n \n[[ -z \"$linuxdists\" ]] &amp;&amp; linuxdists='debian';\n \n[[ \"$isMirror\" == '1' ]] &amp;&amp; [[ -n \"$tmpMirror\" ]] &amp;&amp; {\n  tmpDebianMirror=\"$(echo -n \"$tmpMirror\" |grep -Eo '.*\\.(\\w+)')\";\n  echo -n \"$tmpDebianMirror\" |grep -q ':\/\/';\n  [[ $? -eq '0' ]] &amp;&amp; {\n    DebianMirror=\"$(echo -n \"$tmpDebianMirror\" |awk -F':\/\/' '{print $2}')\";\n  } || {\n    DebianMirror=\"$(echo -n \"$tmpDebianMirror\")\";\n  }\n} || {\n  [[ \"$linuxdists\" == 'debian' ]] &amp;&amp; DebianMirror='httpredir.debian.org';\n  [[ \"$linuxdists\" == 'ubuntu' ]] &amp;&amp; DebianMirror='archive.ubuntu.com';\n}\n \n[[ -z \"$DebianMirrorDirectory\" ]] &amp;&amp; [[ -n \"$DebianMirror\" ]] &amp;&amp; [[ -n \"$tmpMirror\" ]] &amp;&amp; {\n  DebianMirrorDirectory=\"$(echo -n \"$tmpMirror\" |awk -F''${DebianMirror}'' '{print $2}' |sed 's\/\\\/$\/\/g')\";\n}\n \n[[ -n \"$DebianMirror\" ]] &amp;&amp; {\n  [[ \"$DebianMirrorDirectory\" == '\/' ]] &amp;&amp; {\n    [[ \"$linuxdists\" == 'debian' ]] &amp;&amp; DebianMirrorDirectory='\/debian';\n    [[ \"$linuxdists\" == 'ubuntu' ]] &amp;&amp; DebianMirrorDirectory='\/ubuntu';\n  }\n  [[ -z \"$DebianMirrorDirectory\" ]] &amp;&amp; {\n    [[ \"$linuxdists\" == 'debian' ]] &amp;&amp; DebianMirrorDirectory='\/debian';\n    [[ \"$linuxdists\" == 'ubuntu' ]] &amp;&amp; DebianMirrorDirectory='\/ubuntu';\n  }\n}\n \n[[ -z \"$tmpDIST\" ]] &amp;&amp; {\n  [[ \"$linuxdists\" == 'debian' ]] &amp;&amp; DIST='wheezy';\n  [[ \"$linuxdists\" == 'ubuntu' ]] &amp;&amp; DIST='trusty';\n}\n \n[[ -z \"$DIST\" ]] &amp;&amp; {\n  DIST=\"$(echo \"$tmpDIST\" |sed -r 's\/(.*)\/\\L\\1\/')\";\n  echo \"$DIST\" |grep -q '[0-9]';\n  [[ $? -eq '0' ]] &amp;&amp; {\n    isDigital=\"$(echo \"$DIST\" |grep -o '[0-9\\.]\\{1,\\}' |sed -n '1h;1!H;$g;s\/\\n\/\/g;$p' |cut -d'.' -f1)\";\n    [[ -n $isDigital ]] &amp;&amp; {\n      [[ \"$isDigital\" == '7' ]] &amp;&amp; DIST='wheezy';\n      [[ \"$isDigital\" == '8' ]] &amp;&amp; DIST='jessie';\n      [[ \"$isDigital\" == '9' ]] &amp;&amp; DIST='stretch';\n      [[ \"$isDigital\" == '10' ]] &amp;&amp; DIST='buster';\n    }\n  }\n}\n \n[[ \"$ddMode\" == '1' ]] &amp;&amp; {\n  [[ -n \"$tmpURL\" ]] &amp;&amp; {\n    linuxdists='debian';\n    DIST='jessie';\n    VER='amd64';\n    tmpINS='auto';\n    DDURL=\"$tmpURL\"\n    echo \"$DDURL\" |grep -q '^http:\/\/\\|^ftp:\/\/\\|^https:\/\/';\n    [[ $? -ne '0' ]] &amp;&amp; echo 'Please input vaild URL,Only support http:\/\/, ftp:\/\/ and https:\/\/ !' &amp;&amp; exit 1;\n    [[ -n \"$tmpSSL\" ]] &amp;&amp; SSL_SUPPORT=\"$tmpSSL\";\n    [[ -z \"$SSL_SUPPORT\" ]] &amp;&amp; SSL_SUPPORT='https:\/\/moeclub.org\/get-wget_udeb_amd64';\n  } || {\n    echo 'Please input vaild URL! ';\n    exit 1;\n  }\n}\n \nDistsList=\"$(wget --no-check-certificate -qO- \"http:\/\/$DebianMirror$DebianMirrorDirectory\/dists\/\" |grep -o 'href=.*\/\"' |cut -d'\"' -f2 |sed '\/-\\|old\\|Debian\\|experimental\\|stable\\|test\\|sid\\|devel\/d' |grep '^[^\/]' |sed -n '1h;1!H;$g;s\/\\n\/\/g;s\/\\\/\/\\;\/g;$p')\";\nfor CheckDEB in `echo \"$DistsList\" |sed 's\/;\/\\n\/g'`\n  do\n    [[ \"$CheckDEB\" == \"$DIST\" ]] &amp;&amp; FindDists='1';\n    [[ \"$FindDists\" == '1' ]] &amp;&amp; break;\n  done\n[[ \"$FindDists\" == '0' ]] &amp;&amp; {\n  echo -ne '\\nThe dists version not found, Please check it! \\n\\n'\n  bash $0 error;\n  exit 1;\n}\n \n[[ -n \"$tmpINS\" ]] &amp;&amp; {\n  [[ \"$tmpINS\" == 'auto' ]] &amp;&amp; inVNC='n';\n  [[ \"$tmpINS\" == 'manual' ]] &amp;&amp; inVNC='y';\n}\n \n[ -n \"$ipAddr\" ] &amp;&amp; [ -n \"$ipMask\" ] &amp;&amp; [ -n \"$ipGate\" ] &amp;&amp; setNet='1';\n[[ -n \"$tmpWORD\" ]] &amp;&amp; myPASSWORD=\"$tmpWORD\";\n[[ -n \"$tmpFW\" ]] &amp;&amp; INCFW=\"$tmpFW\";\n[[ -z \"$myPASSWORD\" ]] &amp;&amp; myPASSWORD='Vicer';\n[[ -z \"$INCFW\" ]] &amp;&amp; INCFW='0';\n \nclear &amp;&amp; echo -e \"\\n\\033[36m# Install\\033[0m\\n\"\n \nASKVNC(){\n  inVNC='y';\n  [[ \"$ddMode\" == '0' ]] &amp;&amp; {\n    echo -ne \"\\033[34mCan you login VNC?\\033[0m\\e[33m[\\e[32my\\e[33m\/n]\\e[0m \"\n    read tmpinVNC\n    [[ -n \"$tmpinVNC\" ]] &amp;&amp; inVNCtmp=\"$tmpinVNC\"\n  }\n  [ \"$inVNCtmp\" == 'y' -o \"$inVNCtmp\" == 'Y' ] &amp;&amp; inVNC='y';\n  [ \"$inVNCtmp\" == 'n' -o \"$inVNCtmp\" == 'N' ] &amp;&amp; inVNC='n';\n}\n \n[ \"$inVNC\" == 'y' -o \"$inVNC\" == 'n' ] || ASKVNC;\n[[ \"$linuxdists\" == 'debian' ]] &amp;&amp; LinuxName='Debian';\n[[ \"$linuxdists\" == 'ubuntu' ]] &amp;&amp; LinuxName='Ubuntu';\n[[ \"$ddMode\" == '0' ]] &amp;&amp; { \n  [[ \"$inVNC\" == 'y' ]] &amp;&amp; echo -e \"\\033[34mManual Mode\\033[0m insatll \\033[33m$LinuxName\\033[0m [\\033[33m$DIST\\033[0m] [\\033[33m$VER\\033[0m] in VNC. \"\n  [[ \"$inVNC\" == 'n' ]] &amp;&amp; echo -e \"\\033[34mAuto Mode\\033[0m insatll \\033[33m$LinuxName\\033[0m [\\033[33m$DIST\\033[0m] [\\033[33m$VER\\033[0m]. \"\n}\n[[ \"$ddMode\" == '1' ]] &amp;&amp; {\n  echo -ne \"\\033[34mAuto Mode\\033[0m insatll \\033[33mWindows\\033[0m\\n[\\033[33m$DDURL\\033[0m]\\n\"\n}\n \necho -e \"\\n[\\033[33m$LinuxName\\033[0m] [\\033[33m$DIST\\033[0m] [\\033[33m$VER\\033[0m] Downloading...\"\n[[ -z \"$DebianMirror\" ]] &amp;&amp; echo -ne \"\\033[31mError! \\033[0mGet debian mirror fail! \\n\" &amp;&amp; exit 1\n[[ -z \"$DebianMirrorDirectory\" ]] &amp;&amp; echo -ne \"\\033[31mError! \\033[0mGet debian mirror directory fail! \\n\" &amp;&amp; exit 1\nwget --no-check-certificate -qO '\/boot\/initrd.gz' \"http:\/\/$DebianMirror$DebianMirrorDirectory\/dists\/$DIST\/main\/installer-$VER\/current\/images\/netboot\/$linuxdists-installer\/$VER\/initrd.gz\"\n[[ $? -ne '0' ]] &amp;&amp; echo -ne \"\\033[31mError! \\033[0mDownload 'initrd.gz' failed! \\n\" &amp;&amp; exit 1\nwget --no-check-certificate -qO '\/boot\/linux' \"http:\/\/$DebianMirror$DebianMirrorDirectory\/dists\/$DIST\/main\/installer-$VER\/current\/images\/netboot\/$linuxdists-installer\/$VER\/linux\"\n[[ $? -ne '0' ]] &amp;&amp; echo -ne \"\\033[31mError! \\033[0mDownload 'linux' failed! \\n\" &amp;&amp; exit 1\n[[ \"$INCFW\" == '1' ]] &amp;&amp; [[ \"$linuxdists\" == 'debian' ]] &amp;&amp; {\n  wget --no-check-certificate -qO '\/boot\/firmware.cpio.gz' \"http:\/\/cdimage.debian.org\/cdimage\/unofficial\/non-free\/firmware\/$DIST\/current\/firmware.cpio.gz\"\n  [[ $? -ne '0' ]] &amp;&amp; echo -ne \"\\033[31mError! \\033[0mDownload 'firmware' failed! \\n\" &amp;&amp; exit 1\n}\n \n[[ \"$setNet\" == '1' ]] &amp;&amp; {\n  IPv4=\"$ipAddr\";\n  MASK=\"$ipMask\";\n  GATE=\"$ipGate\";\n} || {\n  DEFAULTNET=\"$(ip route show |grep -o 'default via [0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.*' |head -n1 |sed 's\/proto.*\\|onlink.*\/\/g' |awk '{print $NF}')\";\n  [[ -n \"$DEFAULTNET\" ]] &amp;&amp; IPSUB=\"$(ip addr |grep ''${DEFAULTNET}'' |grep 'global' |grep 'brd' |head -n1 |grep -o '[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}\/[0-9]\\{1,2\\}')\";\n  IPv4=\"$(echo -n \"$IPSUB\" |cut -d'\/' -f1)\";\n  NETSUB=\"$(echo -n \"$IPSUB\" |grep -o '\/[0-9]\\{1,2\\}')\";\n  GATE=\"$(ip route show |grep -o 'default via [0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}' |head -n1 |grep -o '[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}')\";\n  [[ -n \"$NETSUB\" ]] &amp;&amp; MASK=\"$(echo -n '128.0.0.0\/1,192.0.0.0\/2,224.0.0.0\/3,240.0.0.0\/4,248.0.0.0\/5,252.0.0.0\/6,254.0.0.0\/7,255.0.0.0\/8,255.128.0.0\/9,255.192.0.0\/10,255.224.0.0\/11,255.240.0.0\/12,255.248.0.0\/13,255.252.0.0\/14,255.254.0.0\/15,255.255.0.0\/16,255.255.128.0\/17,255.255.192.0\/18,255.255.224.0\/19,255.255.240.0\/20,255.255.248.0\/21,255.255.252.0\/22,255.255.254.0\/23,255.255.255.0\/24,255.255.255.128\/25,255.255.255.192\/26,255.255.255.224\/27,255.255.255.240\/28,255.255.255.248\/29,255.255.255.252\/30,255.255.255.254\/31,255.255.255.255\/32' |grep -o '[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}'${NETSUB}'' |cut -d'\/' -f1)\";\n}\n \n[[ -n \"$GATE\" ]] &amp;&amp; [[ -n \"$MASK\" ]] &amp;&amp; [[ -n \"$IPv4\" ]] || {\necho \"Not found `ip command`, It will use `route command`.\"\nipNum() {\n  local IFS='.';\n  read ip1 ip2 ip3 ip4 &lt;&lt;&lt;\"$1\";\n  echo $((ip1*(1&lt;&lt;24)+ip2*(1&lt;&lt;16)+ip3*(1&lt;&lt;8)+ip4));\n}\n \nSelectMax(){\nii=0;\nfor IPITEM in `route -n |awk -v OUT=$1 '{print $OUT}' |grep '[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}'`\n  do\n    NumTMP=\"$(ipNum $IPITEM)\";\n    eval \"arrayNum[$ii]='$NumTMP,$IPITEM'\";\n    ii=$[$ii+1];\n  done\necho ${arrayNum[@]} |sed 's\/\\s\/\\n\/g' |sort -n -k 1 -t ',' |tail -n1 |cut -d',' -f2;\n}\n \n[[ -z $IPv4 ]] &amp;&amp; IPv4=\"$(ifconfig |grep 'Bcast' |head -n1 |grep -o '[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}' |head -n1)\";\n[[ -z $GATE ]] &amp;&amp; GATE=\"$(SelectMax 2)\";\n[[ -z $MASK ]] &amp;&amp; MASK=\"$(SelectMax 3)\";\n \n[[ -n \"$GATE\" ]] &amp;&amp; [[ -n \"$MASK\" ]] &amp;&amp; [[ -n \"$IPv4\" ]] || {\n  echo \"Error! Not configure network. \";\n  exit 1;\n}\n}\n \n[[ \"$setNet\" != '1' ]] &amp;&amp; [[ -f '\/etc\/network\/interfaces' ]] &amp;&amp; {\n  [[ -z \"$(sed -n '\/iface.*inet static\/p' \/etc\/network\/interfaces)\" ]] &amp;&amp; AutoNet='1' || AutoNet='0';\n  [[ -d \/etc\/network\/interfaces.d ]] &amp;&amp; {\n    ICFGN=\"$(find \/etc\/network\/interfaces.d -name '*.cfg' |wc -l)\" || ICFGN='0';\n    [[ \"$ICFGN\" -ne '0' ]] &amp;&amp; {\n      for NetCFG in `ls -1 \/etc\/network\/interfaces.d\/*.cfg`\n        do \n          [[ -z \"$(cat $NetCFG | sed -n '\/iface.*inet static\/p')\" ]] &amp;&amp; AutoNet='1' || AutoNet='0';\n          [[ \"$AutoNet\" -eq '0' ]] &amp;&amp; break;\n        done\n    }\n  }\n}\n \n[[ \"$setNet\" != '1' ]] &amp;&amp; [[ -d '\/etc\/sysconfig\/network-scripts' ]] &amp;&amp; {\n  ICFGN=\"$(find \/etc\/sysconfig\/network-scripts -name 'ifcfg-*' |grep -v 'lo'|wc -l)\" || ICFGN='0';\n  [[ \"$ICFGN\" -ne '0' ]] &amp;&amp; {\n    for NetCFG in `ls -1 \/etc\/sysconfig\/network-scripts\/ifcfg-* |grep -v 'lo$' |grep -v ':[0-9]\\{1,\\}'`\n      do \n        [[ -n \"$(cat $NetCFG | sed -n '\/BOOTPROTO.*[dD][hH][cC][pP]\/p')\" ]] &amp;&amp; AutoNet='1' || {\n          AutoNet='0' &amp;&amp; . $NetCFG;\n          [[ -n $NETMASK ]] &amp;&amp; MASK=\"$NETMASK\";\n          [[ -n $GATEWAY ]] &amp;&amp; GATE=\"$GATEWAY\";\n        }\n        [[ \"$AutoNet\" -eq '0' ]] &amp;&amp; break;\n      done\n  }\n}\n \n[[ ! -f $GRUBDIR\/$GRUBFILE ]] &amp;&amp; echo \"Error! Not Found $GRUBFILE. \" &amp;&amp; exit 1;\n \n[[ ! -f $GRUBDIR\/$GRUBFILE.old ]] &amp;&amp; [[ -f $GRUBDIR\/$GRUBFILE.bak ]] &amp;&amp; mv -f $GRUBDIR\/$GRUBFILE.bak $GRUBDIR\/$GRUBFILE.old;\nmv -f $GRUBDIR\/$GRUBFILE $GRUBDIR\/$GRUBFILE.bak;\n[[ -f $GRUBDIR\/$GRUBFILE.old ]] &amp;&amp; cat $GRUBDIR\/$GRUBFILE.old &gt;$GRUBDIR\/$GRUBFILE || cat $GRUBDIR\/$GRUBFILE.bak &gt;$GRUBDIR\/$GRUBFILE;\n \n[[ \"$GRUBOLD\" == '0' ]] &amp;&amp; {\n  READGRUB='\/tmp\/grub.read'\n  cat $GRUBDIR\/$GRUBFILE |sed -n '1h;1!H;$g;s\/\\n\/+++\/g;$p' |grep -oPm 1 'menuentry\\ .*\\{.*\\}\\+\\+\\+' |sed 's\/\\+\\+\\+\/\\n\/g' &gt;$READGRUB\n  LoadNum=\"$(cat $READGRUB |grep -c 'menuentry ')\"\n  if [[ \"$LoadNum\" -eq '1' ]]; then\n    cat $READGRUB |sed '\/^$\/d' &gt;\/tmp\/grub.new;\n  elif [[ \"$LoadNum\" -gt '1' ]]; then\n    CFG0=\"$(awk '\/menuentry \/{print NR}' $READGRUB|head -n 1)\";\n    CFG2=\"$(awk '\/menuentry \/{print NR}' $READGRUB|head -n 2 |tail -n 1)\";\n    CFG1=\"\";\n    for tmpCFG in `awk '\/}\/{print NR}' $READGRUB`\n      do\n        [ \"$tmpCFG\" -gt \"$CFG0\" -a \"$tmpCFG\" -lt \"$CFG2\" ] &amp;&amp; CFG1=\"$tmpCFG\";\n      done\n    [[ -z \"$CFG1\" ]] &amp;&amp; {\n      echo \"Error! read $GRUBFILE. \";\n      exit 1;\n    }\n \n    sed -n \"$CFG0,$CFG1\"p $READGRUB &gt;\/tmp\/grub.new;\n    [[ -f \/tmp\/grub.new ]] &amp;&amp; [[ \"$(grep -c '{' \/tmp\/grub.new)\" -eq \"$(grep -c '}' \/tmp\/grub.new)\" ]] || {\n      echo -ne \"\\033[31mError! \\033[0mNot configure $GRUBFILE. \\n\";\n      exit 1;\n    }\n  fi\n  [ ! -f \/tmp\/grub.new ] &amp;&amp; echo \"Error! $GRUBFILE. \" &amp;&amp; exit 1;\n  sed -i \"\/menuentry.*\/c\\menuentry\\ \\'Install OS \\[$DIST\\ $VER\\]\\'\\ --class debian\\ --class\\ gnu-linux\\ --class\\ gnu\\ --class\\ os\\ \\{\" \/tmp\/grub.new\n  sed -i \"\/echo.*Loading\/d\" \/tmp\/grub.new;\n}\n \n[[ \"$GRUBOLD\" == '1' ]] &amp;&amp; {\n  CFG0=\"$(awk '\/title \/{print NR}' $GRUBDIR\/$GRUBFILE|head -n 1)\";\n  CFG1=\"$(awk '\/title \/{print NR}' $GRUBDIR\/$GRUBFILE|head -n 2 |tail -n 1)\";\n  [[ -n $CFG0 ]] &amp;&amp; [ -z $CFG1 -o $CFG1 == $CFG0 ] &amp;&amp; sed -n \"$CFG0,$\"p $GRUBDIR\/$GRUBFILE &gt;\/tmp\/grub.new;\n  [[ -n $CFG0 ]] &amp;&amp; [ -z $CFG1 -o $CFG1 != $CFG0 ] &amp;&amp; sed -n \"$CFG0,$CFG1\"p $GRUBDIR\/$GRUBFILE &gt;\/tmp\/grub.new;\n  [[ ! -f \/tmp\/grub.new ]] &amp;&amp; echo \"Error! configure append $GRUBFILE. \" &amp;&amp; exit 1;\n  sed -i \"\/title.*\/c\\title\\ \\'Install OS \\[$DIST\\ $VER\\]\\'\" \/tmp\/grub.new;\n  sed -i '\/^#\/d' \/tmp\/grub.new;\n}\n \n[[ -n \"$(grep 'linux.*\/\\|kernel.*\/' \/tmp\/grub.new |awk '{print $2}' |tail -n 1 |grep '^\/boot\/')\" ]] &amp;&amp; Type='InBoot' || Type='NoBoot';\n \nLinuxKernel=\"$(grep 'linux.*\/\\|kernel.*\/' \/tmp\/grub.new |awk '{print $1}' |head -n 1)\";\n[[ -z \"$LinuxKernel\" ]] &amp;&amp; echo \"Error! read grub config! \" &amp;&amp; exit 1;\nLinuxIMG=\"$(grep 'initrd.*\/' \/tmp\/grub.new |awk '{print $1}' |tail -n 1)\";\n[ -z \"$LinuxIMG\" ] &amp;&amp; sed -i \"\/$LinuxKernel.*\\\/\/a\\\\\\tinitrd\\ \\\/\" \/tmp\/grub.new &amp;&amp; LinuxIMG='initrd';\n \n[[ \"$Type\" == 'InBoot' ]] &amp;&amp; {\n  sed -i \"\/$LinuxKernel.*\\\/\/c\\\\\\t$LinuxKernel\\\\t\\\/boot\\\/linux auto=true hostname=$linuxdists domain= -- quiet\" \/tmp\/grub.new;\n  sed -i \"\/$LinuxIMG.*\\\/\/c\\\\\\t$LinuxIMG\\\\t\\\/boot\\\/initrd.gz\" \/tmp\/grub.new;\n}\n \n[[ \"$Type\" == 'NoBoot' ]] &amp;&amp; {\n  sed -i \"\/$LinuxKernel.*\\\/\/c\\\\\\t$LinuxKernel\\\\t\\\/linux auto=true hostname=$linuxdists domain= -- quiet\" \/tmp\/grub.new;\n  sed -i \"\/$LinuxIMG.*\\\/\/c\\\\\\t$LinuxIMG\\\\t\\\/initrd.gz\" \/tmp\/grub.new;\n}\n \nsed -i '$a\\\\n' \/tmp\/grub.new;\n \n[[ \"$inVNC\" == 'n' ]] &amp;&amp; {\nGRUBPATCH='0';\n \n[ -f '\/etc\/network\/interfaces' -o -d '\/etc\/sysconfig\/network-scripts' ] || {\n  echo \"Error, Not found interfaces config.\";\n  exit 1;\n}\n \nINSERTGRUB=\"$(awk '\/menuentry \/{print NR}' $GRUBDIR\/$GRUBFILE|head -n 1)\"\nsed -i ''${INSERTGRUB}'i\\\\n' $GRUBDIR\/$GRUBFILE;\nsed -i ''${INSERTGRUB}'r \/tmp\/grub.new' $GRUBDIR\/$GRUBFILE;\n[[ -f  $GRUBDIR\/grubenv ]] &amp;&amp; sed -i 's\/saved_entry\/#saved_entry\/g' $GRUBDIR\/grubenv;\n \n[[ -d \/boot\/tmp ]] &amp;&amp; rm -rf \/boot\/tmp;\nmkdir -p \/boot\/tmp;\ncd \/boot\/tmp;\ngzip -d &lt; ..\/initrd.gz | cpio --extract --verbose --make-directories --no-absolute-filenames &gt;&gt;\/dev\/null 2&gt;&amp;1\n \ncat &gt;\/boot\/tmp\/preseed.cfg&lt;&lt;EOF\nd-i debian-installer\/locale string en_US\nd-i console-setup\/layoutcode string us\n \nd-i keyboard-configuration\/xkb-keymap string us\n \nd-i netcfg\/choose_interface select auto\n \nd-i netcfg\/disable_autoconfig boolean true\nd-i netcfg\/dhcp_failed note\nd-i netcfg\/dhcp_options select Configure network manually\nd-i netcfg\/get_ipaddress string $IPv4\nd-i netcfg\/get_netmask string $MASK\nd-i netcfg\/get_gateway string $GATE\nd-i netcfg\/get_nameservers string 8.8.8.8\nd-i netcfg\/no_default_route boolean true\nd-i netcfg\/confirm_static boolean true\n \nd-i hw-detect\/load_firmware boolean true\n \nd-i mirror\/country string manual\nd-i mirror\/http\/hostname string $DebianMirror\nd-i mirror\/http\/directory string $DebianMirrorDirectory\nd-i mirror\/http\/proxy string\n \nd-i passwd\/root-login boolean ture\nd-i passwd\/make-user boolean false\nd-i passwd\/root-password password $myPASSWORD\nd-i passwd\/root-password-again password $myPASSWORD\nd-i user-setup\/allow-password-weak boolean true\nd-i user-setup\/encrypt-home boolean false\n \nd-i clock-setup\/utc boolean true\nd-i time\/zone string US\/Eastern\nd-i clock-setup\/ntp boolean true\n \nd-i preseed\/early_command string anna-install libfuse2-udeb fuse-udeb ntfs-3g-udeb fuse-modules-3.16.0-4-amd64-di\nd-i partman\/early_command string \\\ndebconf-set partman-auto\/disk \"\\$(list-devices disk |head -n1)\"; \\\nwget -qO- '$DDURL' |gunzip -dc |\/bin\/dd of=\\$(list-devices disk |head -n1); \\\nmount.ntfs-3g \\$(list-devices partition |head -n1) \/mnt; \\\ncd '\/mnt\/ProgramData\/Microsoft\/Windows\/Start Menu\/Programs'; \\\ncd Start* || cd start*; \\\ncp -f '\/net.bat' '.\/net.bat'; \\\n\/sbin\/reboot; \\\ndebconf-set grub-installer\/bootdev string \"\\$(list-devices disk |head -n1)\"; \\\numount \/media || true; \\\n \nd-i partman\/mount_style select uuid\nd-i partman-auto\/init_automatically_partition select Guided - use entire disk\nd-i partman-auto\/method string regular\nd-i partman-lvm\/device_remove_lvm boolean true\nd-i partman-md\/device_remove_md boolean true\nd-i partman-auto\/choose_recipe select atomic\nd-i partman-partitioning\/confirm_write_new_label boolean true\nd-i partman\/choose_partition select finish\nd-i partman-lvm\/confirm boolean true\nd-i partman-lvm\/confirm_nooverwrite boolean true\nd-i partman\/confirm boolean true\nd-i partman\/confirm_nooverwrite boolean true\n \nd-i debian-installer\/allow_unauthenticated boolean true\n \ntasksel tasksel\/first multiselect minimal\nd-i pkgsel\/update-policy select none\nd-i pkgsel\/include string openssh-server\nd-i pkgsel\/upgrade select none\n \npopularity-contest popularity-contest\/participate boolean false\n \nd-i grub-installer\/only_debian boolean true\nd-i grub-installer\/bootdev string default\nd-i finish-install\/reboot_in_progress note\nd-i debian-installer\/exit\/reboot boolean true\nd-i preseed\/late_command string\t\\\nsed -ri 's\/^#?PermitRootLogin.*\/PermitRootLogin yes\/g' \/target\/etc\/ssh\/sshd_config; \\\nsed -ri 's\/^#?PasswordAuthentication.*\/PasswordAuthentication yes\/g' \/target\/etc\/ssh\/sshd_config;\nEOF\n \n[[ \"$setNet\" == '0' ]] &amp;&amp; [[ \"$AutoNet\" == '1' ]] &amp;&amp; {\n  sed -i '\/netcfg\\\/disable_autoconfig\/d' \/boot\/tmp\/preseed.cfg\n  sed -i '\/netcfg\\\/dhcp_options\/d' \/boot\/tmp\/preseed.cfg\n  sed -i '\/netcfg\\\/get_.*\/d' \/boot\/tmp\/preseed.cfg\n  sed -i '\/netcfg\\\/confirm_static\/d' \/boot\/tmp\/preseed.cfg\n}\n \n[[ \"$DIST\" == 'trusty' ]] &amp;&amp; GRUBPATCH='1'\n[[ \"$DIST\" == 'wily' ]] &amp;&amp; GRUBPATCH='1'\n \n[[ \"$GRUBPATCH\" == '1' ]] &amp;&amp; {\n  sed -i 's\/^d-i\\ grub-installer\\\/bootdev\\ string\\ default\/\/g' \/boot\/tmp\/preseed.cfg\n}\n[[ \"$GRUBPATCH\" == '0' ]] &amp;&amp; {\n  sed -i 's\/debconf-set\\ grub-installer\\\/bootdev.*\\\"\\;\/\/g' \/boot\/tmp\/preseed.cfg\n}\n[[ \"$DIST\" == 'xenial' ]] &amp;&amp; {\n  sed -i 's\/^d-i\\ clock-setup\\\/ntp\\ boolean\\ true\/d-i\\ clock-setup\\\/ntp\\ boolean\\ false\/g' \/boot\/tmp\/preseed.cfg\n}\n \n[[ \"$linuxdists\" == 'debian' ]] &amp;&amp; {\n  sed -i '\/user-setup\\\/allow-password-weak\/d' \/boot\/tmp\/preseed.cfg\n  sed -i '\/user-setup\\\/encrypt-home\/d' \/boot\/tmp\/preseed.cfg\n  sed -i '\/pkgsel\\\/update-policy\/d' \/boot\/tmp\/preseed.cfg\n  sed -i 's\/umount\\ \\\/media.*true\\;\\ \/\/g' \/boot\/tmp\/preseed.cfg\n}\n \n[[ \"$ddMode\" == '1' ]] &amp;&amp; {\nWinDHCP(){\n  echo -ne \"@ECHO OFF\\r\\ncd\\040\\057d\\040\\042\\045ProgramData\\045\\057Microsoft\\057Windows\\057Start\\040Menu\\057Programs\\057Startup\\042\\r\\ndel\\040\\057f\\040\\057q\\040net\\056bat\\r\\n\\r\\n\" &gt;'\/boot\/tmp\/net.tmp';\n}\nWinNoDHCP(){\n  echo -ne \"@ECHO OFF\\r\\ncd\\056\\076\\045windir\\045\\GetAdmin\\r\\nif\\040exist\\040\\045windir\\045\\GetAdmin\\040\\050del\\040\\057f\\040\\057q\\040\\042\\045windir\\045\\GetAdmin\\042\\051\\040else\\040\\050\\r\\necho\\040CreateObject^\\050\\042Shell\\056Application\\042^\\051\\056ShellExecute\\040\\042\\045~s0\\042\\054\\040\\042\\045\\052\\042\\054\\040\\042\\042\\054\\040\\042runas\\042\\054\\040\\061\\040\\076\\076\\040\\042\\045temp\\045\\Admin\\056vbs\\042\\r\\n\\042\\045temp\\045\\Admin\\056vbs\\042\\r\\ndel\\040\\057f\\040\\057q\\040\\042\\045temp\\045\\Admin\\056vbs\\042\\r\\nexit\\040\\057b\\040\\062\\051\\r\\nfor\\040\\057f\\040\\042tokens=\\063\\052\\042\\040\\045\\045i\\040in\\040\\050\\047netsh\\040interface\\040show\\040interface\\040^|more\\040+3\\040^|findstr\\040\\057R\\040\\042\\u672c\\u5730\\056\\052\\040\\u4ee5\\u592a\\056\\052\\040Local\\056\\052\\040Ethernet\\042\\047\\051\\040do\\040\\050set\\040EthName=\\045\\045j\\051\\r\\nnetsh\\040-c\\040interface\\040ip\\040set\\040address\\040name=\\042\\045EthName\\045\\042\\040source=static\\040address=$IPv4\\040mask=$MASK\\040gateway=$GATE\\r\\nnetsh\\040-c\\040interface\\040ip\\040add\\040dnsservers\\040name=\\042\\045EthName\\045\\042\\040address=\\070\\056\\070\\056\\070\\056\\070\\040index=1\\040validate=no\\r\\nnetsh\\040-c\\040interface\\040ip\\040add\\040dnsservers\\040name=\\042\\045EthName\\045\\042\\040address=\\070\\056\\070\\056\\064\\056\\064\\040index=2\\040validate=no\\r\\ncd\\040\\057d\\040\\042\\045ProgramData\\045\\057Microsoft\\057Windows\\057Start\\040Menu\\057Programs\\057Startup\\042\\r\\ndel\\040\\057f\\040\\057q\\040net\\056bat\\r\\n\\r\\n\" &gt;'\/boot\/tmp\/net.tmp';\n}\n  [[ \"$setNet\" == '1' ]] &amp;&amp; WinNoDHCP;\n  [[ \"$setNet\" == '0' ]] &amp;&amp; {\n    [[ \"$AutoNet\" -eq '1' ]] &amp;&amp; WinDHCP;\n    [[ \"$AutoNet\" -eq '0' ]] &amp;&amp; WinNoDHCP;\n  }\n  iconv -f 'UTF-8' -t 'GBK' '\/boot\/tmp\/net.tmp' -o '\/boot\/tmp\/net.bat'\n  rm -rf '\/boot\/tmp\/net.tmp'\n  echo \"$DDURL\" |grep -q '^https:\/\/'\n  [[ $? -eq '0' ]] &amp;&amp; {\n    echo -ne '\\nAdd ssl support...\\n'\n    [[ -n $SSL_SUPPORT ]] &amp;&amp; {\n      wget --no-check-certificate -qO- \"$SSL_SUPPORT\" |tar -x\n      [[ ! -f  \/boot\/tmp\/usr\/bin\/wget ]] &amp;&amp; echo 'Error! SSL_SUPPORT.' &amp;&amp; exit 1;\n      sed -i 's\/wget\\ -qO-\/\\\/usr\\\/bin\\\/wget\\ --no-check-certificate\\ --retry-connrefused\\ --tries=7\\ --continue\\ -qO-\/g' \/boot\/tmp\/preseed.cfg\n      [[ $? -eq '0' ]] &amp;&amp; echo -ne 'Success! \\n\\n'\n    } || {\n    echo -ne 'Not ssl support package! \\n\\n';\n    exit 1;\n    }\n  }\n}\n \n[[ \"$ddMode\" == '0' ]] &amp;&amp; {\n  sed -i '\/anna-install\/d' \/boot\/tmp\/preseed.cfg\n  sed -i 's\/wget.*\\\/sbin\\\/reboot\\;\\ \/\/g' \/boot\/tmp\/preseed.cfg\n}\n[[ \"$INCFW\" == '1' ]] &amp;&amp; [[ \"$linuxdists\" == 'debian' ]] &amp;&amp; [[ -f '\/boot\/firmware.cpio.gz' ]] &amp;&amp; {\n  gzip -d &lt; ..\/firmware.cpio.gz | cpio --extract --verbose --make-directories --no-absolute-filenames &gt;&gt;\/dev\/null 2&gt;&amp;1\n}\nrm -rf ..\/initrd.gz;\nfind . | cpio -H newc --create --verbose | gzip -9 &gt; ..\/initrd.gz;\nrm -rf \/boot\/tmp;\n}\n \n[[ \"$inVNC\" == 'y' ]] &amp;&amp; {\n  sed -i '$i\\\\n' $GRUBDIR\/$GRUBFILE\n  sed -i '$r \/tmp\/grub.new' $GRUBDIR\/$GRUBFILE\n  echo -e \"\\n\\033[33m\\033[04mIt will reboot! \\nPlease look at VNC! \\nSelect\\033[0m\\033[32m Install OS [$DIST $VER] \\033[33m\\033[4mto install system.\\033[04m\\n\\n\\033[31m\\033[04mThere is some information for you.\\nDO NOT CLOSE THE WINDOW! \\033[0m\\n\"\n  echo -e \"\\033[35mIPv4\\t\\tNETMASK\\t\\tGATEWAY\\033[0m\"\n  echo -e \"\\033[36m\\033[04m$IPv4\\033[0m\\t\\033[36m\\033[04m$MASK\\033[0m\\t\\033[36m\\033[04m$GATE\\033[0m\\n\\n\"\n \n  read -n 1 -p \"Press Enter to reboot...\" INP\n  [[ \"$INP\" != '' ]] &amp;&amp; echo -ne '\\b \\n\\n';\n}\n \nchown root:root $GRUBDIR\/$GRUBFILE\nchmod 444 $GRUBDIR\/$GRUBFILE\n \nsleep 3 &amp;&amp; reboot &gt;\/dev\/null 2&gt;&amp;1<\/code><\/pre>\n<p>&nbsp;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\t\t\t\t\t\t&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"http:\/\/www.zhangyijun.com\/?p=141\">\u9605\u8bfb\u66f4\u591a<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-141","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.zhangyijun.com\/index.php?rest_route=\/wp\/v2\/posts\/141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.zhangyijun.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.zhangyijun.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.zhangyijun.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.zhangyijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=141"}],"version-history":[{"count":0,"href":"http:\/\/www.zhangyijun.com\/index.php?rest_route=\/wp\/v2\/posts\/141\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.zhangyijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.zhangyijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.zhangyijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}