Skip to content

Instantly share code, notes, and snippets.

@rifatx
rifatx / clean-gcr-images.sh
Last active May 30, 2018 12:58
shell script to clean all but last N images in gcr
#!/bin/bash
repoAddress="xx.gcr.io/xXx"
repos=$(gcloud container images list --format='table[no-heading](name:sort=1)' --repository=repoAddress)
while read -r repo; do
images=$(gcloud container images list-tags --limit=99999 --sort-by=~timestamp --format='get(digest)' $repo)
n=10
while read -r image; do
if (( n < 1 )); then
gcloud container images delete --quiet "$repo@$image"
fi;
@rifatx
rifatx / sdcard.sh
Last active May 23, 2018 11:15
sd card backup, restore and partition resize
#backup
dd bs=4M if=/dev/sdb | gzip > sdcard.gz
#restore
gzip -dc sdcard.gz | dd bs=4M of=/dev/sdb
#recreate partition
fdisk
p
# note start sector of partition 2 -> start
@rifatx
rifatx / btaudioautoconnect.sh
Last active May 4, 2024 15:16
raspi osmc setup and autoconnect to alsa:default bt speaker
#!/bin/bash
# tweaked from https://gist.github.com/mitchese/7a3373132f94fc946b1cbeb2b04e7818
USER="kodi-user"
PASSWORD="kodi-pass"
PORT="8080"
ANALOGUEDEVICE="ALSA:sysdefault:CARD=Headphones"
BTDEVICE="ALSA:bluealsa"
STAT="NA"
async buildConsumers() {
const path = Path.resolve(__dirname + '/../../../Consumers');
if (FS.existsSync(path)) {
const consumers = Object.values(RequireAll({
dirname: path,
recursive: false
})).map(consumer => consumer.default);
# enable ssh on initial boot
touch ssh
# ssh public key setup
mkdir -p ./home/pi/.ssh
cat << EOF > ./home/pi/.ssh/authorized_keys
# --- BEGIN PVE ---
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEApHSlBYGanB/nObsWYIZXF7kcT9Sa2oATwdnNqkb+K/8P3MRLY67g1Ki1yhATpqkPhGrwie5wa60+5T2WpVAyeQ4GzxHVZ9Vjk64Wmc/2yabq4LZRnw+9uZvH2Wx5UlMkOJM2trKYZof6pdz/n044BVihZnFQfWnTYg8vKlKKtFsL0sGKz+DWBgr49fldj4qUB6Nmn5M7+4RqYAAd3af+6ljOSCv4NG2r1ZbMRcBW89569/msPcfQYcBzVXXeC5Z+7o5Svk/10pzUaT6P09Kyz8j6T8iy/T+ugsYZ4Se3l2SRtnAFsd2AJMu6kHp5vaqNOZbnJLuAvbQVp+NL/KI88GZbGNZnua1C/L2zLwarpdZw27NgOJRc4U2sNVPI9qWlXNAPPkpVmpbQvX7gem0BmQdoTgYU6nXexTzGDlSX5yCc13i+xeIJKOf0cCLRse3JLD1fxefqlr2HqlH3cx1ISl0T4Pcj+8QuWAVmAASRaR6+ij31nArIAnPmvAGFDvrfa4Tp6AYQNxmjrqyMBrO0r6NpwbHwKzEsYBoAKjuQTBeE5E+mAPpJWOF+tVZlLPuWZyI1IfPIluVgOnSJ/F1iC4MhAFVZ+bUiQl2p2cUEL2Qzajzm9CfAABIDHSj/piqkv2+8xVbkDn0qtM21q1nMbJnxu0gFqUyVZtE1Vz+VXy0= rifat.aricanli@gmail.com
# --- END PVE ---
EOF