mirror of
https://github.com/artizirk/dotfiles.git
synced 2025-06-06 22:58:17 +03:00
Compare commits
2 Commits
0bb59ae237
...
16c9af02ff
Author | SHA1 | Date | |
---|---|---|---|
16c9af02ff | |||
e26a30d88e |
@ -11,22 +11,26 @@ fi
|
|||||||
|
|
||||||
function show_help {
|
function show_help {
|
||||||
cat <<-EOF
|
cat <<-EOF
|
||||||
Usage: $0 -h | -n NAME [-s SUITE] [-d]
|
Usage: $0 -h | -n NAME [-s SUITE] [-t [SNAPSHOT_NAME] -r] [-d]
|
||||||
|
|
||||||
Create a nspanw container called NAME
|
Create a nspanw container called NAME
|
||||||
|
|
||||||
-h help
|
-h help
|
||||||
-n container name
|
-n container name
|
||||||
-s debian suite (default: ${DEFAULT_SUITE})
|
-s debian suite (default: ${DEFAULT_SUITE})
|
||||||
|
-t snapshot container
|
||||||
|
-r rollback to snapshot
|
||||||
-d delete container
|
-d delete container
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts 'hn:s:d' flag; do
|
while getopts 'hn:s:t:rd' flag; do
|
||||||
case "${flag}" in
|
case "${flag}" in
|
||||||
h) show_help; exit 0;;
|
h) show_help; exit 0;;
|
||||||
n) name="${OPTARG}" ;;
|
n) name="${OPTARG}" ;;
|
||||||
s) suite="${OPTARG}" ;;
|
s) suite="${OPTARG}" ;;
|
||||||
|
t) snapshot="${OPTARG}" ;;
|
||||||
|
r) rollback=1 ;;
|
||||||
d) delete=1 ;;
|
d) delete=1 ;;
|
||||||
*) echo "Unexpected option ${flag}" ;;
|
*) echo "Unexpected option ${flag}" ;;
|
||||||
esac
|
esac
|
||||||
@ -43,9 +47,26 @@ else
|
|||||||
echo "Container name is $name and suite is ${SUITE}"
|
echo "Container name is $name and suite is ${SUITE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n ${snapshot:-} ]]; then
|
||||||
|
dest_snapshot_name="${BASE}/.${name}_${snapshot}"
|
||||||
|
if [[ -n ${rollback:-} ]]; then
|
||||||
|
if [[ -d ${dest_snapshot_name} ]]; then
|
||||||
|
btrfs subvolume delete "${BASE}/${name}"
|
||||||
|
btrfs subvolume snapshot "${dest_snapshot_name}" "${BASE}/${name}"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Can't rollback as '${snapshot}' does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
btrfs subvolume snapshot -r "${BASE}/${name}" "${dest_snapshot_name}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -n ${delete:-} ]]; then
|
if [[ -n ${delete:-} ]]; then
|
||||||
btrfs subvolume delete "${BASE}/$name"
|
btrfs subvolume delete "${BASE}/${name}" "${BASE}/.${name}_"*
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
btrfs subvolume create "${BASE}/${name}"
|
btrfs subvolume create "${BASE}/${name}"
|
||||||
@ -92,7 +113,7 @@ elif [[ "$ID" == "debian" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install --yes --no-install-recommends locales dbus ssh python3
|
apt-get install --yes --no-install-recommends locales dbus ssh python3 libnss-resolve
|
||||||
|
|
||||||
echo "locales locales/default_environment_locale select en_US.UTF-8" | debconf-set-selections
|
echo "locales locales/default_environment_locale select en_US.UTF-8" | debconf-set-selections
|
||||||
echo "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8, et_EE.UTF-8 UTF-8" | debconf-set-selections
|
echo "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8, et_EE.UTF-8 UTF-8" | debconf-set-selections
|
||||||
@ -105,9 +126,8 @@ apt install --yes --no-install-recommends neovim
|
|||||||
update-alternatives --set editor /usr/bin/nvim
|
update-alternatives --set editor /usr/bin/nvim
|
||||||
ln -sf /usr/share/nvim/runtime/macros/less.sh /usr/local/bin/vless
|
ln -sf /usr/share/nvim/runtime/macros/less.sh /usr/local/bin/vless
|
||||||
|
|
||||||
# Use systemd-resovled directly by configuring /etc/nsswitch.conf
|
|
||||||
apt install --yes --no-install-recommends libnss-resolve
|
|
||||||
|
|
||||||
systemctl enable systemd-networkd
|
systemctl enable systemd-networkd
|
||||||
|
# Needed by libnss-resolve config in /etc/nsswitch.conf
|
||||||
systemctl enable systemd-resolved
|
systemctl enable systemd-resolved
|
||||||
EOF
|
EOF
|
||||||
|
2
.zshrc
2
.zshrc
@ -319,6 +319,8 @@ function ssh {
|
|||||||
|
|
||||||
# i don't like that systemd by default uses a pager
|
# i don't like that systemd by default uses a pager
|
||||||
export SYSTEMD_PAGER=''
|
export SYSTEMD_PAGER=''
|
||||||
|
# Minio CLI is also stupid
|
||||||
|
export MC_DISABLE_PAGER=1
|
||||||
|
|
||||||
# set man max width
|
# set man max width
|
||||||
export MANWIDTH=80
|
export MANWIDTH=80
|
||||||
|
Loading…
x
Reference in New Issue
Block a user