add prefix option to install2.sh script
This commit is contained in:
parent
79058810c2
commit
bd87403ae5
2 changed files with 13 additions and 6 deletions
|
@ -13,7 +13,8 @@ fi
|
||||||
# parse arguments
|
# parse arguments
|
||||||
dev=""
|
dev=""
|
||||||
verbose=""
|
verbose=""
|
||||||
while getopts "dv" opt; do
|
prefix=""
|
||||||
|
while getopts "dvp:" opt; do
|
||||||
case ${opt} in
|
case ${opt} in
|
||||||
d)
|
d)
|
||||||
dev="-d"
|
dev="-d"
|
||||||
|
@ -21,11 +22,15 @@ while getopts "dv" opt; do
|
||||||
v)
|
v)
|
||||||
verbose="-v"
|
verbose="-v"
|
||||||
;;
|
;;
|
||||||
|
p)
|
||||||
|
prefix="-p ${OPTARG}"
|
||||||
|
;;
|
||||||
\?)
|
\?)
|
||||||
echo "script usage: $(basename $0) [-d] [-v]" >&2
|
echo "script usage: $(basename $0) [-d] [-v]" >&2
|
||||||
echo "" >&2
|
echo "" >&2
|
||||||
echo "-v enable verbose install" >&2
|
echo "-v enable verbose install" >&2
|
||||||
echo "-d enable developer install" >&2
|
echo "-d enable developer install" >&2
|
||||||
|
echo "-p install prefix, defaults to /usr/local" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -49,4 +54,4 @@ python3 -m pip install --user pipx
|
||||||
python3 -m pipx ensurepath
|
python3 -m pipx ensurepath
|
||||||
export PATH=$PATH:~/.local/bin
|
export PATH=$PATH:~/.local/bin
|
||||||
pipx install invoke
|
pipx install invoke
|
||||||
inv install ${dev} ${verbose}
|
inv install ${dev} ${verbose} ${prefix}
|
||||||
|
|
10
tasks.py
10
tasks.py
|
@ -10,6 +10,7 @@ from invoke import task, Context
|
||||||
DAEMON_DIR: str = "daemon"
|
DAEMON_DIR: str = "daemon"
|
||||||
VCMD_DIR: str = "netns"
|
VCMD_DIR: str = "netns"
|
||||||
GUI_DIR: str = "gui"
|
GUI_DIR: str = "gui"
|
||||||
|
DEFAULT_PREFIX: str = "/usr/local"
|
||||||
|
|
||||||
|
|
||||||
class OsName(Enum):
|
class OsName(Enum):
|
||||||
|
@ -169,7 +170,7 @@ def install_ospf_mdr(c: Context, os_info: OsInfo, hide: bool) -> None:
|
||||||
c.run("sudo make install", hide=hide)
|
c.run("sudo make install", hide=hide)
|
||||||
|
|
||||||
|
|
||||||
def install_files(c: Context, hide: bool, prefix: str = "/usr/local") -> None:
|
def install_files(c: Context, hide: bool, prefix: str = DEFAULT_PREFIX) -> None:
|
||||||
# install all scripts
|
# install all scripts
|
||||||
python = get_python(c)
|
python = get_python(c)
|
||||||
bin_dir = Path(prefix).joinpath("bin")
|
bin_dir = Path(prefix).joinpath("bin")
|
||||||
|
@ -225,10 +226,11 @@ def install_files(c: Context, hide: bool, prefix: str = "/usr/local") -> None:
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def install(c, dev=False, verbose=False):
|
def install(c, dev=False, verbose=False, prefix=DEFAULT_PREFIX):
|
||||||
"""
|
"""
|
||||||
install core
|
install core
|
||||||
"""
|
"""
|
||||||
|
print(f"installing core with prefix: {prefix}")
|
||||||
hide = not verbose
|
hide = not verbose
|
||||||
os_info = get_os()
|
os_info = get_os()
|
||||||
install_system(c, os_info, hide)
|
install_system(c, os_info, hide)
|
||||||
|
@ -236,7 +238,7 @@ def install(c, dev=False, verbose=False):
|
||||||
build(c, os_info, hide)
|
build(c, os_info, hide)
|
||||||
install_core(c, hide)
|
install_core(c, hide)
|
||||||
install_poetry(c, dev, hide)
|
install_poetry(c, dev, hide)
|
||||||
install_files(c, hide)
|
install_files(c, hide, prefix)
|
||||||
install_ospf_mdr(c, os_info, hide)
|
install_ospf_mdr(c, os_info, hide)
|
||||||
print("please open a new terminal or re-login to leverage invoke for running core")
|
print("please open a new terminal or re-login to leverage invoke for running core")
|
||||||
print("# run daemon")
|
print("# run daemon")
|
||||||
|
@ -246,7 +248,7 @@ def install(c, dev=False, verbose=False):
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def uninstall(c, dev=False, verbose=False, prefix="/usr/local"):
|
def uninstall(c, dev=False, verbose=False, prefix=DEFAULT_PREFIX):
|
||||||
"""
|
"""
|
||||||
uninstall core
|
uninstall core
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue