{"id":2865,"date":"2016-11-28T00:24:30","date_gmt":"2016-11-27T16:24:30","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=2865"},"modified":"2016-11-28T00:24:30","modified_gmt":"2016-11-27T16:24:30","slug":"%e5%9c%a8shell%e8%84%9a%e6%9c%ac%e4%b8%ad%e5%b5%8c%e5%85%a5%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/2865.html","title":{"rendered":"\u5728shell\u811a\u672c\u4e2d\u5d4c\u5165\u6587\u4ef6"},"content":{"rendered":"<p>=Start=<\/p>\n<h5>\u7f18\u7531\uff1a<\/h5>\n<p>\u4e4b\u524d\u6709\u78b0\u5230\u8fc7\u5c06\u6587\u4ef6\u5d4c\u5165shell\u811a\u672c\u7684\u60c5\u51b5\uff0c\u4f46\u6ca1\u6709\u7ec6\u7a76\uff0c\u6700\u8fd1\u770b\u5230<a href=\"https:\/\/www.52os.net\/articles\/embedding-files-into-shell-scripts.html\">\u4e00\u7bc7\u6587\u7ae0<\/a>\u7684\u65f6\u5019\u60f3\u8d77\u6765\u4e86\uff0c\u5c31\u987a\u7740\u5b66\u4e60\u4e00\u4e0b\uff0c\u8bf4\u4e0d\u5b9a\u4ee5\u540e\u7528\u5f97\u7740\u3002<\/p>\n<h5>\u53c2\u8003\u89e3\u7b54\uff1a<\/h5>\n<pre class=\"lang:default decode:true \">#!\/bin\/bash\n\nPATH=\/usr\/bin:\/bin\numask 022\nmd5=0ee8c59a12d99fdfd1e95bfda6938e86\n\npre_install()\n{\n    echo \"\u51c6\u5907\u5b89\u88c5\u73af\u5883\uff08\u7565\uff09...\"\n    mkdir .\/install.tmp.$$\n}\nextract()\n{\n    echo \"\u4ece\u811a\u672c\u4e2d\u63d0\u53d6\u6587\u4ef6\"\n    line_number=`awk '\/^__BIN_FILE_BEGIN__\/ {print NR + 1; exit 0; }' \"$0\"`\n    tail -n +$line_number \"$0\" &gt;.\/install.tmp.$$\/extract.$$\n    # tail -n +$line_number \"$0\" &gt;.\/install.tmp.$$\/extract_tmp.$$\n    # base64 -d .\/install.tmp.$$\/extract_tmp.$$ &gt;.\/install.tmp.$$\/extract.$$\n}\ncheck_sum()\n{\n    if [ -x \/usr\/bin\/md5sum ] &amp;&amp; [ -f \"install.tmp.$$\/extract.$$\" ]; then\n        echo \"\u6b63\u5728\u68c0\u67e5md5......\"\n        sum_tmp=($(\/usr\/bin\/md5sum install.tmp.$$\/extract.$$))\n        if [ $sum_tmp != $md5 ]; then\n            echo \"\u6587\u4ef6md5\u4e0d\u4e00\u81f4\uff0c\u8bf7\u68c0\u67e5\u6587\u4ef6\u5b8c\u6574\u6027,\u9000\u51fa!\"\n            exit 1\n        fi\n    else\n        echo \"\u627e\u4e0d\u5230md5sum\u547d\u4ee4\u6216\u6587\u4ef6\u672a\u63d0\u53d6,\u9000\u51fa\"\n        exit 1\n    fi\n}\ninstall()\n{\n    echo \"\u5b89\u88c5\u4e2d\uff08\u7565\uff09...\"\n}\npost_install()\n{\n    echo \"\u914d\u7f6e\u4e2d(\u7565)...\"\n    echo \"\u6e05\u7406\u4e34\u65f6\u6587\u4ef6\"\n    rm -rf install.tmp.$$\n}\n\nmain()\n{\n    pre_install\n    extract\n    check_sum\n    install\n    post_install\n    exit 0\n}\n\nmain\n\n__BIN_FILE_BEGIN__  #\u8fd9\u884c\u4e0b\u9762\u63a5\u4e8c\u8fdb\u5236\u6587\u4ef6\n# ......<\/pre>\n<h5>\u53c2\u8003\u94fe\u63a5\uff1a<\/h5>\n<ul>\n<li><a href=\"https:\/\/www.52os.net\/articles\/embedding-files-into-shell-scripts.html\">\u5728shell\u811a\u672c\u4e2d\u5d4c\u5165\u6587\u4ef6<\/a><\/li>\n<li><a href=\"http:\/\/www.oenhan.com\/shell-pack-bin\">\u5728shell\u4e2d\u5d4c\u5165\u4e8c\u8fdb\u5236\u6587\u4ef6<\/a> #\u8be6\u7ec6<\/li>\n<li><a href=\"http:\/\/blog.chinaunix.net\/uid-10540984-id-3262931.html\">shell\u811a\u672c\u4e2d\u5d4c\u5165\u4e8c\u8fdb\u5236\u6587\u4ef6<\/a><\/li>\n<li><a href=\"http:\/\/blog.csdn.net\/ace_fei\/article\/details\/6416730\">[\u603b\u7ed3]\u5982\u4f55\u7f16\u5199\u81ea\u89e3\u538b\u811a\u672c\uff08\u811a\u672c\u4e2d\u5d4c\u5165\u4e8c\u8fdb\u5236\u6587\u4ef6\uff09<\/a><\/li>\n<li>\u53e6\uff1a<a href=\"http:\/\/www.yunweipai.com\/archives\/5985.html\">\u5982\u4f55\u5728PowerShell\u811a\u672c\u4e2d\u5d4c\u5165EXE\u6587\u4ef6?<\/a><\/li>\n<\/ul>\n<p>=END=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=Start= \u7f18\u7531\uff1a \u4e4b\u524d\u6709\u78b0\u5230\u8fc7\u5c06\u6587\u4ef6\u5d4c\u5165shell\u811a\u672c\u7684\u60c5\u51b5\uff0c\u4f46\u6ca1\u6709\u7ec6\u7a76\uff0c\u6700\u8fd1\u770b\u5230\u4e00\u7bc7\u6587\u7ae0\u7684\u65f6\u5019\u60f3\u8d77\u6765\u4e86 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11,7,12],"tags":[65,19],"class_list":["post-2865","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","category-programing","category-tools","tag-shell","tag-tips"],"views":3932,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2865","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=2865"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2865\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=2865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=2865"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=2865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}