Compare commits
No commits in common. "main" and "v0.1.2" have entirely different histories.
|
@ -1,6 +1,6 @@
|
|||
name: autoinstall
|
||||
help: Install files, repository and else
|
||||
version: 0.1.3
|
||||
version: 0.1.2
|
||||
|
||||
flags:
|
||||
- long: --clean
|
||||
|
@ -30,12 +30,6 @@ commands:
|
|||
- 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
|
||||
|
@ -115,13 +109,3 @@ commands:
|
|||
- 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)
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
action=${action:?}
|
||||
|
||||
# do nothing on some selected actions
|
||||
if [ "$action" = "completions" ] || [ "$action" = "flatpak" ] || [ "$action" = "run" ]
|
||||
# if action is run or completions, do nothing
|
||||
if [ "$action" = "run" ] || [ "$action" = "completions" ]
|
||||
then
|
||||
return
|
||||
fi
|
||||
|
@ -19,12 +19,5 @@ 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
|
||||
|
|
|
@ -5,7 +5,7 @@ completions=${args[--completions]:-}
|
|||
target=${args[target]:?}
|
||||
url=${args[url]:?}
|
||||
|
||||
if [ "${action:-file}" = "exe" ] && ! echo "$target" | grep -q "/"
|
||||
if [ "${action:-file}" = "exe" ]
|
||||
then
|
||||
if [ -x "$(command -v "$target")" ]
|
||||
then
|
||||
|
@ -16,7 +16,7 @@ then
|
|||
fi
|
||||
|
||||
|
||||
if [ ! -e "$target" ]
|
||||
if [ ! -f "$target" ]
|
||||
then
|
||||
echo "Installing file $url to $target"
|
||||
|
||||
|
|
|
@ -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,19 +1,24 @@
|
|||
#!/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"
|
||||
_config_query() {
|
||||
tomlq -c --arg group "$group" \
|
||||
'.autoinstall | map(select(.groups + ["all"] | contains([$group]))) | '"$1" \
|
||||
"$XDG_CONFIG_HOME/autoinstall.toml"
|
||||
}
|
||||
|
||||
_config_query ".[]" | while read -r entry; do
|
||||
install_args=()
|
||||
|
||||
type=$(echo "$entry" | jq -r '.type')
|
||||
source=$(echo "$entry" | jq -r '.source')
|
||||
target=$(echo "$entry" | jq -r '.target')
|
||||
hook=$(echo "$entry" | jq -r '.hook // ""')
|
||||
pipe=$(echo "$entry" | jq -r '.pipe // ""')
|
||||
completions=$(echo "$entry" | jq -r '.completions // ""')
|
||||
|
||||
if [[ -n "$hook" ]]; then
|
||||
install_args+=("--hook=$hook")
|
||||
fi
|
||||
|
@ -32,57 +37,11 @@ _install_entry() {
|
|||
|
||||
if [[ $source = \$* ]]
|
||||
then
|
||||
source=$(eval "echo $source")
|
||||
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
|
||||
autoinstall "${install_args[@]}"
|
||||
done
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: autostart-manage
|
||||
help: Manage autostart
|
||||
version: 0.1.3
|
||||
version: 0.1.2
|
||||
|
||||
dependencies:
|
||||
tomlq: please install yq (https://github.com/kislyuk/yq)
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
}
|
Loading…
Reference in a new issue