Update odoo exemple

This commit is contained in:
Thomas Di Grégorio 2018-07-03 00:11:18 +02:00
parent de1cf96a45
commit fabb36eaa1
4 changed files with 45 additions and 70 deletions

View File

@ -24,7 +24,7 @@
# write tour default options here
source easyoptions || exit
verbose() { [[ -n "" ]] && echo /home/dig/bin/.taskrc; }
verbose() { [[ -n "$verbose" ]] && echo $1; }
##### YOUR CODE HERE #####
name=${arguments[1]}
@ -34,7 +34,7 @@ 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]}""
verbose "No .url file, try given url: ${arguments[1]}"
name=${arguments[2]}
wget -O $name.zip ${arguments[1]}
fi

View File

@ -15,67 +15,30 @@
##
## -h, --help Show this help.
## -v, --verbose Show sub-task resolution and options parsed.
## --in=INSTANCE Name the docker odoo instance to copy in.
## --in=INSTANCE Name the docker odoo instance to copy in, otherwise /odoo alias is used.
##
## Exemples:
## install web_responsive
## install theme_backent_v11 --in manage
## install theme_backent_v11
##
# wirte tour default options here
in="odoo-test"
# write your default options here
source easyoptions || exit
verbose() { [[ -n "" ]] && echo /home/dig/bin/.taskrc; }
verbose() { [[ -n "$verbose" ]] && echo $1; }
##### YOUR CODE HERE #####
sudo cp -r $1 /opt/docker/$in/addons/
verbose "Copied \'$1\' in folder: /opt/docker/$in/addons/"
path="/odoo/addons/"
[[ -n "$in" ]] && path="/opt/docker/$in/addons/"
##### 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)"
# Calls command (1rt argument) as script or function $1( $2 $3 ... )
if [ -r "$__dirtask/$1" ]
verbose "Command file exists call it: $__dirtask/$1 ${*:2}"
$__dirtask/$1 ${*:2}
if [ -f $1.package ]
then
for package in $(cat $1.package)
do
sudo cp -r $package $path
verbose "Copied '$package' in folder: $path"
done
else
if [ -n "$(type -t $1)" ] && [ "$(type -t $1)" = function ];
then
verbose "$__dirtask/$1 not exists try func: $1 ${*:2}"
$1 "${*:2}"
fi
verbose "No $1.package file found!"
fi

View File

@ -12,8 +12,10 @@
## ( 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.
## -m, --module Search a module (default) on odoo.com website.
## -t, --theme Search a theme on odoo.com website.
## -n, --no-deps Download without dependencies.
##
## Exemples:
## task odoo search web_responsive
@ -30,18 +32,25 @@ source easyoptions || exit
[[ -n "$module" ]] && type=module
[[ -n "$theme" ]] && type=theme
echo "Search for a $type at adoo.com"
type="$1"
name="$2"
url="https://www.odoo.com/apps/${type}s/11.0/${name}"
echo "Search for a $type at odoo.com"
name="${arguments[0]}"
url="https://www.odoo.com/apps/${type}s/11.0/${name}/"
echo "Try $url"
wget -O $name.html $url
if [ -s $name.html ]
then
grep -o "https://apps.odoo.com/loempia/download/.*?deps" $name.html | sed 's/?deps//g' > $name.url
wget -O $name.zip "$(cat $name.url)"
if [ -n "$no_deps" ]
then
grep -o "https://apps.odoo.com/loempia/download/.*?deps" $name.html | sed 's/?deps//g' > $name.url
else
grep -o "https://apps.odoo.com/loempia/download/.*?deps" $name.html > $name.url
fi
wget -O $name.zip "$(cat $name.url)"
unzip -l $name.zip "*/__init__.py" -x "*/*/*" | grep -o "[A-Z1-9a-z_]*/" | sed 's|/||' > $name.package
unzip $name.zip
else
echo "Not found any $type"

View File

@ -23,6 +23,7 @@
## -t, --theme Search a theme on odoo.com website.
## -z, --unzip Unzip the downloaded package.
## --in=VALUE Defines the docker dir of odoo addons to install the package in.
## -n, --no-deps Download without dependencies.
##
## Exemples:
## task odoo search web_responsive
@ -36,8 +37,7 @@
## task odoo help COMMAND
##
# write tour default options here
module=yes
# write your default options here
source easyoptions || exit
verbose() { [[ -n "$verbose" ]] && echo $1; }
@ -57,18 +57,21 @@ dl()
}
################################################################################
__dirname="$(dirname $0)"
__dirtask="$__dirname/.$(basename $0)"
__taskargs=$(echo "${@:1}" | sed "s/${arguments[0]} //")
# Calls command (1rt argument) as script or function \$1( \$2 \$3 ... )
if [ -r "$__dirtask/$1" ]
verbose "Command file exists call it: $__dirtask/$1 ${*:2}"
$__dirtask/$1 ${*:2}
# Calls command (1rt argument) as script or function $1( $2 $3 ... )
if [ -r "$__dirtask/${arguments[0]}" ]
then
verbose "Command file exists call it: $__dirtask/${arguments[0]} $__taskargs"
$__dirtask/${arguments[0]} $__taskargs
else
if [ -n "$(type -t $1)" ] && [ "$(type -t $1)" = function ];
if [ -n "$(type -t ${arguments[0]})" ] && [ "$(type -t ${arguments[0]})" = function ];
then
verbose "$__dirtask/$1 not exists try func: $1 ${*:2}"
$1 "${*:2}"
verbose "$__dirtask/${arguments[0]} do not exists, trying function: ${arguments[0]} $__taskargs"
${arguments[0]} $__taskargs
fi
fi