From 528279e3ae12a196789e90641680913e383d98e4 Mon Sep 17 00:00:00 2001 From: home Date: Tue, 31 Oct 2023 21:36:17 +0300 Subject: [PATCH] add bootstrap. --- .README.md | 5 +++++ .bootstrap.sh | 14 +++++++++++++ .gitignore | 3 +++ .linux/bash/module/toolbx.sh | 38 ++++++++++++++++++------------------ 4 files changed, 41 insertions(+), 19 deletions(-) create mode 100755 .bootstrap.sh diff --git a/.README.md b/.README.md index 2c73b8a..30da012 100644 --- a/.README.md +++ b/.README.md @@ -1,6 +1,11 @@ # Custom system config. This is my own custom config that I use on my GNU/Linux machines. Not ment to be used by anyone else. +# Bootstrap. +```bash + +``` + # Table of contents. 1. [General info.](#general-info) diff --git a/.bootstrap.sh b/.bootstrap.sh new file mode 100755 index 0000000..a6e8f74 --- /dev/null +++ b/.bootstrap.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# check if this is already a git repo. +if [[ -d ".git" ]]; then + echo "Found the .git directory. Already initialized?" + exit 1 +fi + +# sync. +git init +git remote add origin https://git.voronind.com/voronind/linux.git +git fetch +git reset origin/master +git checkout -t origin/master diff --git a/.gitignore b/.gitignore index cc2e0f6..dc4ec9b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ * +# bootstrap. +!/.bootstrap.sh + # readme. !/.README.md diff --git a/.linux/bash/module/toolbx.sh b/.linux/bash/module/toolbx.sh index a5d06e1..bc33b71 100644 --- a/.linux/bash/module/toolbx.sh +++ b/.linux/bash/module/toolbx.sh @@ -2,38 +2,38 @@ # usage: tb [NAME] tba() { - local name="$1" + local name="${1}" # set default name. - if [[ "$name" = "" ]]; then + if [[ "${name}" = "" ]]; then name="main" fi # start container or run command inside it if specified. - if [[ "$2" = "" ]]; then + if [[ "${2}" = "" ]]; then # set hostname. - toolbox --container "$name" run sudo hostname "${HOSTNAME}-${name}" + toolbox --container "${name}" run sudo hostname "${HOSTNAME}-${name}" # try to enter or create if failed. - toolbox enter "$name" || { + toolbox enter "${name}" || { # create container. - toolbox create "$name" + toolbox create "${name}" # initialize container. - toolbox --container "$name" run sudo hostname "${HOSTNAME}-${name}" - toolbox --container "$name" run sudo rm /root/.bashrc - toolbox --container "$name" run sudo ln -s $HOME/.linux /root/.linux - toolbox --container "$name" run sudo ln -s /root/.linux/bash/bashrc.sh /root/.bashrc + toolbox --container "${name}" run sudo hostname "${HOSTNAME}-${name}" + # toolbox --container "$name" run sudo rm /root/.bashrc + # toolbox --container "$name" run sudo ln -s $HOME/.linux /root/.linux + # toolbox --container "$name" run sudo ln -s /root/.linux/bash/bashrc.sh /root/.bashrc # enter container, finally. - toolbox enter "$name" + toolbox enter "${name}" } else # set hostname. - toolbox --container "$name" run sudo hostname "${HOSTNAME}-${name}" + toolbox --container "${name}" run sudo hostname "${HOSTNAME}-${name}" # run command inside container. - toolbox --container "$name" run ${@:2} + toolbox --container "${name}" run ${@:2} fi } @@ -41,30 +41,30 @@ tba() # usage: tbk [NAME] tbk() { - local name="$1" + local name="${1}" # set default name. - if [[ "$name" = "" ]]; then + if [[ "${name}" = "" ]]; then name="main" fi # stop and remove podman container. - podman stop "$name" > /dev/null && podman rm "$name" > /dev/null + podman stop "${name}" > /dev/null && podman rm "${name}" > /dev/null } # install rpm-fusion repository. # usage: tb_rpmfusion [NAME] tb_rpmfusion() { - local name="$1" + local name="${1}" # set default name. - if [[ "$name" = "" ]]; then + if [[ "${name}" = "" ]]; then name="main" fi # run dnf inside container. - toolbox --container "$name" run sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm + toolbox --container "${name}" run sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm } # list all containers.