add functions cmd_exists qshell_setup qshell_upload
This commit is contained in:
parent
96c161f12d
commit
6cf86809c7
@ -129,11 +129,25 @@ function swap() {
|
|||||||
function init_db() {
|
function init_db() {
|
||||||
dc exec $1 rails db:drop db:create db:migrate db:seed
|
dc exec $1 rails db:drop db:create db:migrate db:seed
|
||||||
}
|
}
|
||||||
|
function cmd_exists() {
|
||||||
function qiniu_uploader() {
|
cmd=$1
|
||||||
bucket=''
|
$cmd &> /dev/null;
|
||||||
filepath=''
|
if [[ $? == 0 ]]; then
|
||||||
while getopts "b:f:" o; do
|
echo Y
|
||||||
|
else
|
||||||
|
echo N
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
function qshell_setup() {
|
||||||
|
if [[ $(cmd_exists qshell) == 'N' ]]; then
|
||||||
|
curl https://raw.githubusercontent.com/paiyou-network/scripts/master/install-qshell.sh | bash
|
||||||
|
fi
|
||||||
|
~/Projects/paiyou-hub/bin/setup-qshell-account.sh
|
||||||
|
}
|
||||||
|
function qshell_upload() {
|
||||||
|
qshell_setup
|
||||||
|
bucket=assets
|
||||||
|
while getopts "b:f:k:t" o; do
|
||||||
case "${o}" in
|
case "${o}" in
|
||||||
b)
|
b)
|
||||||
bucket=${OPTARG}
|
bucket=${OPTARG}
|
||||||
@ -141,13 +155,25 @@ function qiniu_uploader() {
|
|||||||
f)
|
f)
|
||||||
filepath=${OPTARG}
|
filepath=${OPTARG}
|
||||||
;;
|
;;
|
||||||
|
k)
|
||||||
|
key=${OPTARG}
|
||||||
|
;;
|
||||||
|
t)
|
||||||
|
timestamp=true
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: -b BUCKET -f FILEPATH"
|
echo "Usage: qshell_upload [-b BUCKET] -f FILEPATH [-k KEY] [-t]"
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
ruby ~/Projects/paiyou-hub/bin/qiniu_uploader.rb -b $bucket -f $filepath
|
if [[ $key == '' ]]; then
|
||||||
|
key=$(basename $filepath)
|
||||||
|
fi
|
||||||
|
if [[ $timestamp == 'true' ]];then
|
||||||
|
key=`date +%Y%m%dT%H%M%S`_${key}
|
||||||
|
fi
|
||||||
|
qshell rput $bucket $key $filepath
|
||||||
}
|
}
|
||||||
|
|
||||||
function gitcopy() {
|
function gitcopy() {
|
||||||
|
Loading…
Reference in New Issue
Block a user