parent
ab7c74f888
commit
6222075b6f
32 changed files with 18 additions and 530 deletions
2
.envrc
2
.envrc
|
@ -1,3 +1 @@
|
|||
use nix
|
||||
|
||||
export BASHLY_SOURCE_DIR=$(cat .target)
|
||||
|
|
|
@ -3,13 +3,8 @@ 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
|
||||
|
@ -20,28 +15,17 @@ jobs:
|
|||
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 ./autostart-manage /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
7
.gitignore
vendored
|
@ -1,5 +1,4 @@
|
|||
.target
|
||||
output/
|
||||
src/lib/send_completions.sh
|
||||
|
||||
autoinstall/lib/send_completions.sh
|
||||
autostart-manage/lib/send_completions.sh
|
||||
autostart-manage
|
||||
man1
|
||||
|
|
24
Makefile
24
Makefile
|
@ -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 ./autostart-manage ~/.local/bin/
|
||||
cp -f ./man1/autostart-manage*.1 ~/.local/share/man/man1/
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
target=${args[target]:?}
|
||||
url=${args[url]:?}
|
||||
|
||||
if [ ! -f "$target" ]
|
||||
then
|
||||
echo "Installing archive $url to $target"
|
||||
|
||||
target_dir=$(dirname "$target")
|
||||
mkdir -p "$target_dir"
|
||||
cd "$target_dir" || exit 1
|
||||
|
||||
_http_client "$url" > "$target"
|
||||
tar xaf "$target"
|
||||
|
||||
_run_hook
|
||||
fi
|
|
@ -1,127 +0,0 @@
|
|||
name: autoinstall
|
||||
help: Install files, repository and else
|
||||
version: 0.1.3
|
||||
|
||||
flags:
|
||||
- long: --clean
|
||||
short: -c
|
||||
help: Clean exisiting targets
|
||||
- long: --hook
|
||||
short: -h
|
||||
help: Hook to run if something changed
|
||||
arg: hook
|
||||
|
||||
environment_variables:
|
||||
- name: AUTOINSTALL_CLEAN
|
||||
help: Clean exisiting targets
|
||||
|
||||
dependencies:
|
||||
http_client:
|
||||
command: [curl, wget]
|
||||
help: Please install either curl or wget
|
||||
|
||||
commands:
|
||||
- name: completions
|
||||
help: Generate bash completions
|
||||
|
||||
- name: run
|
||||
help: Autoinstall from file
|
||||
args:
|
||||
- name: group
|
||||
required: true
|
||||
help: The group to install
|
||||
flags:
|
||||
- long: --file
|
||||
short: -f
|
||||
help: File from which to read autoinstall-config
|
||||
arg: file
|
||||
default: $XDG_CONFIG_HOME/autoinstall.conf
|
||||
|
||||
- name: git
|
||||
help: Install a git repository
|
||||
args:
|
||||
- name: repo
|
||||
required: true
|
||||
help: The url of the git repository
|
||||
- name: target
|
||||
required: true
|
||||
help: The path to clone the repository into
|
||||
|
||||
- name: file
|
||||
help: Install a file
|
||||
args:
|
||||
- name: url
|
||||
required: true
|
||||
help: The url of the file
|
||||
- name: target
|
||||
required: true
|
||||
help: The file-path to download the file into
|
||||
flags:
|
||||
- long: --pipe
|
||||
short: -p
|
||||
help: Pipe file through command (e.g. "tar xzO")
|
||||
arg: pipe
|
||||
default: cat
|
||||
|
||||
- name: exe
|
||||
help: Install an executable
|
||||
args:
|
||||
- name: url
|
||||
required: true
|
||||
help: The url of the file
|
||||
- name: target
|
||||
required: true
|
||||
help: The file-path to download the file into
|
||||
filename: file_command.sh
|
||||
flags:
|
||||
- long: --pipe
|
||||
short: -f
|
||||
help: Pipe file through command (e.g. "tar xzO")
|
||||
arg: pipe
|
||||
default: cat
|
||||
- long: --completions
|
||||
short: -c
|
||||
help: Run a command on the new exe to install completions
|
||||
arg: completions
|
||||
|
||||
- name: archive
|
||||
help: Install an archive
|
||||
args:
|
||||
- name: url
|
||||
required: true
|
||||
help: The url of the arhive
|
||||
- name: target
|
||||
required: true
|
||||
help: The path to clone the repository into
|
||||
|
||||
- name: env
|
||||
help: Create a file with envsubst
|
||||
args:
|
||||
- name: template
|
||||
required: true
|
||||
help: The path to the template
|
||||
- name: target
|
||||
required: true
|
||||
help: The path to write the result to
|
||||
dependencies:
|
||||
envsubst: This tool is usually part of the gettext package
|
||||
|
||||
- name: text
|
||||
help: Create a file from text
|
||||
args:
|
||||
- name: text
|
||||
required: true
|
||||
help: The text to write to the file
|
||||
- name: target
|
||||
required: true
|
||||
help: The path to write the result to
|
||||
|
||||
- name: flatpak
|
||||
help: Install a flatpak
|
||||
args:
|
||||
- name: flatpak
|
||||
required: true
|
||||
help: The flatpak to install
|
||||
- name: mode
|
||||
required: true
|
||||
help: The target to install into (user or system)
|
|
@ -1,30 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
action=${action:?}
|
||||
|
||||
# do nothing on some selected actions
|
||||
if [ "$action" = "completions" ] || [ "$action" = "flatpak" ] || [ "$action" = "run" ]
|
||||
then
|
||||
return
|
||||
fi
|
||||
|
||||
clean=${args[--clean]:-}
|
||||
target=${args[target]:?}
|
||||
|
||||
if [ "$action" = "exe" ]
|
||||
then
|
||||
target="$HOME/.local/bin/$target"
|
||||
fi
|
||||
|
||||
if [ -n "$clean" ] || [ -n "${AUTOINSTALL_CLEAN:-}" ]
|
||||
then
|
||||
echo "Cleaning $target"
|
||||
|
||||
# sanity checks
|
||||
if [ -z "$target" ] || [ "$target" = "/" ] || [ "$target" = "$HOME" ] || [ "$target" = "$HOME/" ]
|
||||
then
|
||||
echo "Invalid target: '$target'"
|
||||
exit 1
|
||||
fi
|
||||
rm -rf "$target"
|
||||
fi
|
|
@ -1,17 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
target=${args[target]:?}
|
||||
template=${args[template]:?}
|
||||
|
||||
if [ ! -f "$target" ]
|
||||
then
|
||||
echo "Installing env-template $template to $target"
|
||||
|
||||
target_dir=$(dirname "$target")
|
||||
mkdir -p "$target_dir"
|
||||
cd "$target_dir" || exit 1
|
||||
|
||||
envsubst < "$template" > "$target"
|
||||
|
||||
_run_hook
|
||||
fi
|
|
@ -1,45 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
pipe=${args[--pipe]:?}
|
||||
completions=${args[--completions]:-}
|
||||
target=${args[target]:?}
|
||||
url=${args[url]:?}
|
||||
|
||||
if [ "${action:-file}" = "exe" ] && ! echo "$target" | grep -q "/"
|
||||
then
|
||||
if [ -x "$(command -v "$target")" ]
|
||||
then
|
||||
return
|
||||
fi
|
||||
exe=$target
|
||||
target="$HOME/.local/bin/$target"
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -e "$target" ]
|
||||
then
|
||||
echo "Installing file $url to $target"
|
||||
|
||||
target_dir=$(dirname "$target")
|
||||
mkdir -p "$target_dir"
|
||||
cd "$target_dir" || exit 1
|
||||
|
||||
_http_client "$url" | eval "$pipe" > "$target"
|
||||
|
||||
if [ "${action:-file}" = "exe" ]
|
||||
then
|
||||
chmod +x "$target"
|
||||
|
||||
if [ -n "$completions" ]
|
||||
then
|
||||
echo "Installing completions for $exe"
|
||||
|
||||
# path taken from "__load_completion" function
|
||||
bash_completions_dir=${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions
|
||||
mkdir -p "$bash_completions_dir"
|
||||
eval "$target $completions" > "$bash_completions_dir/_$(basename "$exe")"
|
||||
fi
|
||||
fi
|
||||
|
||||
_run_hook
|
||||
fi
|
|
@ -1,13 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
flatpak=${args[flatpak]:?}
|
||||
mode=${args[mode]:?}
|
||||
|
||||
if ! flatpak info "$flatpak" &> /dev/null
|
||||
then
|
||||
echo "Installing flatpak $flatpak"
|
||||
|
||||
flatpak install -y "--$mode" "$flatpak"
|
||||
|
||||
_run_hook
|
||||
fi
|
|
@ -1,15 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
target=${args[target]:?}
|
||||
repo=${args[repo]:?}
|
||||
|
||||
if [ ! -d "$target" ]
|
||||
then
|
||||
echo "Installing repo $repo to $target"
|
||||
|
||||
mkdir -p "$target"
|
||||
|
||||
git clone --depth=1 "$repo" "$target" >/dev/null 2>&1
|
||||
|
||||
_run_hook
|
||||
fi
|
|
@ -1,20 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
_http_client() {
|
||||
if [ -x "$(command -v curl)" ]
|
||||
then
|
||||
curl -fsSL "$1"
|
||||
elif [ -x "$(command -v wget)" ]
|
||||
then
|
||||
wget -qO - "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
_run_hook() {
|
||||
hook=${args[--hook]:-}
|
||||
if [ -n "$hook" ]
|
||||
then
|
||||
yellow "Running hook: $hook"
|
||||
bash -c "$hook"
|
||||
fi
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
group=${args[group]:?}
|
||||
file=${args[--file]:-}
|
||||
clean=${args[--clean]:-}
|
||||
|
||||
_install_entry() {
|
||||
type="$1"
|
||||
source="$2"
|
||||
target="$3"
|
||||
hook="$4"
|
||||
pipe="$5"
|
||||
completions="$6"
|
||||
|
||||
install_args=()
|
||||
|
||||
if [[ -n "$hook" ]]; then
|
||||
install_args+=("--hook=$hook")
|
||||
fi
|
||||
if [[ -n "$clean" ]]; then
|
||||
install_args+=("--clean")
|
||||
fi
|
||||
|
||||
install_args+=("$type")
|
||||
|
||||
if [[ -n "$pipe" ]]; then
|
||||
install_args+=("--pipe=$pipe")
|
||||
fi
|
||||
if [[ -n "$completions" ]]; then
|
||||
install_args+=("--completions=$completions")
|
||||
fi
|
||||
|
||||
if [[ $source = \$* ]]
|
||||
then
|
||||
source=$(eval "echo $source")
|
||||
fi
|
||||
install_args+=("$source")
|
||||
|
||||
install_args+=("$(eval "echo $target")")
|
||||
|
||||
"$0" "${install_args[@]}"
|
||||
}
|
||||
|
||||
_handle_entry() {
|
||||
unset AUTOINSTALL_ITEM_TYPE \
|
||||
AUTOINSTALL_ITEM_SOURCE \
|
||||
AUTOINSTALL_ITEM_TARGET \
|
||||
AUTOINSTALL_ITEM_HOOK \
|
||||
AUTOINSTALL_ITEM_PIPE \
|
||||
AUTOINSTALL_ITEM_COMPLETIONS
|
||||
|
||||
eval "$1"
|
||||
|
||||
# check if we have the required vars
|
||||
if [[ -z "${AUTOINSTALL_ITEM_TYPE:-}" \
|
||||
|| -z "${AUTOINSTALL_ITEM_SOURCE:-}" \
|
||||
|| -z "${AUTOINSTALL_ITEM_TARGET:-}" ]]
|
||||
then
|
||||
return
|
||||
fi
|
||||
|
||||
_install_entry "$AUTOINSTALL_ITEM_TYPE" "$AUTOINSTALL_ITEM_SOURCE" \
|
||||
"$AUTOINSTALL_ITEM_TARGET" "${AUTOINSTALL_ITEM_HOOK:-}" "${AUTOINSTALL_ITEM_PIPE:-}" "${AUTOINSTALL_ITEM_COMPLETIONS:-}"
|
||||
|
||||
}
|
||||
|
||||
file_lines=$(wc -l < "$file")
|
||||
line=0
|
||||
while [[ $line -lt $file_lines ]]; do
|
||||
entry=$(tail -n +$line "$file" | awk '/^$/{exit} {print} ')
|
||||
entry_len=$(echo "$entry" | wc -l)
|
||||
line=$((line + entry_len))
|
||||
|
||||
if [[ $entry_len -le 1 ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ "$group" != "all" ]]
|
||||
then
|
||||
# check if group is in groups
|
||||
if ! echo "$entry" | grep -qE "^AUTOINSTALL_ITEM_GROUPS=\"(.*,)?$group(,.*)?\"$"
|
||||
then
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
_handle_entry "$entry" || true # ignore errors
|
||||
done
|
|
@ -1,16 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
target=${args[target]:?}
|
||||
text=${args[text]:?}
|
||||
|
||||
if [ ! -f "$target" ]
|
||||
then
|
||||
echo "Installing text '$text' to $target"
|
||||
|
||||
target_dir=$(dirname "$target")
|
||||
mkdir -p "$target_dir"
|
||||
|
||||
echo "$text" > "$target"
|
||||
|
||||
_run_hook
|
||||
fi
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
send_completions
|
|
@ -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" "$*"; }
|
49
settings.yml
49
settings.yml
|
@ -1,49 +0,0 @@
|
|||
# The path to bashly.yml
|
||||
config_path: "%{source_dir}/bashly.yml"
|
||||
|
||||
# The path to use for creating the bash script
|
||||
target_dir: output
|
||||
|
||||
# The path to use for common library files, relative to source_dir
|
||||
lib_dir: lib
|
||||
|
||||
# The path to use for command files, relative to source_dir
|
||||
# When set to nil (~), command files will be placed directly under source_dir
|
||||
# When set to any other string, command files will be placed under this
|
||||
# directory, and each command will get its own subdirectory
|
||||
commands_dir: ~
|
||||
|
||||
# Configure the bash options that will be added to the initialize function:
|
||||
# strict: true Bash strict mode (set -euo pipefail)
|
||||
# strict: false Only exit on errors (set -e)
|
||||
# strict: '' Do not add any 'set' directive
|
||||
# strict: <string> Add any other custom 'set' directive
|
||||
strict: true
|
||||
|
||||
# When true, the generated script will use tab indentation instead of spaces
|
||||
# (every 2 leading spaces will be converted to a tab character)
|
||||
tab_indent: true
|
||||
|
||||
# When true, the generated script will consider any argument in the form of
|
||||
# `-abc` as if it is `-a -b -c`.
|
||||
compact_short_flags: true
|
||||
|
||||
# Set to 'production' or 'development':
|
||||
# env: production Generate a smaller script, without file markers
|
||||
# env: development Generate with file markers
|
||||
env: development
|
||||
|
||||
# The extension to use when reading/writing partial script snippets
|
||||
partials_extension: sh
|
||||
|
||||
# Display various usage elements in color by providing the name of the color
|
||||
# function. The value for each property is a name of a function that is
|
||||
# available in your script, for example: `green` or `bold`.
|
||||
# You can run `bashly add colors` to add a standard colors library.
|
||||
# This option cannot be set via environment variables.
|
||||
usage_colors:
|
||||
caption: blue
|
||||
command: green
|
||||
arg: red
|
||||
flag: yellow
|
||||
environment_variable: cyan
|
|
@ -1,6 +1,6 @@
|
|||
name: autostart-manage
|
||||
help: Manage autostart
|
||||
version: 0.1.3
|
||||
version: 0.1.4
|
||||
|
||||
dependencies:
|
||||
tomlq: please install yq (https://github.com/kislyuk/yq)
|
Loading…
Reference in a new issue