1st step of init_homepath rework
This commit is contained in:
parent
737597bf3b
commit
7ead24e4f3
112
init_homepath
112
init_homepath
@ -1,30 +1,90 @@
|
|||||||
#!/bin/sh
|
#!/usr/bin/python3
|
||||||
#
|
#
|
||||||
|
|
||||||
BASE_FOLDERS="Downloads media_images Videos C64"
|
import subprocess
|
||||||
VIP_FOLDERS="prj prj/Arduino Schreibtisch"
|
import sys
|
||||||
|
|
||||||
|
def proceed():
|
||||||
|
while True:
|
||||||
|
uf = input("\nProceed? [Y/n/q]")
|
||||||
|
if len(uf) == 0:
|
||||||
|
uf = "y"
|
||||||
|
if uf.lower() in ["y", "n", "q"]:
|
||||||
|
break
|
||||||
|
if uf == "q":
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
return uf == "y"
|
||||||
|
|
||||||
|
|
||||||
|
BASE_GIT_URL = "https://git.mount-mockery.de/dirk"
|
||||||
|
REPOS = (
|
||||||
|
(BASE_GIT_URL + "/" + "bin.git", "~/bin"),
|
||||||
|
(BASE_GIT_URL + "/" + "bash.git", "~/.bash"),
|
||||||
|
(BASE_GIT_URL + "/" + "config_files.git", "~/.config_files"),
|
||||||
|
)
|
||||||
|
print("Cloning the following repositories:")
|
||||||
|
for data in REPOS:
|
||||||
|
print(" %s --> %s" % data)
|
||||||
|
if proceed():
|
||||||
|
for url, target in REPOS:
|
||||||
|
command = "git clone %s %s" % (url, target)
|
||||||
|
sys.stdout.write("Cloning %s" % url)
|
||||||
|
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
process.wait()
|
||||||
|
if process.returncode == 0:
|
||||||
|
print("\t\t[ SUCCESS ]")
|
||||||
|
else:
|
||||||
|
print("\t\t[ FAILED ]")
|
||||||
|
print(" ", process.stderr.read().decode("utf-8"))
|
||||||
|
|
||||||
|
CONFIG_COMMANDS = (
|
||||||
|
"GS=`grep .bash/enabled ~/.bashrc`; [ ${#GS} -ne 0 ] || cat ~/.bash/BASHRC_ADDON >> ~/.bashrc",
|
||||||
|
"mkdir -p ~/.cache/vim && mkdir -p ~/.vim && ln -s ~/.config_files/vimrc ~/.vimrc && ln -s ~/.config_files/vim_skeletons ~/.vim/skeletons",
|
||||||
|
"which tmux && ln -s ~/.config_files/tmux.conf ~/.tmux.conf",
|
||||||
|
"mkdir -p ~/.config && ln -s ~/.config_files/powerline_gitstatus ~/.config/powerline",
|
||||||
|
"mkdir -p ~/.ssh && chmod 700 ~/.ssh && ln -s ~/.config_files/ssh_config ~/.ssh/config",
|
||||||
|
)
|
||||||
|
print("\n\n\nAdding the configuration to your environment:")
|
||||||
|
for command in CONFIG_COMMANDS:
|
||||||
|
print(" ", command)
|
||||||
|
if proceed():
|
||||||
|
for command in CONFIG_COMMANDS:
|
||||||
|
sys.stdout.write("Executing %s" % command)
|
||||||
|
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
process.wait()
|
||||||
|
if process.returncode == 0:
|
||||||
|
print("\t\t[ SUCCESS ]")
|
||||||
|
else:
|
||||||
|
print("\t\t[ FAILED ]")
|
||||||
|
print(" ", process.stderr.read().decode("utf-8"))
|
||||||
|
|
||||||
|
#BASE_FOLDERS="Downloads media_images Videos C64"
|
||||||
|
#VIP_FOLDERS="prj prj/Arduino Schreibtisch"
|
||||||
|
|
||||||
|
|
||||||
|
#echo The following folders will be deleted:
|
||||||
|
#for folder in $BASE_FOLDERS; do
|
||||||
|
# echo -e "* $HOME/\033[1m$folder\033[0m"
|
||||||
|
#done
|
||||||
|
#for folder in $VIP_FOLDERS; do
|
||||||
|
# echo -e "* $HOME/\033[1m$folder\033[0m"
|
||||||
|
#done
|
||||||
|
#echo
|
||||||
|
#read -r -p "Are you sure? [y/N] " response
|
||||||
|
#case "$response" in
|
||||||
|
# [yY][eE][sS]|[yY])
|
||||||
|
# for folder in $BASE_FOLDERS; do
|
||||||
|
# rm -rf $HOME/`basename $folder`; ln -s /usr/data/$USER/local/$folder $HOME
|
||||||
|
# done
|
||||||
|
# rm -rf $HOME/data; ln -s /usr/data/$USER/data data
|
||||||
|
# for folder in $VIP_FOLDERS; do
|
||||||
|
# rm -rf $HOME/`basename $folder`; ln -s /usr/data/$USER/data/$folder $HOME
|
||||||
|
# done
|
||||||
|
# ;;
|
||||||
|
# *)
|
||||||
|
# echo No folder initialisation!
|
||||||
|
# ;;
|
||||||
|
#esac
|
||||||
|
|
||||||
|
|
||||||
echo The following folders will be deleted:
|
|
||||||
for folder in $BASE_FOLDERS; do
|
|
||||||
echo -e "* $HOME/\033[1m$folder\033[0m"
|
|
||||||
done
|
|
||||||
for folder in $VIP_FOLDERS; do
|
|
||||||
echo -e "* $HOME/\033[1m$folder\033[0m"
|
|
||||||
done
|
|
||||||
echo
|
|
||||||
read -r -p "Are you sure? [y/N] " response
|
|
||||||
case "$response" in
|
|
||||||
[yY][eE][sS]|[yY])
|
|
||||||
for folder in $BASE_FOLDERS; do
|
|
||||||
rm -rf $HOME/`basename $folder`; ln -s /usr/data/$USER/local/$folder $HOME
|
|
||||||
done
|
|
||||||
rm -rf $HOME/data; ln -s /usr/data/$USER/data data
|
|
||||||
for folder in $VIP_FOLDERS; do
|
|
||||||
rm -rf $HOME/`basename $folder`; ln -s /usr/data/$USER/data/$folder $HOME
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo No folder initialisation!
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user