Skip to content

Instantly share code, notes, and snippets.

View 89luca89's full-sized avatar

Luca Di Maio 89luca89

View GitHub Profile
@89luca89
89luca89 / podman-to-rootfs.sh
Created February 10, 2023 21:17
Simple script to pull an image and unpack it in a chrootable rootfs
#!/bin/sh
#
if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "help" ] ||
[ -z $1 ] || [ -z $2 ]; then
echo "Usage:"
echo " $0 registry/image:tag /path/to/output"
exit 0
fi
@89luca89
89luca89 / microos-config-status.sh
Last active November 13, 2023 15:05
This script will compare current /etc/ on a system with the "initial" one of a fresh install of the same system.
#!/bin/sh
set -o errexit
set -o nounset
if [ "$EUID" -ne 0 ]; then
sudo "$0" "$@"
exit
fi
@89luca89
89luca89 / microos-status.sh
Last active November 13, 2023 15:05
This script will compare current package list on a system with the "ideal" one of a fresh install of the same system.
#!/bin/bash
if [ "$EUID" -ne 0 ]; then
sudo "$0" "$@"
exit
fi
GREEN='\033[1m\033[32m'
YELLOW='\033[1m\033[33m'
CLEAR='\033[0m'
#!/usr/bin/env python3
import dbus
import dbus.mainloop.glib
from dbus.mainloop.glib import DBusGMainLoop
from gi.repository import GLib
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
@89luca89
89luca89 / rebootmgr_notify.go
Created May 5, 2022 11:36
Example notification daemon for rebootmgr notify strategy
package main
import (
"io"
"log"
"net"
"os"
"reflect"
"strconv"
@89luca89
89luca89 / distrobox-terminal-profile.sh
Last active January 9, 2024 17:49
Create gnome-terminal profile + gnome shortcut for distroboxes
#!/bin/sh
# SPDX-License-Identifier: GPL-3.0-only
#
# This file is part of the distrobox project:
# https://github.com/89luca89/distrobox
#
# Copyright (C) 2021 distrobox contributors
#
# distrobox is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3
@89luca89
89luca89 / install_powersave.sh
Last active January 21, 2023 20:11
Powersave Rules for Linux | Run and reboot. Consider using the commented tweaks in grub for advanced powersaving
#UDEV rules to handle powersaving
# pcie_aspm=force IN GRUB
echo '
# Some logging
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/bin/sh -c '"'"'echo Unplugged $(date) >> /var/log/powerlog.log'"'"'"
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/bin/sh -c '"'"'echo Plugged $(date) >> /var/log/powerlog.log'"'"'"
# CPU Bias power/performance toggle
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/usr/bin/x86_energy_perf_policy power"
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/usr/bin/x86_energy_perf_policy performance"
# Periferals power saving features
@89luca89
89luca89 / tmate-daemon.sh
Last active November 4, 2020 20:34
Simple daemon to use tmate to control a remote machine behind NAT. Uses tmate to generate sessions and save them in a cloud-sync provider folder (ex Dropbox or GDrive)
#!/bin/bash
IP=$(ip a s wlp3s0 | grep inet | awk '{print $2}' | head -n 1)
while true; do
ping -q -w 1 -c 1 `ip r | grep default | awk '{print $3}'` > /dev/null
# No internet connection
if (( $? != 0 )); then
sleep 20s
ping -q -w 1 -c 1 `ip r | grep default | awk '{print $3}'` > /dev/null
if (( $? != 0 )); then
@89luca89
89luca89 / tmux-manager.sh
Last active December 17, 2017 09:55
Manager for tmux sessions
#!/bin/bash
# abort if we're already inside a TMUX session
if [ ! -z "$TMUX" ]; then
unset TMUX
fi
# startup a "default" session if non currently exists
# tmux has-session -t _default || tmux new-session -s _default -d
@89luca89
89luca89 / backup-data.sh
Last active January 24, 2018 22:31
Simple Backup utility, recognizing where to backup and (according to partition space) what profile to use
#!/bin/bash
ssh_backup() {
echo "What's the IP address?"
read IP
echo "What's the port?"
read port
SSH="ssh -p $port"
DIR=$IP":/home/"$USERNAME;