diff --git a/script/install-komrade.sh b/script/install-komrade.sh new file mode 100644 index 0000000..9aaff7b --- /dev/null +++ b/script/install-komrade.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# +# Usage: curl https://pyenv.run | bash +# +# For more info, visit: https://raw.githubusercontent.com/pyenv/pyenv-installer +# +index_main() { + set -e + curl -s -S -L https://github.com/Komrade/Komrade/blob/master/script/komrade-installer.py | bash +} + +index_main \ No newline at end of file diff --git a/bin/komrade-install b/script/komrade-installer.py similarity index 71% rename from bin/komrade-install rename to script/komrade-installer.py index 4eb6463..4e2a514 100755 --- a/bin/komrade-install +++ b/script/komrade-installer.py @@ -4,6 +4,10 @@ URL_PYENV = 'https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/ import os,sys,urllib,shutil from urllib import request +import distutils +from distutils import dir_util + + print(''' # # ## # # ### ## ### #### @@ -19,7 +23,7 @@ installing... PATH_HOME = os.path.expanduser('~') PATH_KOMRADE = os.path.join(PATH_HOME,'komrade') path_pyenv = os.path.join(PATH_HOME,'.pyenv') -path_repo = os.path.join(PATH_KOMRADE,'Komrade') +path_repo = os.path.join(PATH_KOMRADE,'code') def is_tool(name): """Check whether `name` is on PATH and marked as executable.""" from shutil import which @@ -35,14 +39,15 @@ def main(): os.chdir(path_komrade) # 2) install pyenv? - if not is_tool('pyenv') or not os.path.exists(path_pyenv): + if not os.path.exists(path_pyenv): pyenv_yn = input('\npyenv is not installed. Install?\n[Y/n] ').strip().lower() if pyenv_yn != 'n': print('installing pyenv...') os.system('curl https://pyenv.run | bash') # # 3) download komrade - if is_tool('git2'): + print('\ndownloading Komrade...') + if is_tool('git'): if os.path.exists(path_repo): os.chdir(path_repo) os.system('git pull') @@ -51,16 +56,38 @@ def main(): os.system('git clone https://github.com/Komrade/Komrade.git') else: os.chdir(path_komrade) - os.system('curl -o komrade-github.zip -LJO https://github.com/Komrade/Komrade/archive/master.zip') - os.system('unzip komrade-github.zip') - os.rename('Komrade-master','code') + request.urlretrieve( + 'https://github.com/Komrade/Komrade/archive/master.zip', + 'komrade-github.zip' + ) + os.system('unzip -o komrade-github.zip') + distutils.dir_util.copy_tree("Komrade-master", "code") + + shutil.rmtree('Komrade-master') os.remove('komrade-github.zip') - + ## 4) install komrade os.chdir(path_repo) os.environ['PYENV_ROOT']=path_pyenv os.environ['PATH'] = os.path.join(path_pyenv,'bin') + os.environ['PATH'] - os.system('. script/bootstrap') + # os.system('. script/bootstrap') + os.system(''' + +export PYENV_ROOT="$HOME/.pyenv" +export PATH="$PYENV_ROOT/bin:$PATH" + +echo `which pyenv` + +#if command -v pyenv 1>/dev/null 2>&1; then +# eval "$(pyenv init -)" +#fi + + +. script/bootstrap + +''') + + if __name__ == '__main__': main() \ No newline at end of file