Commit ea8af73c authored by Medicean's avatar Medicean

(Enhance: Core/CMDLINUX) upload file 不再只依赖xxd

parent 403b4636
...@@ -6,16 +6,16 @@ ...@@ -6,16 +6,16 @@
module.exports = () => ({ module.exports = () => ({
info: { info: {
_: `ACWD=$(pwd); _: `ACWD=$(pwd);
AUNAME=$(uname -a); AUNAME=$(uname -a);
AUSER=$(whoami); AUSER=$(whoami);
echo -n "$ACWD\\t/\\t$AUNAME\\t$AUSER";` echo -n "$ACWD\\t/\\t$AUNAME\\t$AUSER";`
}, },
probedb: { // 检测数据库函数支持 probedb: { // 检测数据库函数支持
_: `command_exists() { command -v "$@" > /dev/null 2>&1; }; _: `command_exists() { command -v "$@" > /dev/null 2>&1; };
DBLIST="mysql psql sqlite3"; DBLIST="mysql psql sqlite3";
for v in $DBLIST for v in $DBLIST
do do
if command_exists $v; then echo "$v\\t1"; else echo "$v\\t0"; fi; if command_exists $v; then echo "$v\\t1"; else echo "$v\\t0"; fi;
done;` done;`
} }
}) })
\ No newline at end of file
...@@ -31,7 +31,17 @@ if [ $? = 0 ]; then echo -n 1; else echo -n 0; fi;` ...@@ -31,7 +31,17 @@ if [ $? = 0 ]; then echo -n 1; else echo -n 0; fi;`
}, },
upload_file: { upload_file: {
_: `echo #{buffer::content}|xxd -r -p >> #{path} && echo -n 1||echo -n 0;` _: `command_exists() { command -v "$@" > /dev/null 2>&1; };
ACONTENT="#{buffer::content}";
ADSTPATH="#{path}";
if command_exists xxd; then
echo -n $ACONTENT|xxd -r -p >> $ADSTPATH && echo -n 1||echo -n 0;
elif command_exists python3; then
echo -n $ACONTENT|python3 -c "import sys, binascii; sys.stdout.buffer.write(binascii.unhexlify(input().strip()))">>$ADSTPATH && echo -n 1||echo -n 0;
else
echo -n $ACONTENT|sed 's/\\([0-9A-F]\\{2\}\\)/\\\\\\\\\\\\x\\1/gI'|xargs printf>>$ADSTPATH && echo -n 1||echo -n 0;
fi;
`
}, },
rename: { rename: {
...@@ -52,15 +62,15 @@ if [ $? = 0 ]; then echo -n 1; else echo -n 0; fi;` ...@@ -52,15 +62,15 @@ if [ $? = 0 ]; then echo -n 1; else echo -n 0; fi;`
wget: { wget: {
_: `command_exists() { command -v "$@" > /dev/null 2>&1; }; _: `command_exists() { command -v "$@" > /dev/null 2>&1; };
ascurl='' ascurl=''
if command_exists curl; then if command_exists curl; then
ascurl='curl -ksSL -o'; ascurl='curl -ksSL -o';
elif command_exists wget; then elif command_exists wget; then
ascurl='wget --no-check-certificate -qO'; ascurl='wget --no-check-certificate -qO';
elif command_exists busybox && busybox --list-modules | grep -q wget; then elif command_exists busybox && busybox --list-modules | grep -q wget; then
ascurl='busybox wget --no-check-certificate -qO' ascurl='busybox wget --no-check-certificate -qO'
fi; fi;
$ascurl #{path} #{url} && echo -n 1||echo -n 0; $ascurl #{path} #{url} && echo -n 1||echo -n 0;
` `
} }
}) })
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment