A bin folder, holding helpfull scripts and commands
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

init_homepath 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/usr/bin/python3
  2. #
  3. import subprocess
  4. import sys
  5. def proceed():
  6. while True:
  7. uf = input("\nProceed? [Y/n/q]")
  8. if len(uf) == 0:
  9. uf = "y"
  10. if uf.lower() in ["y", "n", "q"]:
  11. break
  12. if uf == "q":
  13. sys.exit(1)
  14. else:
  15. return uf == "y"
  16. BASE_GIT_URL = "https://git.mount-mockery.de/dirk"
  17. REPOS = (
  18. (BASE_GIT_URL + "/" + "bin.git", "~/bin"),
  19. (BASE_GIT_URL + "/" + "bash.git", "~/.bash"),
  20. (BASE_GIT_URL + "/" + "config_files.git", "~/.config_files"),
  21. )
  22. print("Cloning the following repositories:")
  23. for data in REPOS:
  24. print(" %s --> %s" % data)
  25. if proceed():
  26. for url, target in REPOS:
  27. command = "git clone %s %s" % (url, target)
  28. sys.stdout.write("Cloning %s" % url)
  29. process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  30. process.wait()
  31. if process.returncode == 0:
  32. print("\t\t[ SUCCESS ]")
  33. else:
  34. print("\t\t[ FAILED ]")
  35. print(" ", process.stderr.read().decode("utf-8"))
  36. CONFIG_COMMANDS = (
  37. "GS=`grep .bash/enabled ~/.bashrc`; [ ${#GS} -ne 0 ] || cat ~/.bash/BASHRC_ADDON >> ~/.bashrc",
  38. "mkdir -p ~/.cache/vim && mkdir -p ~/.vim && ln -s ~/.config_files/vimrc ~/.vimrc && ln -s ~/.config_files/vim_skeletons ~/.vim/skeletons",
  39. "which tmux && ln -s ~/.config_files/tmux.conf ~/.tmux.conf",
  40. "mkdir -p ~/.config && ln -s ~/.config_files/powerline_gitstatus ~/.config/powerline",
  41. "mkdir -p ~/.ssh && chmod 700 ~/.ssh && ln -s ~/.config_files/ssh_config ~/.ssh/config",
  42. )
  43. print("\n\n\nAdding the configuration to your environment:")
  44. for command in CONFIG_COMMANDS:
  45. print(" ", command)
  46. if proceed():
  47. for command in CONFIG_COMMANDS:
  48. sys.stdout.write("Executing %s" % command)
  49. process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  50. process.wait()
  51. if process.returncode == 0:
  52. print("\t\t[ SUCCESS ]")
  53. else:
  54. print("\t\t[ FAILED ]")
  55. print(" ", process.stderr.read().decode("utf-8"))
  56. #BASE_FOLDERS="Downloads media_images Videos C64"
  57. #VIP_FOLDERS="prj prj/Arduino Schreibtisch"
  58. #echo The following folders will be deleted:
  59. #for folder in $BASE_FOLDERS; do
  60. # echo -e "* $HOME/\033[1m$folder\033[0m"
  61. #done
  62. #for folder in $VIP_FOLDERS; do
  63. # echo -e "* $HOME/\033[1m$folder\033[0m"
  64. #done
  65. #echo
  66. #read -r -p "Are you sure? [y/N] " response
  67. #case "$response" in
  68. # [yY][eE][sS]|[yY])
  69. # for folder in $BASE_FOLDERS; do
  70. # rm -rf $HOME/`basename $folder`; ln -s /usr/data/$USER/local/$folder $HOME
  71. # done
  72. # rm -rf $HOME/data; ln -s /usr/data/$USER/data data
  73. # for folder in $VIP_FOLDERS; do
  74. # rm -rf $HOME/`basename $folder`; ln -s /usr/data/$USER/data/$folder $HOME
  75. # done
  76. # ;;
  77. # *)
  78. # echo No folder initialisation!
  79. # ;;
  80. #esac