From 0a13950d786b159cb8e79778706429a1733c384e Mon Sep 17 00:00:00 2001 From: Sebastian Burschel Date: Mon, 2 Sep 2024 09:11:29 +0200 Subject: [PATCH] Changes --- .config/yadm/bootstrap | 119 +++++++++++++++++------------------ .config/yadm/encrypt | 1 + .config/yadm/hooks/post_pull | 4 ++ .local/share/yadm/archive | 3 + bin/venv-new | 43 +++++++------ 5 files changed, 88 insertions(+), 82 deletions(-) create mode 100644 .config/yadm/encrypt create mode 100755 .config/yadm/hooks/post_pull create mode 100644 .local/share/yadm/archive diff --git a/.config/yadm/bootstrap b/.config/yadm/bootstrap index 6b8cf0b..105e790 100755 --- a/.config/yadm/bootstrap +++ b/.config/yadm/bootstrap @@ -1,6 +1,5 @@ #!/bin/sh - ############# Packages to install ######################################## macos_homebrew_essentials="python3 vim-nox tmux nano zsh git autossh mosh sshuttle lynx npm tidy mcfly ack ncdu shfmt" @@ -9,17 +8,15 @@ raspberrypi_essentials="python3 python3-pip vim-nox python3-venv tmux nano zsh g raspberrypi_printer="cups printer-driver-gutenprint" raspberrypi_camera="python3-opencv" - ############# Packages install functions ################################# - install_python_linters() { pip3 install requests bs4 prospector black isort --break-system-packages } install_npm_linters() { - sudo npm install -g jsonlint - sudo npm install -g fixjson + sudo npm install -g jsonlint + sudo npm install -g fixjson } ############# MacOS exclusive commands ################################### @@ -29,88 +26,86 @@ system_type=$(uname -s) if [ "$system_type" = "Darwin" ]; then - # install homebrew if it's missing - if ! command -v brew >/dev/null 2>&1; then - echo "Install homebrew? (y/n)" - read -r install_homebrew - if [ $install_homebrew = "y" ]; then - echo "Installing homebrew" - /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" + # install homebrew if it's missing + if ! command -v brew >/dev/null 2>&1; then + echo "Install homebrew? (y/n, default=y)" + read -r install_homebrew + install_homebrew=${install_homebrew:-y} + if echo "$install_homebrew" | grep -qi '^[yj]$'; then + echo "Installing homebrew" + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" + fi fi - fi fi ############# Raspberrypi exclusive commands ############################# if [ "$system_type" = "Linux" ]; then - install_this_now="" + install_this_now="" - echo "Install the most important packages ($raspberrypi_essentials)? (y/n)" - read -r install_raspberrypi_essentials - if [ $install_raspberrypi_essentials = "y" ]; then - install_this_now="$install_this_now $raspberrypi_essentials" - fi + echo "Install the most important packages ($raspberrypi_essentials)? (y/n, default=y)" + read -r install_raspberrypi_essentials + install_raspberrypi_essentials=${install_raspberrypi_essentials:-y} + if echo "$install_raspberrypi_essentials" | grep -qi '^[yj]$'; then + install_this_now="$install_this_now $raspberrypi_essentials" + fi - echo "Install the packages for printing? (y/n)" - read -r install_raspberrypi_printer - if [ $install_raspberrypi_printer = "y" ]; then - install_this_now="$install_this_now $raspberrypi_printer" - fi + echo "Install the packages for printing? (y/n, default=y)" + read -r install_raspberrypi_printer + install_raspberrypi_printer=${install_raspberrypi_printer:-y} + if echo "$install_raspberrypi_printer" | grep -qi '^[yj]$'; then + install_this_now="$install_this_now $raspberrypi_printer" + fi + echo "Install the packages for the camera? (y/n, default=y)" + read -r install_raspberrypi_camera + install_raspberrypi_camera=${install_raspberrypi_camera:-y} + if echo "$install_raspberrypi_camera" | grep -qi '^[yj]$'; then + install_this_now="$install_this_now $raspberrypi_camera" + fi - echo "Install the packages for the camera? (y/n)" - read -r install_raspberrypi_camera - if [ $install_raspberrypi_camera = "y" ]; then - install_this_now="$install_this_now $raspberrypi_camera" - fi - - - if [ -n "$install_this_now" ]; then - echo "Packages will be installed now!" - sudo apt update - for i in $install_this_now; do - sudo apt-get install -y $i - done - - - - fi + if [ -n "$install_this_now" ]; then + echo "Packages will be installed now!" + sudo apt update + for i in $install_this_now; do + sudo apt-get install -y $i + done + fi fi - if command -v ufw >/dev/null 2>&1; then - echo "Enable the firewall (ufw with ssh allowed)? (y/n)" - read -r enable_ufw - if [ $enable_ufw = "y" ]; then - ufw allow ssh - ufw enable - - fi + echo "Enable the firewall (ufw with ssh allowed)? (y/n, default=y)" + read -r enable_ufw + enable_ufw=${enable_ufw:-y} + if echo "$enable_ufw" | grep -qi '^[yj]$'; then + ufw allow ssh + ufw enable + fi fi - - ############# Commands for both ########################################## if command -v /bin/zsh >/dev/null 2>&1; then - echo "Set zsh as default shell? (y/n)" - read -r set_default_shell - if [ $set_default_shell = "y" ]; then - chsh -s /bin/zsh - fi + echo "Set zsh as default shell? (y/n, default=y)" + read -r set_default_shell + set_default_shell=${set_default_shell:-y} + if echo "$set_default_shell" | grep -qi '^[yj]$'; then + chsh -s /bin/zsh + fi fi -echo "Install all linters for vim? (y/n)" +echo "Install all linters for vim? (y/n, default=y)" read -r install_linters -if [ $install_linters = "y" ]; then +install_linters=${install_linters:-y} +if echo "$install_linters" | grep -qi '^[yj]$'; then install_npm_linters install_python_linters fi - -echo "Install the vim plugins now? (y/n)" +echo "Install the vim plugins now? (y/n, default=y)" read -r install_vim_plugins -if [ $install_vim_plugins = "y" ]; then +install_vim_plugins=${install_vim_plugins:-y} +if echo "$install_vim_plugins" | grep -qi '^[yj]$'; then vim +'PlugInstall --sync' +qa + echo "Done!" fi - diff --git a/.config/yadm/encrypt b/.config/yadm/encrypt new file mode 100644 index 0000000..dc8c950 --- /dev/null +++ b/.config/yadm/encrypt @@ -0,0 +1 @@ +important_git_repositories.txt diff --git a/.config/yadm/hooks/post_pull b/.config/yadm/hooks/post_pull new file mode 100755 index 0000000..7f5d663 --- /dev/null +++ b/.config/yadm/hooks/post_pull @@ -0,0 +1,4 @@ +#!/bin/sh + +yadm alt +yadm perms diff --git a/.local/share/yadm/archive b/.local/share/yadm/archive new file mode 100644 index 0000000..32a82bd --- /dev/null +++ b/.local/share/yadm/archive @@ -0,0 +1,3 @@ + И;0 +?ca=;=|$ 4yS;8 *lQ,t?ͬxBҿZ=;c6^3*ˆLմˢHZ/dev/null 2>&1; then python_versions="$python_versions $version" fi @@ -27,27 +23,31 @@ if [ -z "$python_versions" ]; then exit 1 fi -# Entferne Duplikate und sortiere die Python-Versionen -python_versions=$(echo "$python_versions" | tr ' ' '\n' | sort -u -r | tr '\n' ' ') +# Remove duplicates +python_versions=$(echo "$python_versions" | tr ' ' '\n' | sort -u -rV | tr '\n' ' ') -# Nummerierte Liste der Python-Versionen anzeigen echo "Installed Python3 versions:" i=1 +highest_version="" for version in $python_versions; do - echo "$i) $(basename "$version")" + if [ $i -eq 1 ]; then + highest_version=$(basename "$version") + echo "$i) $(basename "$version") (default)" + else + echo "$i) $(basename "$version")" + fi i=$((i + 1)) done -# Benutzer nach der Auswahl fragen echo "Select the number of the Python version you want to use:" read user_choice +# Enter -> default if [ -z "$user_choice" ]; then user_choice=1 fi - -# Überprüfen, ob die Eingabe eine Zahl ist +# Check if int if echo "$user_choice" | grep -qE '^[0-9]+$'; then i=1 for version in $python_versions; do @@ -58,7 +58,7 @@ if echo "$user_choice" | grep -qE '^[0-9]+$'; then i=$((i + 1)) done - # Überprüfen, ob eine gültige Auswahl getroffen wurde + # Check if input is valid if [ -n "$python_version" ]; then echo "You selected: $version" else @@ -73,19 +73,22 @@ fi # Additional parameter additional_parameters="--upgrade-deps --clear" -echo "Should the venv have access to the system packages? (y/n)" +echo "Should the venv have access to the system packages? (y/n, default=n)" read -r add_system_packages -if [ "$add_system_packages" = "y" ]; then +add_system_packages=${add_system_packages:-n} +if echo "$add_system_packages" | grep -qi '^[yj]$'; then additional_parameters="$additional_parameters --system-site-packages" fi -# Create venv +echo "Creating venv..." $version -m venv venv $additional_parameters source ./venv/bin/activate +echo "Finished!\n" -# Install requirements.txt -echo "Install packages from requirements.txt? (y/n)" + +echo "Install packages from requirements.txt? (y/n, default=y)" read -r install_requirements_txt -if [ "$install_requirements_txt" = "y" ]; then +install_requirements_txt=${install_requirements_txt:-y} +if echo "$install_requirements_txt" | grep -qi '^[yj]$'; then python3 -m pip install -r requirements.txt fi