migrate snippets

This commit is contained in:
genofire 2020-09-27 13:34:59 +02:00
parent 35cfafd3f7
commit f3199ba7b3
2 changed files with 117 additions and 0 deletions

103
ubuntu-ssh-crypt.sh.md Normal file
View File

@ -0,0 +1,103 @@
#!/bin/sh
# location: /etc/initramfs-tools/hooks/crypt_unlock.sh
PREREQ="dropbear"
prereqs() {
echo "$PREREQ"
}
case "$1" in
prereqs)
prereqs
exit 0
;;
esac
. "${CONFDIR}/initramfs.conf"
. /usr/share/initramfs-tools/hook-functions
if [ "${DROPBEAR}" != "n" ] && [ -r "/etc/crypttab" ] ; then
cat > "${DESTDIR}/bin/unlock" << EOF
#!/bin/sh
if PATH=/lib/unlock:/bin:/sbin /scripts/local-top/cryptroot; then
kill \`ps | grep cryptroot | grep -v "grep" | awk '{print \$1}'\`
# following line kill the remote shell right after the passphrase has
# been entered.
kill -9 \`ps | grep "\-sh" | grep -v "grep" | awk '{print \$1}'\`
exit 0
fi
exit 1
EOF
chmod 755 "${DESTDIR}/bin/unlock"
mkdir -p "${DESTDIR}/lib/unlock"
cat > "${DESTDIR}/lib/unlock/plymouth" << EOF
#!/bin/sh
[ "\$1" == "--ping" ] && exit 1
/bin/plymouth "\$@"
EOF
chmod 755 "${DESTDIR}/lib/unlock/plymouth"
echo To unlock root-partition run "unlock" >> ${DESTDIR}/etc/motd
# ---
#!/bin/sh
# location: /usr/share/initramfs-tools/scripts/init-bottom/dropbear.sh
PREREQ=""
prereqs() {
echo "$PREREQ"
}
case "$1" in
prereqs)
prereqs
exit 0
;;
esac
. /scripts/functions
[ -r /var/run/dropbear.pid ] || exit 0
log_begin_msg "Stopping dropbear"
kill `cat /var/run/dropbear.pid`
ip addr flush dev eth0;
ip link set down eth0;
log_end_msg
# ----
# location: /etc/initramfs-tools/scripts/local-top/mount-boot.sh
PREREQ="udev devpts"
prereqs() {
echo "$PREREQ"
}
case "$1" in
prereqs)
prereqs
exit 0
;;
esac
. /scripts/functions
# 195.9.250.36 is the local static IP
# 76.9.158.210/32 ist the gateway
ip address add 195.9.250.36 peer 76.9.158.210/32 brd 255.255.255.255 dev eth0;
ip link set up eth0;
ip route add 76.9.158.210 src 195.9.250.36 dev eth0;
ip route add default via 76.9.158.210 dev eth0;
ip addr;
ip route;

14
update-git.sh Normal file
View File

@ -0,0 +1,14 @@
#!/bin/sh
if [[ ! -z "$(git status --porcelain --ignore-submodules -unormal)" ]]; then
echo "[bot] commit dirty changes"
git commit -m "bot update" -a
fi
if [[ "$(git rev-list --left-right --count HEAD...@'{u}' | cut -f2 )" != "0" ]]; then
echo "[bot] fetch current version"
git pull --rebase
fi
if [[ "$(git rev-list --left-right --count HEAD...@'{u}' | cut -f1 )" != "0" ]]; then
echo "[bot] push commits"
git remote | xargs -L1 git push --all
fi