File tree Expand file tree Collapse file tree 2 files changed +58
-226
lines changed
Expand file tree Collapse file tree 2 files changed +58
-226
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ function download_file() {
4+ downloader=" wget"
5+ type wget > /dev/null 2>&1 || { downloader=" curl" ; }
6+ if [ " $downloader " = " wget" ]; then
7+ _down_prefix=" O"
8+ else
9+ _down_prefix=" o"
10+ fi
11+ _down_symbol=0
12+ if [ ! -f " $2 " ]; then
13+ echo $1
14+ $downloader " $1 " -$_down_prefix " $2 " > /dev/null 2>&1 && \
15+ echo " 完成!" && _down_symbol=1
16+ else
17+ echo " 已存在!" && _down_symbol=1
18+ fi
19+ if [ $_down_symbol == 0 ]; then
20+ echo " 失败!请检查网络连接!"
21+ rm -rf " $2 "
22+ return 1
23+ fi
24+ return 0
25+ }
26+
27+ function test_composer_and_php() {
28+ succ=$( " $( pwd) /runtime/composer" -n about | grep Manage)
29+ if [ " $succ " = " " ]; then
30+ echo " Download PHP binary and composer failed!"
31+ return 1
32+ fi
33+ return 0
34+ }
35+
36+ mkdir " $( pwd) /runtime" > /dev/null 2>&1
37+ if [ ! -f " $( pwd) /runtime/php" ]; then
38+ download_file " https://dl.zhamao.me/php-bin/down.php?php_ver=7.4&arch=$( uname -m) " " $( pwd) /runtime/php.tar.gz"
39+ if [ $? -ne 0 ]; then
40+ exit 1
41+ fi
42+ tar -xf " $( pwd) /runtime/php.tar.gz" -C " $( pwd) /runtime/"
43+ fi
44+ if [ ! -f " $( pwd) /runtime/composer" ]; then
45+ download_file " https://mirrors.aliyun.com/composer/composer.phar" " $( pwd) /runtime/composer.phar"
46+ if [ $? -ne 0 ]; then
47+ exit 1
48+ fi
49+ echo ' $(dirname $0)/php $(dirname $0)/composer.phar $@' > $( pwd) /runtime/composer
50+ chmod +x $( pwd) /runtime/composer
51+ test_composer_and_php
52+ fi
53+ if [ $? -ne 0 ]; then
54+ exit 1
55+ fi
56+ echo " 成功下载!" && \
57+ echo -e " PHP使用:\truntime/php -v" && \
58+ echo -e " Composer使用:\truntime/composer"
You can’t perform that action at this time.
0 commit comments