Compare commits
9 Commits
683a358096
...
eba4a86db4
| Author | SHA1 | Date |
|---|---|---|
|
|
eba4a86db4 | |
|
|
ac05262eba | |
|
|
3fc3be44e2 | |
|
|
c97a391d87 | |
|
|
bd5b513a69 | |
|
|
9fa1e37d93 | |
|
|
7b6023d8d8 | |
|
|
f0a82d4b8e | |
|
|
89efbba240 |
|
|
@ -1,7 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
# NEWARG="processor.ignore_ppc=1"
|
||||
NEWARG="consoleblank=3"
|
||||
sed -i -E "s|^(GRUB_CMDLINE_LINUX_DEFAULT=\"[^\"]*)\"|\1 ${NEWARG}\"|" /etc/default/grub
|
||||
update_grub
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# the screen will blank after 3 minutes of inactivity on the TTY console.
|
||||
NEWARG="consoleblank=3"
|
||||
sudo sed -i -E "s|^(GRUB_CMDLINE_LINUX_DEFAULT=\"[^\"]*)\"|\1 ${NEWARG}\"|" /etc/default/grub
|
||||
sudo update_grub
|
||||
|
|
@ -10,8 +10,9 @@
|
|||
# then modify “/etc/default/grub” as below:
|
||||
|
||||
## Docker likes kernel swappiness support (on reboot)
|
||||
bash -c "$(perl -p -i -e 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="cgroup_enable=memory"/g' /etc/default/grub)"
|
||||
sudo bash -c "perl -i -pe 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"/g' /etc/default/grub"
|
||||
|
||||
sudo update-grub
|
||||
# Now that your server supports swap limit capabilities in your docker run command you can use --memory-swappiness=0 and set --memory-swap equal to --memory. You also need to set -Des.bootstrap.mlockall=true on the docker run commandline.
|
||||
|
||||
# eg.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Set ignore bios throttling on the kernel commandline
|
||||
NEWARG="processor.ignore_ppc=1"
|
||||
sudo sed -i -E "s|^(GRUB_CMDLINE_LINUX_DEFAULT=\"[^\"]*)\"|\1 ${NEWARG}\"|" /etc/default/grub
|
||||
sudo update_grub
|
||||
|
|
@ -5,4 +5,7 @@ apt install -y util-linux sysvinit-utils
|
|||
apt install -y initscripts openrc
|
||||
|
||||
# Reboot when done
|
||||
for file in /etc/rc0.d/K*; do s=`basename $(readlink "$file")` ; /etc/init.d/$s stop; done
|
||||
for file in /etc/rc0.d/K*; do
|
||||
s=$(basename $(readlink "$file"))
|
||||
/etc/init.d/$s stop
|
||||
done
|
||||
|
|
|
|||
10
020_grc.sh
10
020_grc.sh
|
|
@ -1,18 +1,18 @@
|
|||
#!/usr/bin/env bash
|
||||
sudo apt install -y grc
|
||||
sudo apt install -y grc bat
|
||||
|
||||
DEST=${1:-/etc/skel}
|
||||
ALIAS_DIR=".zsh_aliases.d"
|
||||
ALIAS_HOME=${DEST}/${ALIAS_DIR}/
|
||||
ALIAS_HOME=${DEST}/${ALIAS_DIR}
|
||||
ALIAS_FILE=${ALIAS_HOME}/003_grc.sh
|
||||
|
||||
mkdir -p ${ALIAS_HOME}
|
||||
mkdir -p "${ALIAS_HOME}"
|
||||
|
||||
cat > ${ALIAS_FILE} <<'EOF'
|
||||
cat >"${ALIAS_FILE}" <<'EOF'
|
||||
# coloured output using grc
|
||||
if [ -e /usr/bin/grc ]; then
|
||||
alias cl="/usr/bin/grc -es --colour=auto"
|
||||
alias cat="cl cat"
|
||||
alias cat="bat -p"
|
||||
alias ping="cl ping"
|
||||
alias netstat="cl netstat"
|
||||
alias traceroute="cl traceroute"
|
||||
|
|
|
|||
|
|
@ -1,37 +1,55 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
DEST=${1:-/etc/skel}
|
||||
# Install lazycommit
|
||||
go install github.com/m7medvision/lazycommit@latest
|
||||
# go install github.com/m7medvision/lazycommit@latest
|
||||
|
||||
# Add Go bin directory to PATH if it doesn't exist
|
||||
if ! echo "$PATH" | grep -q "$(go env GOPATH)/bin"; then
|
||||
mkdir -p "${HOME}/.zshrc.d"
|
||||
|
||||
# Write the PATH export with proper escaping
|
||||
cat >"${HOME}/.zshrc.d/008_lazycommit.zsh" <<'EOF'
|
||||
# Add Go binaries to PATH
|
||||
export PATH="${PATH}:${HOME}/go/bin"
|
||||
EOF
|
||||
|
||||
# Source the new file
|
||||
source "${HOME}/.zshrc.d/008_lazycommit.zsh"
|
||||
fi
|
||||
# # Add once – usually already present if you installed Go via official method
|
||||
# if [[ ":$PATH:" != *":$HOME/go/bin:"* ]]; then
|
||||
# echo 'export PATH="$HOME/go/bin:$PATH"' >> ~/.zshrc
|
||||
# export PATH="$HOME/go/bin:$PATH"
|
||||
# fi
|
||||
|
||||
# Create the configuration directory
|
||||
mkdir -p "${HOME}/.config/.lazycommit"
|
||||
# LAZYCOMMIT_HOME=${DEST}/.config/
|
||||
# mkdir -p "${LAZYCOMMIT_HOME}/lazycommit"
|
||||
|
||||
# Create the configuration file with default settings
|
||||
cat >"${HOME}/.config/.lazycommit.yaml" <<'EOF'
|
||||
active_provider: copilot
|
||||
cat >"${DEST}/.config/.lazycommit.yaml" <<'EOF'
|
||||
active_provider: anthropic # default is copilot if a GitHub token is found
|
||||
providers:
|
||||
copilot:
|
||||
api_key: "$GITHUB_TOKEN"
|
||||
model: "gpt-4o"
|
||||
api_key: "$GITHUB_TOKEN" # Uses GitHub token; token is exchanged internally
|
||||
model: "gpt-4o" # or "openai/gpt-4o"; both accepted
|
||||
# endpoint_url: "https://api.githubcopilot.com" # Optional - uses default if not specified
|
||||
openai:
|
||||
api_key: "$OPENAI_API_KEY"
|
||||
model: "gpt-4o"
|
||||
# endpoint_url: "https://api.openai.com/v1" # Optional - uses default if not specified
|
||||
anthropic:
|
||||
model: "claude-haiku-4-5" # Uses Claude Code CLI - no API key needed
|
||||
num_suggestions: 10 # Number of commit suggestions to generate
|
||||
EOF
|
||||
|
||||
# Prompt templates and message configurations.
|
||||
cat >"${DEST}/.config/.lazycommit.prompts.yaml" <<EOF
|
||||
language: English # commit message language (e.g., "English", "Arabic", "Korean")
|
||||
system_message: "You are a helpful assistant that generates git commit messages, and pull request titles."
|
||||
commit_message_template: "Based on the following git diff, generate 10 conventional commit messages. Each message should be on a new line, without any numbering or bullet points:\n\n%s"
|
||||
pr_title_template: "Based on the following git diff, generate 10 pull request title suggestions. Each title should be on a new line, without any numbering or bullet points:\n\n%s"
|
||||
EOF
|
||||
|
||||
# NB We use ${HOME}/.config/lazygit/extras for extending the lazygit/config.yml
|
||||
# # ~/.config/lazygit/
|
||||
# ├── config.yml # minimal base + includes comment explaining the rest
|
||||
# └── extras/
|
||||
# ├── 01-theme.yml
|
||||
# ├── 10-editor-nvim.yml
|
||||
# ├── 20-custom-commands-ai.yml
|
||||
# └── 30-pager-delta.yml
|
||||
# then:
|
||||
## In ~/.zshrc or similar
|
||||
# alias lg='LG_CONFIG_FILE=$$ (ls -1 ~/.config/lazygit/extras/*.yml | tr "\n" "," | sed "s/, $$//"),~/.config/lazygit/config.yml lazygit'
|
||||
# Add custom command to lazygit: ${HOME}/.config/lazygit/config.yml
|
||||
#
|
||||
# customCommands:
|
||||
|
|
@ -49,11 +67,66 @@ EOF
|
|||
# valueFormat: "{{ .message }}"
|
||||
# labelFormat: "{{ .number }}: {{ .message | green }}"
|
||||
|
||||
yq e -i '.customCommands += [{"key": "<c-a>", "description": "Pick AI commit", "context": "files", "subprocess": true, "loadingText": "Generating commit message...", "prompts": [{"type": "menuFromCommand", "title": "AI Generated Commits", "key": "Msg", "command": "bunx @m7medvision/lazycommit@latest --list", "filter": "^(?P<number>\\d+)\\.\\s(?P<message>.+)$", "valueFormat": "{{ .message }}", "labelFormat": "{{ .number }}: {{ .message | green }}"}], "command": "echo \"{{index .PromptResponses 0}}\" > .git/COMMIT_EDITMSG && nvim .git/COMMIT_EDITMSG && if [ -s .git/COMMIT_EDITMSG ]; then git commit -F .git/COMMIT_EDITMSG; else echo \"Commit message is empty, commit aborted.\" && rm .git/COMMIT_EDITMSG; fi"}]' ${HOME}/.config/lazygit/config.yml
|
||||
# Check for the the existance of lazygit config.yml
|
||||
|
||||
# yq e -i '.customCommands += [{"key": "<c-a>", "description": "Pick AI commit", "context": "files", "subprocess": true, "loadingText": "Generating commit message...", "prompts": [{"type": "menuFromCommand", "title": "AI Generated Commits", "key": "Msg", "command": "bunx @m7medvision/lazycommit@latest --list", "filter": "^(?P<number>\\d+)\\.\\s(?P<message>.+)$", "valueFormat": "{{ .message }}", "labelFormat": "{{ .number }}: {{ .message | green }}"}], "command": "echo \"{{index .PromptResponses 0}}\" > .git/COMMIT_EDITMSG && nvim .git/COMMIT_EDITMSG && if [ -s .git/COMMIT_EDITMSG ]; then git commit -F .git/COMMIT_EDITMSG; else echo \"Commit message is empty, commit aborted.\" && rm .git/COMMIT_EDITMSG; fi"}]' \
|
||||
# "${HOME}/.config/lazygit/config.yml"
|
||||
|
||||
# Write a confguration for lazycommmit in lazygit.
|
||||
CONFIG_ROOT="${DEST}/.config/lazygit"
|
||||
EXTRAS_DIR="${CONFIG_ROOT}/extras"
|
||||
mkdir -p "${EXTRAS_DIR}"
|
||||
|
||||
conf_print_LC_LD-Config() {
|
||||
cat <<'EOF'
|
||||
customCommands:
|
||||
# Quick commit without editing (direct accept)
|
||||
- key: "<c-a>"
|
||||
description: "Pick AI commit & commit immediately"
|
||||
context: "files"
|
||||
loadingText: "Generating commit suggestions..."
|
||||
subprocess: true
|
||||
command: 'git commit -m "{{.Form.Msg}}"'
|
||||
prompts:
|
||||
- type: "menuFromCommand"
|
||||
title: "AI Generated Commits"
|
||||
key: "Msg"
|
||||
command: "lazycommit commit"
|
||||
filter: '^(?P<raw>.+)$'
|
||||
valueFormat: "{{ .raw }}"
|
||||
labelFormat: "{{ .raw | green }}"
|
||||
|
||||
# Edit before commit (your original style, but updated)
|
||||
- key: "<c-b>"
|
||||
description: "Pick AI commit (edit before commit)"
|
||||
context: "files"
|
||||
loadingText: "Generating commit suggestions..."
|
||||
subprocess: true
|
||||
command: |
|
||||
bash -c 'msg="{{.Form.Msg}}"
|
||||
echo "$msg" > .git/COMMIT_EDITMSG
|
||||
${EDITOR:-nvim} .git/COMMIT_EDITMSG
|
||||
if [ -s .git/COMMIT_EDITMSG ]; then
|
||||
git commit -F .git/COMMIT_EDITMSG
|
||||
else
|
||||
echo "Commit message empty → aborted."
|
||||
rm -f .git/COMMIT_EDITMSG
|
||||
fi'
|
||||
prompts:
|
||||
- type: "menuFromCommand"
|
||||
title: "AI Generated Commits"
|
||||
key: "Msg"
|
||||
command: "lazycommit commit"
|
||||
filter: '^(?P<raw>.+)$'
|
||||
valueFormat: "{{ .raw }}"
|
||||
labelFormat: "{{ .raw | green }}"
|
||||
EOF
|
||||
}
|
||||
conf_print_LC_LD-Config | tee "${EXTRAS_DIR}/20-lazycommit.yml"
|
||||
|
||||
# Verify the installation
|
||||
echo "Current PATH entries:"
|
||||
echo "$PATH" | tr ':' '\n' | grep '/go/bin'
|
||||
|
||||
# Test lazycommit
|
||||
lazycommit commit
|
||||
# lazycommit commit
|
||||
|
|
|
|||
314
020_sanoid.sh
314
020_sanoid.sh
|
|
@ -21,6 +21,10 @@ cat <<-EOF
|
|||
CHANGELIST /usr/share/doc/sanoid/changelog
|
||||
EOF
|
||||
|
||||
# Both sanoid and syncoid are oneshot processes so it makes little sense to
|
||||
# provide an init file, cron is just fine. In this case the systemd file is there
|
||||
# because systemd decided to manage cron tasks.
|
||||
#
|
||||
# Cronjob for non-systemd systems: every 15 minutes.
|
||||
# If you require a different interval, you will need to disable the
|
||||
# timer or the cron job according to your system configuration.
|
||||
|
|
@ -48,17 +52,43 @@ sudo mkdir -p /etc/sanoid/
|
|||
|
||||
conf_print_sanoid() {
|
||||
cat <<-EOF
|
||||
#-- Organisational datasets
|
||||
# DATA
|
||||
[rpool/DATA]
|
||||
use_template = ignore
|
||||
recursive = yes
|
||||
process_children_only = yes
|
||||
|
||||
# ROOT
|
||||
[rpool/ROOT]
|
||||
use_template = ignore
|
||||
recursive = yes
|
||||
process_children_only = yes
|
||||
|
||||
#-- END
|
||||
|
||||
# These datasets contain the docker zsh backing store "graph" (layers).
|
||||
# Just restore broken container with docker-compose down && docker-compose up
|
||||
[rpool/docker]
|
||||
use_template = ignore
|
||||
recursive = yes
|
||||
|
||||
# Docker persistent data
|
||||
[rpool/DATA/docker-volumes]
|
||||
use_template = docker-persistent
|
||||
recursive = yes
|
||||
|
||||
[rpool/archive]
|
||||
use_template = ignore
|
||||
recursive = yes
|
||||
|
||||
[rpool/swap]
|
||||
use_template = ignore
|
||||
recursive = yes
|
||||
|
||||
[rpool/tmp]
|
||||
use_template = ignore
|
||||
recursive = yes
|
||||
|
||||
[rpool/ROOT/devuan-1]
|
||||
use_template = root
|
||||
|
|
@ -74,9 +104,9 @@ conf_print_sanoid() {
|
|||
# Specific override for Virtual Machines to use scripts
|
||||
[rpool/ROOT/devuan-1/var_lib_virt]
|
||||
use_template = root
|
||||
recursive = no
|
||||
pre_snapshot_script = /usr/local/bin/virt-freeze-all.sh
|
||||
post_snapshot_script = /usr/local/bin/virt-thaw-all.sh
|
||||
recursive = yes
|
||||
pre_snapshot_script = /usr/local/bin/sanoid_virt-freeze-all.sh
|
||||
post_snapshot_script = /usr/local/bin/sanoid_virt-thaw-all.sh
|
||||
|
||||
# -- User Data --
|
||||
[rpool/home]
|
||||
|
|
@ -113,6 +143,28 @@ conf_print_sanoid() {
|
|||
autosnap = no
|
||||
monitor = no
|
||||
|
||||
##############################
|
||||
# Docker Persistent Template #
|
||||
##############################
|
||||
[template_docker-persistent]
|
||||
# Frequent snapshots for active databases/configs
|
||||
frequently = 0
|
||||
hourly = 24
|
||||
daily = 7
|
||||
monthly = 1
|
||||
yearly = 0
|
||||
|
||||
# Safety checks
|
||||
autosnap = yes
|
||||
autoprune = yes
|
||||
|
||||
# Don't take a snapshot if the dataset hasn't changed
|
||||
# (Saves metadata overhead)
|
||||
# skip_hourless = yes
|
||||
pre_snapshot_script = /usr/local/bin/sanoid_zfs-skip-empty.sh
|
||||
|
||||
#-- END
|
||||
|
||||
[template_backup]
|
||||
autoprune = yes
|
||||
frequently = 0
|
||||
|
|
@ -134,11 +186,14 @@ conf_print_sanoid() {
|
|||
daily_warn = 48
|
||||
daily_crit = 60
|
||||
|
||||
#-- END
|
||||
|
||||
[template_hotspare]
|
||||
autoprune = yes
|
||||
frequently = 0
|
||||
hourly = 30
|
||||
daily = 90
|
||||
weekly = 4
|
||||
monthly = 3
|
||||
yearly = 0
|
||||
|
||||
|
|
@ -154,177 +209,82 @@ conf_print_sanoid() {
|
|||
hourly_crit = 6h
|
||||
daily_warn = 2d
|
||||
daily_crit = 4d
|
||||
|
||||
[template_scripts]
|
||||
### information about the snapshot will be supplied as environment variables,
|
||||
### see the README.md file for details about what is passed when.
|
||||
### run script before snapshot
|
||||
pre_snapshot_script = /path/to/script.sh
|
||||
### run script after snapshot
|
||||
post_snapshot_script = /path/to/script.sh
|
||||
### run script before pruning snapshot
|
||||
pre_pruning_script = /path/to/script.sh
|
||||
### run script after pruning snapshot
|
||||
pruning_script = /path/to/script.sh
|
||||
### don't take an inconsistent snapshot (skip if pre script fails)
|
||||
#no_inconsistent_snapshot = yes
|
||||
### run post_snapshot_script when pre_snapshot_script is failing
|
||||
#force_post_snapshot_script = yes
|
||||
### limit allowed execution time of scripts before continuing (<= 0: infinite)
|
||||
script_timeout = 5
|
||||
EOF
|
||||
}
|
||||
conf_print_sanoid | sudo tee /etc/sanoid/sanoid.conf
|
||||
|
||||
# Both sanoid and synmcoid are oneshot processes so it makes little sense to
|
||||
# provide an init file, cron is just fine. In this case the systemd file is there
|
||||
# because systemd decided to manage cron tasks.
|
||||
# Generated using:
|
||||
# https://raw.githubusercontent.com/akhilvij/systemd-to-sysvinit-converter/master/converter.py
|
||||
# python2 converter /usr/src/sanoid-2.2.0/sanoid.service > sanoid
|
||||
conf_print_sanoid_init() {
|
||||
cat <<-'EOF'
|
||||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: sanoid
|
||||
# Required-Start: $syslog $local_fs $remote_fs
|
||||
# Required-Stop: $syslog $local_fs $remote_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Snapshot ZFS filesystems
|
||||
### END INIT INFO
|
||||
########################
|
||||
# Pre-snapshot scripts #
|
||||
########################
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
prog=sanoid
|
||||
PIDFILE=/var/run/$prog.pid
|
||||
DESC="Snapshot ZFS filesystems"
|
||||
start() {
|
||||
log_daemon_msg "Starting $DESC" "$prog"
|
||||
start_daemon -p $PIDFILE /usr/sbin/sanoid --take-snapshots --verbose
|
||||
if [ $? -ne 0 ]; then
|
||||
log_end_msg 1
|
||||
exit 1
|
||||
fi
|
||||
if [ $? -eq 0 ]; then
|
||||
log_end_msg 0
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
# In ZFS, even if no data has changed, creating a snapshot still consumes a
|
||||
# small amount of space for metadata and adds an entry to the ZFS history.
|
||||
# If you have hundreds of datasets being snapshotted every 15 minutes, this
|
||||
# "metadata bloat" can make commands like zfs list -t snapshot feel sluggish
|
||||
# over time. If you think this is an issue for ypu use zfs-skip-empty.sh as
|
||||
# a pre_snapshot_script
|
||||
conf_print_skip_empty() {
|
||||
cat <<'EOF'
|
||||
#!/bin/bash
|
||||
|
||||
stop() {
|
||||
log_daemon_msg "Stopping $DESC" "$prog"
|
||||
killproc -p $PIDFILE /usr/sbin/sanoid
|
||||
if [ $? -ne 0 ]; then
|
||||
log_end_msg 1
|
||||
exit 1
|
||||
fi
|
||||
if [ $? -eq 0 ]; then
|
||||
log_end_msg 0
|
||||
fi
|
||||
}
|
||||
# Usage: ./sanoid-threshold.sh <dataset> <threshold_size>
|
||||
# or
|
||||
# Add this to you /etc/sanoid.conf to fire this script.
|
||||
|
||||
force_reload() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
# [tank/important_data]
|
||||
# use_template = production
|
||||
# # Only snapshot if more than 5MB changed
|
||||
# pre_snapshot_script = /usr/local/bin/sanoid-threshold.sh 5M
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
force-reload)
|
||||
force_reload
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
DATASET=$1
|
||||
RAW_THRESHOLD=$2
|
||||
|
||||
*)
|
||||
echo "$Usage: $prog {start|stop|force-reload|restart}"
|
||||
exit 2
|
||||
convert_to_bytes() {
|
||||
local number=$(echo "$1" | grep -oE '^[0-9.]+')
|
||||
local unit=$(echo "$1" | grep -oI '[KMGPT]' | tr '[:lower:]' '[:upper:]')
|
||||
|
||||
case "$unit" in
|
||||
K) awk "BEGIN { printf \"%.0f\", $number * 1024 }" ;;
|
||||
M) awk "BEGIN { printf \"%.0f\", $number * 1024^2 }" ;;
|
||||
G) awk "BEGIN { printf \"%.0f\", $number * 1024^3 }" ;;
|
||||
T) awk "BEGIN { printf \"%.0f\", $number * 1024^4 }" ;;
|
||||
*) printf "%.0f" "$number" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
if [[ -z "$DATASET" || -z "$RAW_THRESHOLD" ]]; then
|
||||
logger -t sanoid "Threshold Error: Usage: $0 <dataset> <threshold>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! zfs list -H "$DATASET" >/dev/null 2>&1; then
|
||||
logger -t sanoid "Threshold Error: Dataset $DATASET not found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
THRESHOLD=$(convert_to_bytes "$RAW_THRESHOLD")
|
||||
WRITTEN_BYTES=$(zfs get -Hp -o value written "$DATASET")
|
||||
|
||||
if [[ "$WRITTEN_BYTES" -lt "$THRESHOLD" ]]; then
|
||||
WRITTEN_HUMAN=$(zfs get -H -o value written "$DATASET")
|
||||
# Optional: Comment out the logger below if your logs get too noisy
|
||||
logger -t sanoid "Skipping $DATASET: Written $WRITTEN_HUMAN < Threshold $RAW_THRESHOLD."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
EOF
|
||||
}
|
||||
# Sandoid doesn't ran as a daemon it runs vi cron
|
||||
# conf_print_sanoid_init | sudo tee /etc/init.d/sanoid
|
||||
# sudo chmod +x /etc/init.d/sanoid
|
||||
conf_print_skip_hourless | sudo tee /usr/local/bin/sanoid_zfs-skip-empty.sh
|
||||
|
||||
# Generated using:
|
||||
# https://raw.githubusercontent.com/akhilvij/systemd-to-sysvinit-converter/master/converter.py
|
||||
# python2 converter /usr/src/sanoid-2.2.0/sanoid-prune.service > sanoid-prune
|
||||
conf_print_sanoid-prune_init() {
|
||||
cat <<-'EOF'
|
||||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: sanoid-prune
|
||||
# Required-Start: $syslog $local_fs $remote_fs
|
||||
# Required-Stop: $syslog $local_fs $remote_fs
|
||||
# Short-Description: Prune ZFS snapshots
|
||||
### END INIT INFO
|
||||
chmod +x /usr/local/bin/sanoid_zfs-skip-empty.sh
|
||||
# VM Consistency (The "Freeze/Thaw" Logic)
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
prog=sanoid-prune
|
||||
PIDFILE=/var/run/$prog.pid
|
||||
DESC="Prune ZFS snapshots"
|
||||
start() {
|
||||
log_daemon_msg "Starting $DESC" "$prog"
|
||||
start_daemon -p $PIDFILE /usr/sbin/sanoid --prune-snapshots --verbose
|
||||
if [ $? -ne 0 ]; then
|
||||
log_end_msg 1
|
||||
exit 1
|
||||
fi
|
||||
if [ $? -eq 0 ]; then
|
||||
log_end_msg 0
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
|
||||
stop() {
|
||||
log_daemon_msg "Stopping $DESC" "$prog"
|
||||
killproc -p $PIDFILE /usr/sbin/sanoid
|
||||
if [ $? -ne 0 ]; then
|
||||
log_end_msg 1
|
||||
exit 1
|
||||
fi
|
||||
if [ $? -eq 0 ]; then
|
||||
log_end_msg 0
|
||||
fi
|
||||
}
|
||||
|
||||
force_reload() {
|
||||
stop
|
||||
start
|
||||
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
force-reload)
|
||||
force_reload
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "$Usage: $prog {start|stop|force-reload|restart}"
|
||||
exit 2
|
||||
esac
|
||||
EOF
|
||||
}
|
||||
# Sandoid doesn't ran as a daemon it runs vi cron
|
||||
# conf_print_sanoid-prune_init | sudo tee /etc/init.d/sanoid-prune
|
||||
# sudo chmod +x /etc/init.d/sanoid-prune
|
||||
# The inclusion of virt-freeze-all.sh and virt-thaw-all.sh to ensure data integrity:
|
||||
# * Pre-snapshot: virsh domfsfreeze tells the Guest OS (via qemu-guest-agent) to flush its write buffers and temporarily pause I/O.
|
||||
# * Snapshot: Sanoid takes an atomic ZFS snapshot.
|
||||
# * Post-snapshot: virsh domfsthaw resumes I/O.
|
||||
# Result: You get an "application-consistent" backup rather than a "crash-consistent" one.
|
||||
|
||||
# Give sudo access to virsh or is part of the libvirt group.
|
||||
# qemu-guest-agent must be running in the vm
|
||||
|
|
@ -341,7 +301,7 @@ if [ -z "$VM_NAME" ]; then
|
|||
fi
|
||||
|
||||
# Check if the VM is running
|
||||
STATE=$(virsh domstate "$VM_NAME" 2>/dev/null)
|
||||
STATE=$(/usr/bin/virsh domstate "$VM_NAME" 2>/dev/null)
|
||||
if [ "$STATE" != "running" ]; then
|
||||
echo "VM $VM_NAME is not running or does not exist. Skipping freeze."
|
||||
exit 0
|
||||
|
|
@ -349,7 +309,7 @@ fi
|
|||
|
||||
echo "Freezing filesystems for $VM_NAME..."
|
||||
# domfsfreeze returns the number of frozen filesystems on success
|
||||
if virsh domfsfreeze "$VM_NAME" > /dev/null; then
|
||||
if /usr/bin/virsh domfsfreeze "$VM_NAME" > /dev/null; then
|
||||
echo "Successfully frozen $VM_NAME."
|
||||
else
|
||||
echo "Error: Failed to freeze $VM_NAME. Ensure qemu-guest-agent is active."
|
||||
|
|
@ -357,8 +317,8 @@ else
|
|||
fi
|
||||
EOF
|
||||
}
|
||||
conf_print_virt_freeze | sudo tee /usr/local/bin/virt-freeze.sh
|
||||
sudo chmod +x /usr/local/bin/virt-freeze.sh
|
||||
conf_print_virt_freeze | sudo tee /usr/local/bin/sanoid_virt-freeze.sh
|
||||
sudo chmod +x /usr/local/bin/sanoid_virt-freeze.sh
|
||||
|
||||
#---
|
||||
|
||||
|
|
@ -375,7 +335,7 @@ if [ -z "$VM_NAME" ]; then
|
|||
fi
|
||||
|
||||
# Check if the VM is running
|
||||
STATE=$(virsh domstate "$VM_NAME" 2>/dev/null)
|
||||
STATE=$(/usr/bin/virsh domstate "$VM_NAME" 2>/dev/null)
|
||||
if [ "$STATE" != "running" ]; then
|
||||
echo "VM $VM_NAME is not running. Skipping unfreeze."
|
||||
exit 0
|
||||
|
|
@ -383,7 +343,7 @@ fi
|
|||
|
||||
echo "Thawing filesystems for $VM_NAME..."
|
||||
# domfsthaw returns the number of thawed filesystems on success
|
||||
if virsh domfsthaw "$VM_NAME" > /dev/null; then
|
||||
if /usr/bin/virsh domfsthaw "$VM_NAME" > /dev/null; then
|
||||
echo "Successfully thawed $VM_NAME."
|
||||
else
|
||||
echo "Error: Failed to thaw $VM_NAME."
|
||||
|
|
@ -391,8 +351,8 @@ else
|
|||
fi
|
||||
EOF
|
||||
}
|
||||
conf_print_virt_unfreeze | sudo tee /usr/local/bin/virt-unfreeze.sh
|
||||
sudo chmod +x /usr/local/bin/virt-unfreeze.sh
|
||||
conf_print_virt_unfreeze | sudo tee /usr/local/bin/sanoid_virt-unfreeze.sh
|
||||
sudo chmod +x /usr/local/bin/sanoid_virt-unfreeze.sh
|
||||
|
||||
#---
|
||||
|
||||
|
|
@ -402,7 +362,7 @@ conf_print_virt_thaw_all() {
|
|||
# /usr/local/bin/virt-thaw-all.sh
|
||||
|
||||
# 1. Get running VM names, filtering out empty lines with awk
|
||||
RUNNING_VMS=$(virsh list --state-running --name | awk 'NF')
|
||||
RUNNING_VMS=$(/usr/bin/virsh list --state-running --name | awk 'NF')
|
||||
|
||||
if [ -z "$RUNNING_VMS" ]; then
|
||||
echo "No running VMs found."
|
||||
|
|
@ -415,11 +375,11 @@ for VM_NAME in $RUNNING_VMS; do
|
|||
|
||||
# Use the native thaw command.
|
||||
# It handles the guest agent communication for you.
|
||||
if virsh domfsthaw "$VM_NAME" > /dev/null 2>&1; then
|
||||
if /usr/bin/virsh domfsthaw "$VM_NAME" > /dev/null 2>&1; then
|
||||
echo "Successfully thawed $VM_NAME."
|
||||
else
|
||||
# If native fails, we capture the error for the user
|
||||
ERROR=$(virsh domfsthaw "$VM_NAME" 2>&1)
|
||||
ERROR=$(/usr/bin/virsh domfsthaw "$VM_NAME" 2>&1)
|
||||
echo "Error thawing $VM_NAME: $ERROR"
|
||||
fi
|
||||
done
|
||||
|
|
@ -427,8 +387,8 @@ done
|
|||
echo "Finished processing all VMs."
|
||||
EOF
|
||||
}
|
||||
conf_print_virt_thaw_all | sudo tee /usr/local/bin/virt-thaw-all.sh
|
||||
sudo chmod +x /usr/local/bin/virt-thaw-all.sh
|
||||
conf_print_virt_thaw_all | sudo tee /usr/local/bin/sanoid_virt-thaw-all.sh
|
||||
sudo chmod +x /usr/local/bin/sanoid_virt-thaw-all.sh
|
||||
|
||||
#---
|
||||
|
||||
|
|
@ -437,7 +397,7 @@ conf_print_virt_freeze-all() {
|
|||
#!/bin/bash
|
||||
|
||||
# 1. Get running VM names, filtering out empty lines
|
||||
RUNNING_VMS=$(virsh list --state-running --name | awk 'NF')
|
||||
RUNNING_VMS=$(/usr/bin/virsh list --state-running --name | awk 'NF')
|
||||
|
||||
if [ -z "$RUNNING_VMS" ]; then
|
||||
echo "No running VMs found."
|
||||
|
|
@ -450,7 +410,7 @@ for VM_NAME in $RUNNING_VMS; do
|
|||
|
||||
# Using the native virsh command is generally cleaner
|
||||
# It returns the number of frozen filesystems on success
|
||||
if virsh domfsfreeze "$VM_NAME" > /dev/null 2>&1; then
|
||||
if /usr/bin/virsh domfsfreeze "$VM_NAME" > /dev/null 2>&1; then
|
||||
echo "Successfully frozen $VM_NAME."
|
||||
else
|
||||
echo "Error: Could not freeze $VM_NAME. Check if QEMU Guest Agent is running."
|
||||
|
|
@ -460,8 +420,8 @@ done
|
|||
echo "Finished processing all VMs."
|
||||
EOF
|
||||
}
|
||||
conf_print_virt_freeze-all | sudo tee /usr/local/bin/virt-freeze-all.sh
|
||||
sudo chmod +x /usr/local/bin/virt-freeze-all.sh
|
||||
conf_print_virt_freeze-all | sudo tee /usr/local/bin/sanoid_virt-freeze-all.sh
|
||||
sudo chmod +x /usr/local/bin/sanoid_virt-freeze-all.sh
|
||||
|
||||
#---
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
# or:
|
||||
## Make ZFS Snapshots work on Debian
|
||||
## A .deb package can be created for zfs-auto-snapshot:
|
||||
apt install -y git build-essential zfsnap
|
||||
apt install -y git build-essential
|
||||
apt install -y zfs-auto-snapshot
|
||||
#ZSH_BUILD_HOME=/var/tmp/zfs-auto-snapshot
|
||||
#mkdir -p ${ZSH_BUILD_HOME} && \
|
||||
|
|
|
|||
|
|
@ -1,120 +1,78 @@
|
|||
#/usr/bin/env bash
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ARCH=$(dpkg --print-architecture)
|
||||
if [[ ${ARCH} == "armhf" ]]; then ARCH="arm-v7"; fi
|
||||
# Config
|
||||
USER="zunit-zsh"
|
||||
PROJECT="zunit"
|
||||
PACKAGE="zsh-zunit"
|
||||
VERSION=$(curl "https://api.github.com/repos/${USER}/${PROJECT}/tags?per_page=5" | jq '[ .[] | select(.name|test("v[[:digit:].]+$"))]|.[0] | .name')
|
||||
DEB_VERSION=$(echo "${VERSION}" | tr -d "\"" | tr -d "v") # strip the preceding 'v'
|
||||
#VERSION="1.0.0"
|
||||
#ARCH=$(dpkg --print-architecture)
|
||||
MACHINE=$(uname -m)
|
||||
OS=$(uname -s)
|
||||
# DEBEMAIL="person@company.tld"
|
||||
# DEBFULLNAME="Testy McTester"
|
||||
# DESCRIPTION="."
|
||||
# LONG_DESCRIPTION=" ."
|
||||
|
||||
RSS_FEED="https://github.com/${USER}/${PROJECT}/releases.atom"
|
||||
# xdg-open ${RSS_FEED}
|
||||
echo ${RSS_FEED}
|
||||
|
||||
EXCLUDES="/root/.wget-hsts"
|
||||
|
||||
REQUIRES="zsh"
|
||||
BUILD_DIR=/var/tmp/build_zunit
|
||||
ARCH=$(dpkg --print-architecture)
|
||||
if [[ ${ARCH} == "armhf" ]]; then ARCH="arm-v7"; fi
|
||||
|
||||
## Checkinstall variables - see defaults in /etc/checkinstallrc
|
||||
# DOC_DIR=/usr/share/doc
|
||||
# Get latest version from GitHub API (returns "v0.8.2" with quotes)
|
||||
VERSION_JSON=$(curl -s "https://api.github.com/repos/${USER}/${PROJECT}/tags?per_page=1")
|
||||
VERSION=$(echo "${VERSION_JSON}" | jq -r '.[0].name // "v0.8.2"') # fallback
|
||||
DEB_VERSION=${VERSION#v} # → 0.8.2
|
||||
|
||||
# make a new temporary directory for this use to avoid permission issues.
|
||||
BASE_TMP_DIR=~/tmptmp/checkinstall_tmp
|
||||
#-------------------------------------------------------------------------------
|
||||
RELEASE="1" # ← you need to define this (debian revision)
|
||||
LATEST_URL="https://github.com/${USER}/${PROJECT}"
|
||||
|
||||
## Create and populate the install scripts and documentation for checkinstall
|
||||
cat <<-EOF | tee ${BUILD_DIR}/description-pak
|
||||
ZUnit is a powerful unit testing framework for ZSH
|
||||
BUILD_DIR="/var/tmp/build_zunit"
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
cd "${BUILD_DIR}"
|
||||
|
||||
# Optional: better maintainer info
|
||||
export DEBFULLNAME="Your Name"
|
||||
export DEBEMAIL="your@email.example"
|
||||
|
||||
# Create description-pak
|
||||
cat >description-pak <<'EOF'
|
||||
ZUnit is a powerful unit testing framework for ZSH.
|
||||
EOF
|
||||
|
||||
# | preinstall-pak | Run BEFORE the package is INSTALLED |
|
||||
cat <<-EOF | tee ${BUILD_DIR}/preinstall-pak
|
||||
#!/usr/bin/env bash
|
||||
EOF
|
||||
|
||||
# | postinstall-pak | Run AFTER the package is INSTALLED |
|
||||
cat <<-EOF | tee ${BUILD_DIR}/postinstall-pak
|
||||
#!/usr/bin/env bash
|
||||
EOF
|
||||
|
||||
# | preremove-pak | Run BEFORE the package is REMOVED |
|
||||
cat <<-EOF | tee ${BUILD_DIR}/preremove-pak
|
||||
#!/usr/bin/env bash
|
||||
EOF
|
||||
|
||||
# | postremove-pak | Run AFTER the package is REMOVED
|
||||
cat <<-EOF | tee ${BUILD_DIR}/postremove-pak
|
||||
#!/usr/bin/env bash
|
||||
EOF
|
||||
|
||||
## Make the doc-pak directory for README, INSTALL, COPYING, Changelog, TODO, CREDITS
|
||||
mkdir -p ${BUILD_DIR}/doc-pak
|
||||
#cp README INSTALL COPYING Changelog TODO CREDITS doc-pak
|
||||
|
||||
cat <<-EOF | tee ${BUILD_DIR}/doc-pak/README
|
||||
EOF
|
||||
|
||||
cat <<-FOE | tee ${BUILD_DIR}/checkinstall_it.sh
|
||||
|
||||
## Checkinstall variables - see defaults in /etc/checkinstallrc
|
||||
DOC_DIR=/usr/share/doc
|
||||
|
||||
# make a new temporary directory for this use to avoid permission issues.
|
||||
BASE_TMP_DIR=~/tmptmp/checkinstall_tmp
|
||||
mkdir -p '${BASE_TMP_DIR}'
|
||||
|
||||
|
||||
# do your work
|
||||
checkinstall -y --fstrans \
|
||||
--pkgname=${PACKAGE} \
|
||||
--pkgversion=${DEB_VERSION}\
|
||||
--pkgrelease=${RELEASE} \
|
||||
--pkgarch=${ARCH} \
|
||||
--pkggroup=admin \
|
||||
--pkglicense=LICENSE \
|
||||
--pkgsource=${LATEST_URL} \
|
||||
--maintainer=cyteen@ring-zero.co.uk \
|
||||
--requires=${REQUIRES} \
|
||||
--recommends=${RECOMENDS} \
|
||||
--suggests=${SUGGESTS} \
|
||||
--exclude=${EXCLUDES} \
|
||||
-D \
|
||||
bash ${BUILD_DIR}/install.sh
|
||||
FOE
|
||||
|
||||
echo "Writing install.sh to: ${BUILD_DIR}/install.sh"
|
||||
cat <<-FOE | tee ${BUILD_DIR}/install.sh
|
||||
# Minimal install script (what checkinstall will run as "make install")
|
||||
cat >install.sh <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
#set -x
|
||||
|
||||
# Install revolver
|
||||
INSTALL_DIR=/usr/local/bin
|
||||
curl -L https://raw.githubusercontent.com/molovo/revolver/master/revolver > ${INSTALL_DIR}/revolver
|
||||
INSTALL_DIR="/usr/local/bin"
|
||||
ZSH_COMP_DIR="/usr/share/zsh/vendor-completions"
|
||||
|
||||
chmod +x ${INSTALL_DIR}/revolver
|
||||
# Install revolver dependency
|
||||
curl -L -o "${INSTALL_DIR}/revolver" \
|
||||
https://raw.githubusercontent.com/molovo/revolver/master/revolver
|
||||
chmod +x "${INSTALL_DIR}/revolver"
|
||||
|
||||
# Build ZUnit from source
|
||||
git clone https://github.com/zunit-zsh/zunit ${BUILD_DIR}/zunit
|
||||
cd ${BUILD_DIR}/zunit
|
||||
# Clone & build ZUnit
|
||||
git clone --depth 1 https://github.com/zunit-zsh/zunit.git src
|
||||
cd src
|
||||
./build.zsh
|
||||
|
||||
# Copy zunit into $path
|
||||
cp zunit ${INSTALL_DIR}
|
||||
chmod +x ${INSTALL_DIR}/zunit
|
||||
# Install binary
|
||||
install -m 755 zunit "${INSTALL_DIR}/zunit"
|
||||
|
||||
# Optional, copy ZUnit ZSH completion into $fpath
|
||||
cp zunit.zsh-completion "${fpath[1]}/_zu
|
||||
FOE
|
||||
# Install completion (if exists)
|
||||
if [[ -f zunit.zsh-completion ]]; then
|
||||
install -D -m 644 zunit.zsh-completion "${ZSH_COMP_DIR}/_zunit"
|
||||
fi
|
||||
EOF
|
||||
|
||||
bash ${BUILD_DIR}/checkinstall_it.sh
|
||||
chmod +x install.sh
|
||||
|
||||
# Run checkinstall
|
||||
checkinstall -y --fstrans=no \
|
||||
--pkgname="${PACKAGE}" \
|
||||
--pkgversion="${DEB_VERSION}" \
|
||||
--pkgrelease="${RELEASE}" \
|
||||
--pkgarch="${ARCH}" \
|
||||
--pkggroup="shells" \
|
||||
--pkglicense="MIT" \
|
||||
--pkgsource="${LATEST_URL}" \
|
||||
--maintainer="you@example.com" \
|
||||
--requires="${REQUIRES}" \
|
||||
--deldoc=yes --deldesc=yes --backup=no \
|
||||
--install=no \
|
||||
bash ./install.sh
|
||||
|
||||
echo "Checkinstall .deb should be in current directory."
|
||||
ls -l *.deb
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ cat >"${ALIAS_FILE}" <<-'EOF'
|
|||
}
|
||||
EOF
|
||||
|
||||
# Check that these don't clash with 020_grc.sh
|
||||
ALIAS_FILE="${DEST}/${ALIAS_DIR}/003_local.zsh"
|
||||
cat >"${ALIAS_FILE}" <<-'EOF'
|
||||
alias baobab='dbus-run-session baobab'
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ sudo apt-get install -y cpufrequtils linux-cpupower
|
|||
#sed -i "s|^GRUB_CMDLINE_LINUX_DEFAULT=\"\(.*\)\"|GRUB_CMDLINE_LINUX_DEFAULT=\"\1 processor.ignore_ppc=1\"|" /etc/default/grub
|
||||
|
||||
# NEWARG="processor.ignore_ppc=1"
|
||||
#sed -i -E "s|^(GRUB_CMDLINE_LINUX_DEFAULT=\"[^\"]*)\"|\1 ${NEWARG}\"|" /etc/default/grub
|
||||
#update_grub
|
||||
# sudo sed -i -E "s|^(GRUB_CMDLINE_LINUX_DEFAULT=\"[^\"]*)\"|\1 ${NEWARG}\"|" /etc/default/grub
|
||||
# sudo update_grub
|
||||
|
||||
# get max available cpu frequency
|
||||
frequencies=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,83 @@
|
|||
#!/bin/bash
|
||||
|
||||
# --- DEFAULTS ---
|
||||
FILE="/etc/default/grub"
|
||||
DRY_RUN=false
|
||||
NEW_SETTING=""
|
||||
|
||||
# --- HELP FUNCTION ---
|
||||
usage() {
|
||||
echo "Usage: sudo $0 [OPTION] \"setting=value\""
|
||||
echo "Example: sudo $0 \"consoleblank=3\""
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " -d, --dry-run Show changes without applying them"
|
||||
echo " -h, --help Display this help message"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# --- ARGUMENT PARSING ---
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-d | --dry-run)
|
||||
DRY_RUN=true
|
||||
shift
|
||||
;;
|
||||
-h | --help)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
NEW_SETTING="$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Check if a setting was actually provided
|
||||
if [[ -z "$NEW_SETTING" ]]; then
|
||||
echo "❌ Error: No GRUB setting provided."
|
||||
usage
|
||||
fi
|
||||
|
||||
# --- LOGIC ---
|
||||
apply_grub_change() {
|
||||
local TARGET="$1"
|
||||
# Regex: Appends TARGET inside the quotes of GRUB_CMDLINE_LINUX_DEFAULT
|
||||
local SED_LOGIC="/^GRUB_CMDLINE_LINUX_DEFAULT=/ s/\"\([^\"]*\)\"/\"\1 $TARGET\"/; s/ */ /g; s/ $TARGET\"/$TARGET\"/"
|
||||
|
||||
# 1. PRE-CHECK
|
||||
if grep -q "$TARGET" "$FILE"; then
|
||||
echo "ℹ️ SKIP: '$TARGET' already exists in $FILE."
|
||||
return 0
|
||||
fi
|
||||
|
||||
# 2. EXECUTION
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
echo "🔍 DRY RUN: Simulating '$TARGET' addition..."
|
||||
grep "^GRUB_CMDLINE_LINUX_DEFAULT=" "$FILE" | sed "$SED_LOGIC"
|
||||
else
|
||||
# Ensure script is run as root for actual changes
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "❌ Error: This script must be run with sudo to apply changes."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "💾 Backing up to $FILE.bak..."
|
||||
cp "$FILE" "$FILE.bak"
|
||||
|
||||
echo "🔧 Applying '$TARGET' to $FILE..."
|
||||
sed -i "$SED_LOGIC" "$FILE"
|
||||
|
||||
# 3. VERIFICATION & UPDATE
|
||||
if grep -q "$TARGET" "$FILE"; then
|
||||
echo "✅ SUCCESS: Updating bootloader..."
|
||||
update-grub
|
||||
else
|
||||
echo "❌ ERROR: Failed to apply changes."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# --- EXECUTE ---
|
||||
apply_grub_change "$NEW_SETTING"
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
DEST=${1:-/etc/skel}
|
||||
|
||||
# Moving away from all things and all peaple 'systemd'
|
||||
#
|
||||
sudo apt remove elogind
|
||||
|
||||
sudo apt update
|
||||
sudo apt install seatd
|
||||
|
||||
sudo rc-update add seatd default
|
||||
sudo rc-service seatd start
|
||||
|
||||
sudo gpasswd -a "$USER" video
|
||||
sudo gpasswd -a "$USER" input
|
||||
sudo gpasswd -a "$USER" _seatd # Devuan's seatd group name may vary
|
||||
|
||||
conf_print_seatd_zsh() {
|
||||
cat << EOF
|
||||
export SEAT_DAEMON=seatd
|
||||
export SEATD_SOCK=/run/seatd.sock
|
||||
EOF
|
||||
}
|
||||
conf_print_seatd_zsh | "${DEST}/.zshrc.d/003_seatd.zsh"
|
||||
|
||||
# openrc
|
||||
if [[ $(command -v openrc) ]]; then
|
||||
sudo rc-service elogind stop
|
||||
sudo rc-update del elogind default
|
||||
fi
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
cargo install difftastic
|
||||
Loading…
Reference in New Issue