2018-05-21 20:37:07 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
##
|
|
|
|
## Task download v1.0
|
|
|
|
## Copyright (C) Thomas Di Gregorio
|
|
|
|
## Licensed under MIT
|
|
|
|
##
|
|
|
|
## Downloads an odoo.com page corresponding to the package name given and type.
|
|
|
|
##
|
|
|
|
## Usage:
|
|
|
|
## @script.name [ --theme | --module ] [ --unzip ] PACKAGE
|
|
|
|
##
|
|
|
|
## Options:
|
|
|
|
## ( Long version are mandatory, and can be before or after short version )
|
|
|
|
##
|
|
|
|
## -h, --help Show this help.
|
|
|
|
## -v, --verbose Show sub-task resolution and options parsed.
|
|
|
|
##
|
|
|
|
##
|
|
|
|
## Exemples:
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
# write tour default options here
|
|
|
|
|
|
|
|
source easyoptions || exit
|
|
|
|
verbose() { [[ -n "" ]] && echo /home/dig/bin/.taskrc; }
|
|
|
|
|
|
|
|
##### YOUR CODE HERE #####
|
|
|
|
name=${arguments[1]}
|
|
|
|
|
|
|
|
if [ -r "$PWD/$name.url" ]
|
|
|
|
then
|
|
|
|
verbose "Found a $name.url file containing: $(cat $name.url)"
|
|
|
|
wget -O $name.zip "$(cat $name.url)"
|
|
|
|
else
|
|
|
|
verbose "No .url file, try given url: ${arguments[1]}""
|
|
|
|
name=${arguments[2]}
|
|
|
|
wget -O $name.zip ${arguments[1]}
|
|
|
|
fi
|
|
|
|
[[ -n "$unzip" ]] && unzip $name.zip
|
|
|
|
|
|
|
|
|
|
|
|
##### SNIPPETS ##################################################################
|
|
|
|
|
|
|
|
|
|
|
|
# Boolean and parameter options
|
|
|
|
|
|
|
|
# [[ -n "$option" ]] && echo "Option specified: --option is $option"
|
|
|
|
|
|
|
|
|
|
|
|
# Arguments
|
|
|
|
|
|
|
|
#for argument in "${arguments[@]}"; do
|
|
|
|
# echo "Argument specified: $argument"
|
|
|
|
#done
|
|
|
|
|
|
|
|
|
|
|
|
# Verbose (echo only if -v or --verbose options
|
|
|
|
|
|
|
|
#verbose "I\'m doing things"
|
|
|
|
#mkdir "cant/create/this" || verbose "Error creating folder!"
|
|
|
|
|
|
|
|
# Auto called function acording to 1st agument
|
|
|
|
|
|
|
|
#command()
|
|
|
|
#{
|
|
|
|
# # here get 2nd argument with /home/dig/bin/.taskrc (local 1st arg) or (script)
|
|
|
|
#}
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
__dirname="$(dirname $0)"
|
|
|
|
__dirtask="$__dirname/.$(basename $0)"
|
|
|
|
|
2018-06-29 15:39:12 +02:00
|
|
|
# Calls command (1rt argument) as script or function $1( $2 $3 ... )
|
2018-05-21 20:37:07 +02:00
|
|
|
if [ -r "$__dirtask/$1" ]
|
2018-06-29 15:39:12 +02:00
|
|
|
verbose "Command file exists call it: $__dirtask/$1 ${*:2}"
|
|
|
|
$__dirtask/$1 ${*:2}
|
2018-05-21 20:37:07 +02:00
|
|
|
else
|
|
|
|
if [ -n "$(type -t $1)" ] && [ "$(type -t $1)" = function ];
|
|
|
|
then
|
2018-06-29 15:39:12 +02:00
|
|
|
verbose "$__dirtask/$1 not exists try func: $1 ${*:2}"
|
|
|
|
$1 "${*:2}"
|
2018-05-21 20:37:07 +02:00
|
|
|
fi
|
|
|
|
fi
|