Skip to content

Instantly share code, notes, and snippets.

@geopelia
Last active November 22, 2016 02:32
Show Gist options
  • Save geopelia/1b05d43d69dfbf84141ce349992e4259 to your computer and use it in GitHub Desktop.
Save geopelia/1b05d43d69dfbf84141ce349992e4259 to your computer and use it in GitHub Desktop.
Lista proyectos que están en determinadas rutas y ejecuta una acción determinada
#!/bin/bash
path=/home/pi
action=$1
num_folder=$2
project_sufix="/scm/Deploy_EAR/wee"
is_folder_exist() {
[[ -d $1 ]] && return 0 || return 1
}
deploy_file() {
location="$path/$1"
if (is_folder_exist $location ) then
deploy_path="$location$project_sufix"
if (is_folder_exist $deploy_path) then
cd $deploy_path
./scripts.sh
else
echo "Ruta Invalida de despliege"
fi
else
echo "Ruta Invalida"
fi
}
case $action in
-l) ls $path | awk 'BEGIN{count = 0}
{count++; print count," -> ", $1}'
;;
-n) if [[ $num_folder -gt 0 ]]; then
folder_name=$(ls $path | awk 'NR==line' line=$num_flder)
deploy_file $folder_name
else
echo "Opcion no valida"
fi
;;
*) if [[ $action != '' ]]; then
deploy_file $action
else
echo "Otra accion"
fi
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment