Split repos
Some checks failed
/ release (push) Failing after 23s

This commit is contained in:
Tobias Reisinger 2024-10-28 20:37:23 +01:00
parent ab7c74f888
commit b49d6a4c3a
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
33 changed files with 2240 additions and 383 deletions

2
.envrc
View file

@ -1,3 +1 @@
use nix
export BASHLY_SOURCE_DIR=$(cat .target)

View file

@ -3,45 +3,30 @@ on:
tags:
- v**
jobs:
build-artifacts:
release:
runs-on: docker
strategy:
matrix:
tool:
- autoinstall
- autostart-manage
steps:
- uses: https://code.forgejo.org/actions/checkout@v3
- id: install-dependencies
run: |
apt update
# TODO add pandoc for docs
apt install -y make ruby
gem install bashly
shell: bash
- id: run-bashly
run: |
echo "${{ matrix.tool }}" > .target
make generate
#make docs
shell: bash
- uses: https://code.forgejo.org/actions/upload-artifact@v3
with:
name: ${{ matrix.tool }}
path: ${{ github.workspace }}/output/${{ matrix.tool }}
upload-release:
runs-on: docker
steps:
- uses: https://code.forgejo.org/actions/checkout@v3
- uses: https://code.forgejo.org/actions/download-artifact@v3
with:
path: /tmp/artifacts-in
merge-multiple: true # broken "collect-artifacts" used as workaround
- id: collect-artifacts
- id: prepare-release
run: |
mkdir /tmp/artifacts-out
mv $(find /tmp/artifacts-in -type f) /tmp/artifacts-out
mkdir /tmp/release
cp ./autoinstall /tmp/release
#cp -r ./man1 /tmp/release
shell: bash
- uses: https://code.forgejo.org/actions/forgejo-release@v1
with:
direction: upload
release-dir: /tmp/artifacts-out
release-dir: /tmp/release
token: ${{ github.token }}

7
.gitignore vendored
View file

@ -1,5 +1,4 @@
.target
output/
src/lib/send_completions.sh
autoinstall/lib/send_completions.sh
autostart-manage/lib/send_completions.sh
autoinstall
man1

View file

@ -1,22 +1,12 @@
target:
@echo "Select target directory"
@echo $$(find . -name bashly.yml | sed -e 's/.\///' -e 's/\/.*//' | $$DMENU) > .target
completions:
bashly add completions
get-target:
$(eval TARGET := $(shell cat .target))
output-dir:
mkdir -p ./output
completions: get-target
BASHLY_SOURCE_DIR=$(TARGET) bashly add completions
generate: get-target output-dir completions
BASHLY_SOURCE_DIR=$(TARGET) bashly generate --upgrade
generate: completions
bashly generate --upgrade
docs: generate
BASHLY_SOURCE_DIR=$(TARGET) bashly render :mandoc ./output/man1
bashly render :mandoc ./man1
install: generate docs
cp -f ./output/$(TARGET) ~/.local/bin/
cp -f ./output/man1/$(TARGET)*.1 ~/.local/share/man/man1/
cp -f ./autoinstall ~/.local/bin/
cp -f ./man1/autoinstall*.1 ~/.local/share/man/man1/

View file

@ -1,111 +0,0 @@
name: autostart-manage
help: Manage autostart
version: 0.1.3
dependencies:
tomlq: please install yq (https://github.com/kislyuk/yq)
environment_variables:
- name: HOSTNAME
help: The hostname to use. We will try to get the value automatically.
commands:
- name: completions
help: Generate bash completions
- name: list
help: List available programs
- name: info
help: Get the current status of all programs
- name: sync
help: Remove all programs from autostart and the re-enable all
args:
- name: groups
required: false
help: Extra groups to sync
- name: enable
help: Add a single program to autostart
args:
- name: program
required: true
help: Program to add to autostart
completions:
- $(autostart-manage list)
filename: systemctl.sh
- name: disable
help: Remove a single program from autostart
args:
- name: program
required: true
help: Program to add to autostart
completions:
- $(autostart-manage list)
filename: systemctl.sh
- name: restart
help: Restart programs from autostart
args:
- name: program
help: Program to add to autostart
default: "*"
completions:
- $(autostart-manage list)
filename: systemctl.sh
- name: start
help: Start programs from autostart
args:
- name: program
help: Program to start to autostart
default: "*"
completions:
- $(autostart-manage list)
filename: systemctl.sh
- name: status
help: Check status of programs from autostart
args:
- name: program
help: Program to check status on
default: "*"
completions:
- $(autostart-manage list)
filename: systemctl.sh
- name: stop
help: Stop programs from autostart
args:
- name: program
help: Program to stop
default: "*"
completions:
- $(autostart-manage list)
filename: systemctl.sh
- name: kill
help: Kill the program from autostart
args:
- name: program
required: true
help: Program to kill
completions:
- $(autostart-manage list)
filename: systemctl.sh
- name: log
alias: logs
help: Show the log for a single program from autostart
args:
- name: program
required: true
help: Program to log
completions:
- $(autostart-manage list)
- name: exec
help: Execute a single program from autostart
args:
- name: program
required: true
help: Program to execute
completions:
- $(autostart-manage list)
- name: run
help: Run all programs
- name: run-wayland
help: Run all the wayland specific tasks and all programs
- name: run-xorg
help: Run all the xorg specific tasks and all programs

View file

@ -1,11 +0,0 @@
#!/usr/bin/env bash
service_file="$HOME/.config/systemd/user/autostart@.service"
if [ ! -f "$service_file" ]; then
_deploy_service_file "$service_file"
fi
target_file="$HOME/.config/systemd/user/autostart.target"
if [ ! -f "$target_file" ]; then
_deploy_target_file "$target_file"
fi

View file

@ -1,3 +0,0 @@
#!/usr/bin/env bash
send_completions

View file

@ -1,6 +0,0 @@
#!/usr/bin/env bash
program=${args[program]:?}
sleep "$(_get_autostart_delay "$program")"
bash -c "$(_get_autostart_cmd "$program")"

View file

@ -1,9 +0,0 @@
#!/usr/bin/env bash
autostart_units=()
while IFS='' read -r line
do
autostart_units+=("$line")
done < <(_list "*")
_echo_table "${autostart_units[@]}" | column -t -s$'\t' --table-columns 'Unit,Enabled?,Active?,Command'

View file

@ -1,42 +0,0 @@
## Color functions [@bashly-upgrade colors]
## This file is a part of Bashly standard library
##
## Usage:
## Use any of the functions below to color or format a portion of a string.
##
## echo "before $(red this is red) after"
## echo "before $(green_bold this is green_bold) after"
##
## Color output will be disabled if `NO_COLOR` environment variable is set
## in compliance with https://no-color.org/
##
print_in_color() {
local color="$1"
shift
if [[ -z ${NO_COLOR+x} ]]; then
printf "$color%b\e[0m\n" "$*"
else
printf "%b\n" "$*"
fi
}
red() { print_in_color "\e[31m" "$*"; }
green() { print_in_color "\e[32m" "$*"; }
yellow() { print_in_color "\e[33m" "$*"; }
blue() { print_in_color "\e[34m" "$*"; }
magenta() { print_in_color "\e[35m" "$*"; }
cyan() { print_in_color "\e[36m" "$*"; }
bold() { print_in_color "\e[1m" "$*"; }
underlined() { print_in_color "\e[4m" "$*"; }
red_bold() { print_in_color "\e[1;31m" "$*"; }
green_bold() { print_in_color "\e[1;32m" "$*"; }
yellow_bold() { print_in_color "\e[1;33m" "$*"; }
blue_bold() { print_in_color "\e[1;34m" "$*"; }
magenta_bold() { print_in_color "\e[1;35m" "$*"; }
cyan_bold() { print_in_color "\e[1;36m" "$*"; }
red_underlined() { print_in_color "\e[4;31m" "$*"; }
green_underlined() { print_in_color "\e[4;32m" "$*"; }
yellow_underlined() { print_in_color "\e[4;33m" "$*"; }
blue_underlined() { print_in_color "\e[4;34m" "$*"; }
magenta_underlined() { print_in_color "\e[4;35m" "$*"; }
cyan_underlined() { print_in_color "\e[4;36m" "$*"; }

View file

@ -1,77 +0,0 @@
#!/usr/bin/env bash
_systemctl () {
systemctl --user "${@:2}" "autostart@$1.service"
}
_query_autostart_toml() {
groups_json=$(echo -n "$2" | tr "," "\n" | jq -R . | jq -s .)
tomlq -r \
--arg host "$HOSTNAME" \
--argjson extra_groups "$groups_json" \
'.hosts[$host].groups as $groups | .apps | to_entries[] | select(
(.value.hosts | contains([$host])) or
([.value.group] | inside($groups)) or
([.value.group] | inside($extra_groups)) or
$extra_groups == ["*"]
) | '"$1" \
"$XDG_CONFIG_HOME/autostart.toml"
}
_list () {
_query_autostart_toml '.value.alias // .key' "$1"
}
_autostart_run_graphical () {
set +e
pass x # Try to unlock yubikey asap
start-audio pipewire
wait-for-service "network-online.target"
# Execute only if not already running
# Don't match keepassxc-proxy
if ! (pgrep -l keepassxc | grep -v prox) >/dev/null
then
if pass x
then
(pass keepass | head -n 1 | keepassxc --pw-stdin ~/sync/passwords.kdbx) &
fi
fi
autoinstall run graphical
autostart-manage run
}
_echo_table () {
for unit in "$@"
do
if [ "$(_systemctl "$unit" is-enabled)" = "enabled" ]
then
_enabled=$(green "enabled")
else
_enabled=$(red "disabled")
fi
if _systemctl "$unit" is-active --quiet
then
_active=$(green "active")
else
_active=$(red "inactive")
fi
printf "%s\t%s\t%s\t%s\n" \
"$unit" \
"$_enabled" \
"$_active" \
"$(_get_autostart_cmd "$unit")"
done
}
_get_autostart_cmd () {
_query_autostart_toml 'select((.key == "'"$1"'") or (.value.alias == "'"$1"'")) | .value.command' "*"
}
_get_autostart_delay () {
_query_autostart_toml 'select((.key == "'"$1"'") or (.value.alias == "'"$1"'")) | .value.delay // 0' "*"
}

View file

@ -1,26 +0,0 @@
#!/usr/bin/env bash
_deploy_service_file() {
cat <<EOF > "$1"
[Unit]
Description=Autostart several tools and services
StartLimitIntervalSec=120
StartLimitBurst=10
[Service]
KillMode=process
ExecStart=/bin/sh -c ". \$HOME/.profile && autostart-manage exec '%i'"
Restart=on-failure
RestartSec=5s
EOF
}
_deploy_target_file() {
cat <<EOF > "$1"
[Unit]
Description=Current graphical user session
Documentation=man:systemd.special(7)
RefuseManualStart=no
StopWhenUnneeded=no
EOF
}

View file

@ -1,3 +0,0 @@
#!/usr/bin/env bash
_list "*"

View file

@ -1,3 +0,0 @@
#!/usr/bin/env bash
journalctl --user -fu "autostart@${args[program]:?}.service"

View file

@ -1,3 +0,0 @@
#!/usr/bin/env bash
systemctl --user start autostart.target

View file

@ -1,5 +0,0 @@
#!/usr/bin/env bash
_autostart_run_graphical
killall -SIGUSR2 waybar

View file

@ -1,12 +0,0 @@
#!/usr/bin/env bash
feh --bg-fill "$XDG_PICTURES_DIR/wallpaper/active_wallpaper"
"$HOME/.config/polybar/launch.sh" &
"$HOME/.config/bspwm/focus-voip.py" &
numlockx on
xsetroot -cursor_name left_ptr
xrdb "$HOME/.Xresources"
_autostart_run_graphical

View file

@ -1,11 +0,0 @@
#!/usr/bin/env bash
rm -f "$HOME/.config/systemd/user/autostart.target.wants/"*
autostart_units=()
while IFS='' read -r line
do
autostart_units+=("autostart@$line.service")
done < <(_list "${args[groups]:-}")
systemctl --user add-wants autostart.target "${autostart_units[@]}"

View file

@ -1,9 +0,0 @@
#!/usr/bin/env bash
systemctl_args=("$action")
if [[ $action == "enable" ]]; then
systemctl_args=("add-wants" "autostart.target")
fi
#shellcheck disable=SC2068
_systemctl "${args[program]:?}" "${systemctl_args[@]}"

2220
output/autostart-manage Executable file

File diff suppressed because it is too large Load diff

6
run.sh
View file

@ -1,11 +1,7 @@
#!/usr/bin/env sh
target=$(cat .target)
[ -n "$target" ] || exit 1
make generate
printf "\nBuild complete. Running...\n==========================\n\n"
time "./output/$target" "$@"
time ./autoinstall "$@"

View file

@ -1,6 +1,6 @@
name: autoinstall
help: Install files, repository and else
version: 0.1.3
version: 0.1.4
flags:
- long: --clean