InvenTree/contrib/install.sh

342 lines
7.5 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# This script was generated by bashly 0.8.9 (https://bashly.dannyb.co)
# Modifying it manually is not recommended
# :wrapper.bash3_bouncer
if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
printf "bash version 4 or higher is required\n" >&2
exit 1
fi
# :command.master_script
# :command.root_command
root_command() {
# src/root_command.sh
# Settings
source_url=${args[source]}
publisher=${args[publisher]}
# Flags
no_call=${args[--no-call]}
dry_run=${args[--dry-run]}
REQS="wget apt-transport-https"
function do_call() {
if [[ $dry_run ]]; then
echo -e "### DRY RUN: \n$1"
else
$1
fi
}
function get_distribution {
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
OS=$(lsb_release -si)
VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
. /etc/lsb-release
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then
OS=SEL
elif [ -f /etc/redhat-release ]; then
OS=RedHat
else
OS=$(uname -s)
VER=$(uname -r)
fi
}
echo "### Installer for InvenTree - source: $publisher/$source_url"
# Check if os and version is supported
get_distribution
echo "### Detected distribution: $OS $VER"
NOT_SUPPORTED=false
case "$OS" in
Ubuntu)
if [[ $VER != "20.04" ]]; then
NOT_SUPPORTED=true
fi
;;
Debian | Raspbian)
if [[ $VER != "11" ]]; then
NOT_SUPPORTED=true
fi
;;
*)
echo "### Distribution not supported"
NOT_SUPPORTED=true
;;
esac
if [[ $NOT_SUPPORTED ]]; then
echo "This OS is currently not supported"
echo "please install manually using https://inventree.readthedocs.io/en/stable/start/install/"
echo "or check https://github.com/inventree/InvenTree/issues/3836 for packaging for your OS."
echo "If you think this is a bug please file an issue at"
echo "https://github.com/inventree/InvenTree/issues/new?template=install.yaml"
exit 1
fi
echo "### Installing required packages for download"
for pkg in $REQS; do
if dpkg-query -W -f'${Status}' "$pkg" 2>/dev/null | grep -q "ok installed"; then
true
else
do_call "sudo apt-get -yqq install $pkg"
fi
done
echo "### Adding key and package source"
# Add key
do_call "wget -qO- https://dl.packager.io/srv/$publisher/InvenTree/key | sudo apt-key add -"
# Add packagelist
do_call "sudo wget -O /etc/apt/sources.list.d/inventree.list https://dl.packager.io/srv/$publisher/InvenTree/$source_url/installer/${lsb_dist}/${dist_version}.repo"
echo "### Updateing package lists"
do_call "sudo apt-get update"
# Set up environment for install
echo "### Setting installer args"
if [[ $no_call ]]; then
do_call "export NO_CALL=true"
fi
echo "### Installing InvenTree"
do_call "sudo apt-get install inventree -y"
echo "### Install done!"
Add package-based install method (#3743) * Add runtime * add procfile * add settings for packaging * use heroku buildpack * maybe a hash works? * try brnach instead of tag or hash * remove reference alltogether * maybe this syntax? * switch back to normal buildpack * and heroku again * try official sample * maybe a tar? * just git clone? * lower version * lower version * switch of settings * try this again * maybe install python before? * no sudo? * just build for ubuntu? * set runtime lower and use custom buildpack * remove initial command * add release command * do not collect static while releaseing * switch to custom backend * Update .pkgr.yml * new backend * upgrade runtime version * consolidate env * update python version * add debian as target * fix os name * extend requirements * remove release command * remove ssl dep * add worker command * add scripts * debug listing * make scripts executable * use python3 * add python install * add python as dep * debug step * switch to app home * set paths right * check local command * remove path * update path * add sample install script * more debugging * dbg msg * more enviroment stuff * more dbugging * more defined install script * reduce function * add debug script * and more * remove before * reduce lines * cleanup deps * maybe this way? * rm " * rename env * fix files * use dot annotation * ls * add msgs * move activation * ref? * use source * use point annotation * remove activate * create env and add it to the enviroment * use full paths * move python init * use modern python * use version numbers for ubuntu * add default env vars ( for now) * use export * use shorthand command * add more variables * use apphome reference in paths * add wasyprint dependencies * also use wheels * add gettext for comiling messages * add nginx setting * remove postgres from required stack * refactor fiel configs * make sure parent dirs exsist * add wheels * move python setup again * update packe name * update gunicron command * move to config * try cleaner procfile * use python 3 wheels * update service def * Add enviroment settings to packaging * restart nginx * remove slack * change nginx config name * fix styles * set permissions on update * Add single line install to README * move nginx names back * use production sample as nginx config * fix sed statement * cleaner nginx setup * keep configs in config file instead of packaging index * fix sed connamds to remove spaces * reintroduce spaces * Also disable debug mode * fix file permissions * remove unneeded commands * readd missing spaces * add admin user generation * Show public ipadress in final message * small cleanups * Add log to setup * remove logging * remove logging parts * chown all dirs * run update command as right user already * set path before running command * fix permission setup * switch right assignment * run commands with sudo * pass in envs * preserve only selected enviroment * show enviroment variables * silence curl * fix envs * clean up final message * move nginx file to variable * make admin creation conditional * a bit more overview for setup variables * test if nginx is available * unlink instead of delet * clean up functions * well that was dumb * ok double dumb - now i tested it * use config for admin generation * fix logic * show value - not call it * switch functions to sh * fix syntax * add admin data to exposed envs * remove keeping of admin pwd * switch to true/false * make nginx file location configureable * use gunicorn instead * fix syntax * set base dir * move env to seperate function * Also use/write database settings * use conf values if available * format sh * update passed envs * fix dep * enable installing extra packages via env (ie database backends) * ann more logging steps * add more debuggin steps * get local envs * add more debug and reorder * more code for testing * fix call * Add debug msg * turn install quiet * fix syntax * reduce debugging * add log step * add datestamp * add marker to inv execution * fix syntax * add codeowner
2022-10-15 23:14:18 +00:00
}
# :command.version_command
version_command() {
echo "$version"
}
# :command.usage
install_usage() {
if [[ -n $long_usage ]]; then
printf "install - Interactive installer for InvenTree\n"
echo
else
printf "install - Interactive installer for InvenTree\n"
echo
fi
printf "Usage:\n"
printf " install [SOURCE] [PUBLISHER] [OPTIONS]\n"
printf " install --help | -h\n"
printf " install --version | -v\n"
echo
# :command.long_usage
if [[ -n $long_usage ]]; then
printf "Options:\n"
# :command.usage_fixed_flags
echo " --help, -h"
printf " Show this help\n"
echo
echo " --version, -v"
printf " Show version number\n"
echo
# :command.usage_flags
# :flag.usage
echo " --no-call, -n"
printf " Do not call outside APIs (only functionally needed)\n"
echo
# :flag.usage
echo " --dry-run, -d"
printf " Dry run (do not install anything)\n"
echo
# :command.usage_args
printf "Arguments:\n"
# :argument.usage
echo " SOURCE"
printf " Package source that should be used\n"
printf " Allowed: stable, master, main\n"
printf " Default: stable\n"
echo
# :argument.usage
echo " PUBLISHER"
printf " Publisher that should be used\n"
printf " Default: inventree\n"
echo
# :command.usage_examples
printf "Examples:\n"
printf " install\n"
printf " install master --no-call\n"
printf " install master matmair --dry-run\n"
echo
fi
}
# :command.normalize_input
normalize_input() {
local arg flags
while [[ $# -gt 0 ]]; do
arg="$1"
if [[ $arg =~ ^(--[a-zA-Z0-9_\-]+)=(.+)$ ]]; then
input+=("${BASH_REMATCH[1]}")
input+=("${BASH_REMATCH[2]}")
elif [[ $arg =~ ^(-[a-zA-Z0-9])=(.+)$ ]]; then
input+=("${BASH_REMATCH[1]}")
input+=("${BASH_REMATCH[2]}")
elif [[ $arg =~ ^-([a-zA-Z0-9][a-zA-Z0-9]+)$ ]]; then
flags="${BASH_REMATCH[1]}"
for (( i=0 ; i < ${#flags} ; i++ )); do
input+=("-${flags:i:1}")
done
else
input+=("$arg")
Add package-based install method (#3743) * Add runtime * add procfile * add settings for packaging * use heroku buildpack * maybe a hash works? * try brnach instead of tag or hash * remove reference alltogether * maybe this syntax? * switch back to normal buildpack * and heroku again * try official sample * maybe a tar? * just git clone? * lower version * lower version * switch of settings * try this again * maybe install python before? * no sudo? * just build for ubuntu? * set runtime lower and use custom buildpack * remove initial command * add release command * do not collect static while releaseing * switch to custom backend * Update .pkgr.yml * new backend * upgrade runtime version * consolidate env * update python version * add debian as target * fix os name * extend requirements * remove release command * remove ssl dep * add worker command * add scripts * debug listing * make scripts executable * use python3 * add python install * add python as dep * debug step * switch to app home * set paths right * check local command * remove path * update path * add sample install script * more debugging * dbg msg * more enviroment stuff * more dbugging * more defined install script * reduce function * add debug script * and more * remove before * reduce lines * cleanup deps * maybe this way? * rm " * rename env * fix files * use dot annotation * ls * add msgs * move activation * ref? * use source * use point annotation * remove activate * create env and add it to the enviroment * use full paths * move python init * use modern python * use version numbers for ubuntu * add default env vars ( for now) * use export * use shorthand command * add more variables * use apphome reference in paths * add wasyprint dependencies * also use wheels * add gettext for comiling messages * add nginx setting * remove postgres from required stack * refactor fiel configs * make sure parent dirs exsist * add wheels * move python setup again * update packe name * update gunicron command * move to config * try cleaner procfile * use python 3 wheels * update service def * Add enviroment settings to packaging * restart nginx * remove slack * change nginx config name * fix styles * set permissions on update * Add single line install to README * move nginx names back * use production sample as nginx config * fix sed statement * cleaner nginx setup * keep configs in config file instead of packaging index * fix sed connamds to remove spaces * reintroduce spaces * Also disable debug mode * fix file permissions * remove unneeded commands * readd missing spaces * add admin user generation * Show public ipadress in final message * small cleanups * Add log to setup * remove logging * remove logging parts * chown all dirs * run update command as right user already * set path before running command * fix permission setup * switch right assignment * run commands with sudo * pass in envs * preserve only selected enviroment * show enviroment variables * silence curl * fix envs * clean up final message * move nginx file to variable * make admin creation conditional * a bit more overview for setup variables * test if nginx is available * unlink instead of delet * clean up functions * well that was dumb * ok double dumb - now i tested it * use config for admin generation * fix logic * show value - not call it * switch functions to sh * fix syntax * add admin data to exposed envs * remove keeping of admin pwd * switch to true/false * make nginx file location configureable * use gunicorn instead * fix syntax * set base dir * move env to seperate function * Also use/write database settings * use conf values if available * format sh * update passed envs * fix dep * enable installing extra packages via env (ie database backends) * ann more logging steps * add more debuggin steps * get local envs * add more debug and reorder * more code for testing * fix call * Add debug msg * turn install quiet * fix syntax * reduce debugging * add log step * add datestamp * add marker to inv execution * fix syntax * add codeowner
2022-10-15 23:14:18 +00:00
fi
shift
done
}
# :command.inspect_args
inspect_args() {
readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
if (( ${#args[@]} )); then
echo args:
for k in "${sorted_keys[@]}"; do echo "- \${args[$k]} = ${args[$k]}"; done
else
echo args: none
fi
if (( ${#other_args[@]} )); then
echo
echo other_args:
echo "- \${other_args[*]} = ${other_args[*]}"
for i in "${!other_args[@]}"; do
echo "- \${other_args[$i]} = ${other_args[$i]}"
done
fi
}
# :command.command_functions
# :command.parse_requirements
parse_requirements() {
# :command.fixed_flags_filter
case "${1:-}" in
--version | -v )
version_command
exit
Add package-based install method (#3743) * Add runtime * add procfile * add settings for packaging * use heroku buildpack * maybe a hash works? * try brnach instead of tag or hash * remove reference alltogether * maybe this syntax? * switch back to normal buildpack * and heroku again * try official sample * maybe a tar? * just git clone? * lower version * lower version * switch of settings * try this again * maybe install python before? * no sudo? * just build for ubuntu? * set runtime lower and use custom buildpack * remove initial command * add release command * do not collect static while releaseing * switch to custom backend * Update .pkgr.yml * new backend * upgrade runtime version * consolidate env * update python version * add debian as target * fix os name * extend requirements * remove release command * remove ssl dep * add worker command * add scripts * debug listing * make scripts executable * use python3 * add python install * add python as dep * debug step * switch to app home * set paths right * check local command * remove path * update path * add sample install script * more debugging * dbg msg * more enviroment stuff * more dbugging * more defined install script * reduce function * add debug script * and more * remove before * reduce lines * cleanup deps * maybe this way? * rm " * rename env * fix files * use dot annotation * ls * add msgs * move activation * ref? * use source * use point annotation * remove activate * create env and add it to the enviroment * use full paths * move python init * use modern python * use version numbers for ubuntu * add default env vars ( for now) * use export * use shorthand command * add more variables * use apphome reference in paths * add wasyprint dependencies * also use wheels * add gettext for comiling messages * add nginx setting * remove postgres from required stack * refactor fiel configs * make sure parent dirs exsist * add wheels * move python setup again * update packe name * update gunicron command * move to config * try cleaner procfile * use python 3 wheels * update service def * Add enviroment settings to packaging * restart nginx * remove slack * change nginx config name * fix styles * set permissions on update * Add single line install to README * move nginx names back * use production sample as nginx config * fix sed statement * cleaner nginx setup * keep configs in config file instead of packaging index * fix sed connamds to remove spaces * reintroduce spaces * Also disable debug mode * fix file permissions * remove unneeded commands * readd missing spaces * add admin user generation * Show public ipadress in final message * small cleanups * Add log to setup * remove logging * remove logging parts * chown all dirs * run update command as right user already * set path before running command * fix permission setup * switch right assignment * run commands with sudo * pass in envs * preserve only selected enviroment * show enviroment variables * silence curl * fix envs * clean up final message * move nginx file to variable * make admin creation conditional * a bit more overview for setup variables * test if nginx is available * unlink instead of delet * clean up functions * well that was dumb * ok double dumb - now i tested it * use config for admin generation * fix logic * show value - not call it * switch functions to sh * fix syntax * add admin data to exposed envs * remove keeping of admin pwd * switch to true/false * make nginx file location configureable * use gunicorn instead * fix syntax * set base dir * move env to seperate function * Also use/write database settings * use conf values if available * format sh * update passed envs * fix dep * enable installing extra packages via env (ie database backends) * ann more logging steps * add more debuggin steps * get local envs * add more debug and reorder * more code for testing * fix call * Add debug msg * turn install quiet * fix syntax * reduce debugging * add log step * add datestamp * add marker to inv execution * fix syntax * add codeowner
2022-10-15 23:14:18 +00:00
;;
--help | -h )
long_usage=yes
install_usage
exit
Add package-based install method (#3743) * Add runtime * add procfile * add settings for packaging * use heroku buildpack * maybe a hash works? * try brnach instead of tag or hash * remove reference alltogether * maybe this syntax? * switch back to normal buildpack * and heroku again * try official sample * maybe a tar? * just git clone? * lower version * lower version * switch of settings * try this again * maybe install python before? * no sudo? * just build for ubuntu? * set runtime lower and use custom buildpack * remove initial command * add release command * do not collect static while releaseing * switch to custom backend * Update .pkgr.yml * new backend * upgrade runtime version * consolidate env * update python version * add debian as target * fix os name * extend requirements * remove release command * remove ssl dep * add worker command * add scripts * debug listing * make scripts executable * use python3 * add python install * add python as dep * debug step * switch to app home * set paths right * check local command * remove path * update path * add sample install script * more debugging * dbg msg * more enviroment stuff * more dbugging * more defined install script * reduce function * add debug script * and more * remove before * reduce lines * cleanup deps * maybe this way? * rm " * rename env * fix files * use dot annotation * ls * add msgs * move activation * ref? * use source * use point annotation * remove activate * create env and add it to the enviroment * use full paths * move python init * use modern python * use version numbers for ubuntu * add default env vars ( for now) * use export * use shorthand command * add more variables * use apphome reference in paths * add wasyprint dependencies * also use wheels * add gettext for comiling messages * add nginx setting * remove postgres from required stack * refactor fiel configs * make sure parent dirs exsist * add wheels * move python setup again * update packe name * update gunicron command * move to config * try cleaner procfile * use python 3 wheels * update service def * Add enviroment settings to packaging * restart nginx * remove slack * change nginx config name * fix styles * set permissions on update * Add single line install to README * move nginx names back * use production sample as nginx config * fix sed statement * cleaner nginx setup * keep configs in config file instead of packaging index * fix sed connamds to remove spaces * reintroduce spaces * Also disable debug mode * fix file permissions * remove unneeded commands * readd missing spaces * add admin user generation * Show public ipadress in final message * small cleanups * Add log to setup * remove logging * remove logging parts * chown all dirs * run update command as right user already * set path before running command * fix permission setup * switch right assignment * run commands with sudo * pass in envs * preserve only selected enviroment * show enviroment variables * silence curl * fix envs * clean up final message * move nginx file to variable * make admin creation conditional * a bit more overview for setup variables * test if nginx is available * unlink instead of delet * clean up functions * well that was dumb * ok double dumb - now i tested it * use config for admin generation * fix logic * show value - not call it * switch functions to sh * fix syntax * add admin data to exposed envs * remove keeping of admin pwd * switch to true/false * make nginx file location configureable * use gunicorn instead * fix syntax * set base dir * move env to seperate function * Also use/write database settings * use conf values if available * format sh * update passed envs * fix dep * enable installing extra packages via env (ie database backends) * ann more logging steps * add more debuggin steps * get local envs * add more debug and reorder * more code for testing * fix call * Add debug msg * turn install quiet * fix syntax * reduce debugging * add log step * add datestamp * add marker to inv execution * fix syntax * add codeowner
2022-10-15 23:14:18 +00:00
;;
esac
# :command.command_filter
action="root"
# :command.parse_requirements_while
while [[ $# -gt 0 ]]; do
key="$1"
case "$key" in
# :flag.case
--no-call | -n )
# :flag.case_no_arg
args[--no-call]=1
shift
;;
# :flag.case
--dry-run | -d )
# :flag.case_no_arg
args[--dry-run]=1
shift
;;
-?* )
printf "invalid option: %s\n" "$key" >&2
exit 1
;;
* )
# :command.parse_requirements_case
# :command.parse_requirements_case_simple
if [[ -z ${args[source]+x} ]]; then
args[source]=$1
shift
elif [[ -z ${args[publisher]+x} ]]; then
args[publisher]=$1
shift
else
printf "invalid argument: %s\n" "$key" >&2
exit 1
fi
;;
esac
done
# :command.default_assignments
[[ -n ${args[source]:-} ]] || args[source]="stable"
[[ -n ${args[publisher]:-} ]] || args[publisher]="inventree"
# :command.whitelist_filter
if [[ ! ${args[source]} =~ ^(stable|master|main)$ ]]; then
printf "%s\n" "source must be one of: stable, master, main" >&2
exit 1
fi
}
# :command.initialize
initialize() {
version="2.0"
long_usage=''
set -e
# src/initialize.sh
}
# :command.run
run() {
declare -A args=()
declare -a other_args=()
declare -a input=()
normalize_input "$@"
parse_requirements "${input[@]}"
if [[ $action == "root" ]]; then
root_command
fi
}
initialize
run "$@"