-
Notifications
You must be signed in to change notification settings - Fork 10
/
update-shell-script.sh
executable file
·51 lines (45 loc) · 1.07 KB
/
update-shell-script.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
BASE_FILENAME='wordpress-cli-installer'
SHELL_SCRIPT="${BASE_FILENAME}.sh"
PHP_SCRIPT="${BASE_FILENAME}.php"
PHP_OPTIONS=''
cat > $SHELL_SCRIPT <<- "EOF"
#!/bin/bash
#THIS FILE IS AUTOGENERATED, DO NOT EDIT IT
#EDIT ${PHP_SCRIPT}, THEN RUN $(basename $0) TO MAKE CHANGES
# manually specify the path to the PHP interpreter
# with the environmental variable PHP_BIN
if [ -n "$PHP_BIN" ]; then
PHP="$PHP_BIN"
elif [ -x /usr/bin/php-cli ]; then
PHP=/usr/bin/php-cli
elif [ -x /usr/bin/php ]; then
PHP=/usr/bin/php
else
echo "No suitable PHP interpreter found"
exit 129
fi
read -r -d '' PHP_SCRIPT <<'EOF'
EOF
php -w $PHP_SCRIPT >> $SHELL_SCRIPT
echo >> $SHELL_SCRIPT
echo 'EOF' >> $SHELL_SCRIPT
cat >> $SHELL_SCRIPT <<EOF
\$PHP -f <(printf "%s" "\$PHP_SCRIPT") $PHP_OPTIONS -- "\$@"
if [ \$? -eq 128 ]; then
#everything green
exit 0
elif [ \$? -eq 255 ]; then
#PHP internal error
exit 1
elif [ \$? -gt 128 ]; then
#wpi script error
exit 2
elif [ \$? -eq 0 ]; then
#error from wp_install
exit 3
else
#dunno
exit 4
fi
EOF