commit 6771363c7b44d3adc6e68aad3960ad17d18e65d9 Author: Valentin Lab Date: Tue Dec 10 17:22:51 2019 +0100 First import diff --git a/README.org b/README.org new file mode 100644 index 0000000..c65b1aa --- /dev/null +++ b/README.org @@ -0,0 +1,88 @@ +#+PROPERTY: Effort_ALL 0 0:30 1:00 2:00 0.5d 1d 1.5d 2d 3d 4d 5d +#+PROPERTY: Max_effort_ALL 0 0:30 1:00 2:00 0.5d 1d 1.5d 2d 3d 4d 5d +#+PROPERTY: header-args:python :var filename=(buffer-file-name) +#+PROPERTY: header-args:sh :var filename=(buffer-file-name) +#+TODO: TODO WIP BLOCKED | DONE CANCELED +#+LATEX_HEADER: \usepackage[margin=0.5in]{geometry} +#+LaTeX_CLASS: article +#+OPTIONS: H:8 ^:nil prop:("Effort" "Max_effort") tags:not-in-toc +#+COLUMNS: %50ITEM %Effort(Min Effort) %Max_effort(Max Effort) + +#+BEGIN_LaTeX +\hypersetup{ + linkcolor=blue, + pdfborder={0 0 0 0} +} +#+END_LaTeX + + +#+TITLE: Lokavaluto Dev Pack + +#+LATEX: \pagebreak + +Resources (docs, tools) to help getting things done in the lokavaluto team + +#+LATEX: \pagebreak + +#+LATEX: \pagebreak + +* Common dev environment + +We recommend you to try to stick to a somewhat common environment to +avoid as much as possible any problem stemming for your installation. + +The most important part is the usage of the same docker image of odoo +and the same version of postgres. Here are suggestion of how to +install it. + +** Installation + +*** Linux + +We are using `compose` + +**** Requirements + + - =bash= >= 4.3 + - =docker= >= 17.06 + - =curl= ## for installation + - =git= + +**** Deployment + +We have a magic script for you that will install or update your +current installation of =compose= and of the =charms=. + +#+BEGIN_SRC shell +curl -sS https://git.myceliandre.fr/Lokavaluto/dev-pack/raw/branch/dev/src/install.sh | bash +#+END_SRC + +If you are curious of what it is doing, check: + +https://git.myceliandre.fr/Lokavaluto/dev-pack/src/branch/dev/src/install.sh#L203-L258 + + +*** MacOSX + +**** Requirements + +On MacOSX, you'll need to install homebrew and gnu tools: + +https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/ + + +**** Deployment + +TBD + +*** Windows + +**** Requirements + + - =bash= >= 4.3 + - =docker= >= 17.06 + - =docker-compose= + +**** Deployment + +TBD diff --git a/src/install.sh b/src/install.sh new file mode 100644 index 0000000..f4e77d0 --- /dev/null +++ b/src/install.sh @@ -0,0 +1,324 @@ +#!/bin/bash + +e() { printf "%s" "$*"; } + +warn() { e "${YELLOW}Warning:$NORMAL" "$*"$'\n' >&2 ; } +info() { e "${BLUE}II$NORMAL" "$*"$'\n' >&2 ; } +verb() { [ -z "$VERBOSE" ] || e "$*"$'\n' >&2; } +debug() { [ -z "$DEBUG" ] || e "$*"$'\n' >&2; } +err() { e "${RED}Error:$NORMAL $*"$'\n' >&2 ; } +die() { err "$@" ; exit 1; } + + +get_path() { ( + IFS=: + for d in $PATH; do + filename="$d/$1" + [ -f "$filename" -a -x "$filename" ] && { + echo "$d/$1" + return 0 + } + done + return 1 +) } + +ANSI_ESC=$'\e[' + +ansi_color() { + local choice="$1" + + if [ "$choice" == "tty" ]; then + if [ -t 1 ]; then + choice="yes" + else + choice="no" + fi + fi + + if [ "$choice" != "no" ]; then + + SET_COL_CHAR="${ANSI_ESC}${COL_CHAR}G" + SET_COL_STATUS="${ANSI_ESC}${COL_STATUS}G" + SET_COL_INFO="${ANSI_ESC}${COL_INFO}G" + SET_COL_ELT="${ANSI_ESC}${COL_ELT}G" + + SET_BEGINCOL="${ANSI_ESC}0G" + + UP="${ANSI_ESC}1A" + DOWN="${ANSI_ESC}1B" + LEFT="${ANSI_ESC}1D" + RIGHT="${ANSI_ESC}1C" + + SAVE="${ANSI_ESC}7" + RESTORE="${ANSI_ESC}8" + + NORMAL="${ANSI_ESC}0m" + + GRAY="${ANSI_ESC}1;30m" + RED="${ANSI_ESC}1;31m" + GREEN="${ANSI_ESC}1;32m" + YELLOW="${ANSI_ESC}1;33m" + BLUE="${ANSI_ESC}1;34m" + PINK="${ANSI_ESC}1;35m" + CYAN="${ANSI_ESC}1;36m" + WHITE="${ANSI_ESC}1;37m" + + DARKGRAY="${ANSI_ESC}0;30m" + DARKRED="${ANSI_ESC}0;31m" + DARKGREEN="${ANSI_ESC}0;32m" + DARKYELLOW="${ANSI_ESC}0;33m" + DARKBLUE="${ANSI_ESC}0;34m" + DARKPINK="${ANSI_ESC}0;35m" + DARKCYAN="${ANSI_ESC}0;36m" + DARKWHITE="${ANSI_ESC}0;37m" + + SUCCESS=$GREEN + WARNING=$YELLOW + FAILURE=$RED + NOOP=$BLUE + ON=$SUCCESS + OFF=$FAILURE + ERROR=$FAILURE + + else + + SET_COL_CHAR= + SET_COL_STATUS= + SET_COL_INFO= + SET_COL_ELT= + + SET_BEGINCOL= + + NORMAL= + RED= + GREEN= + YELLOW= + BLUE= + GRAY= + WHITE= + + DARKGRAY= + DARKRED= + DARKGREEN= + DARKYELLOW= + DARKBLUE= + DARKPINK= + DARKCYAN= + + SUCCESS= + WARNING= + FAILURE= + NOOP= + ON= + OFF= + ERROR= + + fi + + ansi_color="$choice" + + export SET_COL_CHAR SET_COL_STATUS SET_COL_INFO SET_COL_ELT \ + SET_BEGINCOL UP DOWN LEFT RIGHT SAVE RESTORE NORMAL \ + GRAY RED GREEN YELLOW BLUE PINK CYAN WHITE DARKGRAY \ + DARKRED DARKGREEN DARKYELLOW DARKBLUE DARKPINK DARKCYAN \ + SUCCESS WARNING FAILURE NOOP ON OFF ERROR ansi_color +} + + +depends() { + ## Avoid colliding with variables that are created with depends. + local __i __path __new_name + + for __i in "$@"; do + if ! __path=$(get_path "$__i"); then + __new_name="$(echo "${__i//-/_}")" + if [ "$__new_name" != "$__i" ]; then + depends "$__new_name" + else + err "dependency check: couldn't find '$__i' required command." + exit 1 + fi + else + if ! test -z "$__path" ; then + export "$(echo "${__i//- /__}")"="$__path" + fi + fi + done +} + +get_os() { + local uname_output + uname_output="$(uname -s)" + case "${uname_output}" in + Linux*) + if [[ "$(< /proc/version)" =~ ^.*@(Microsoft|WSL).*$ ]]; then + e wsl + # elif [[ "$(< /proc/version)" == *@(microsoft|WSL)* ]]; then + # e wsl2 + else + e linux + fi + ;; + Darwin*) e mac;; + CYGWIN*) e cygwin;; + MINGW*) e mingw;; + *) e "UNKNOWN:${uname_output}";; + esac +} + + +OS=$(get_os) || { + err "Couldn't figure what OS you are running." + exit 1 +} + +fn.exists() { declare -F "$1" >/dev/null; } + +## copy stdin to file, archive previous existing file if any +install_file() { + local path="$1" tmpfile + tmpfile="$(mktemp)" + cat > "${tmpfile}" || return 1 + mkdir -vp "${path%/*}" || exit 1 + if [[ -e "$path" ]]; then + if ! diff "${tmpfile}" "${path}";then + info "File '$path' exists but is different, archiving current content and replacing it." + candidate="${path}.bak" + n=1 + while [ -e "$candidate" ]; do + candidate="${path}.bak.$((n++))" + done + echo "Archiving previous version of '$path'" + mv -v "${path}" "$candidate" || return 1 + else + info "File '$path' exists and is already with the right content." + fi + else + echo "Creating '${path}'." + mv "${tmpfile}" "$path" || return 1 + fi + rm -f "$tmpfile" +} + +install.linux() { + depends docker curl git + + if [ "$UID" != 0 ]; then + BIN_PATH=~/bin + CHARM_PATH=~/.charm-store + DEFAULT_COMPOSE_YML=~/.compose/etc/compose.yml + COMPOSE_OPTION_FILE=~/.compose/etc/local.conf + else + BIN_PATH=/usr/local/bin + CHARM_PATH=/srv/charm-store + DEFAULT_COMPOSE_YML=/etc/compose/compose.yml + COMPOSE_OPTION_FILE=/etc/compose/local.conf + fi + + ## COMPOSE + if compose=$(type -p "compose"); then + if [ "$compose" != "$BIN_PATH/compose" ]; then + warn "Found a 'compose' in \$PATH at '$compose' that doesn't match expected compose location '$BIN_PATH/compose'." \ + "Not doing anything." + elif [ -L "$compose" ]; then + warn "Found a 'compose' at '$compose' that is a link. " \ + "Not doing anything." + else + compose="" ## force overwrite + fi + fi + if [ -z "$compose" ]; then + mkdir -p "$BIN_PATH" || exit 1 + info "Downloading 'compose'..." + ( + set +x + curl -sS https://git.0k.io/0k-compose.git/plain/bin/compose > /tmp/compose + chmod -v +x /tmp/compose + mv -v /tmp/compose "$BIN_PATH/" + ) || exit 1 + echo " .. Done !" + fi + + if [[ ":$PATH:" != *":$BIN_PATH:"* ]]; then + warn "Please ensure that '$BIN_PATH' is in your \$PATH to ensure" \ + "the simple usage of 'compose' command." + fi + + ## CHARMS + if ! [ -d "$CHARM_PATH" ]; then + echo "Creating charm-store in '$CHARM_PATH'." + git clone https://git.0k.io/0k-charms.git "$CHARM_PATH" || exit 1 + else + echo "Updating existing charm-store in '$CHARM_PATH'." + cd "$CHARM_PATH" || exit 1 + git checkout master && + git pull -r || { + warn "Could not update charm-store, do you have devs ingoing ?" + } + fi + + ## + ## YYYvlab: following needs to be discussed further with njeudy + ## + + + ## DEFAULT COMPOSE +# cat <&2 + fi +} + +ansi_color tty +run \ No newline at end of file