Adds bootstrap.v2
This commit is contained in:
parent
06c8003cf2
commit
2bbccb4595
61 changed files with 468 additions and 4 deletions
74
.config/yadm/bootstrap.v2/functions/filerunner.sh
Normal file
74
.config/yadm/bootstrap.v2/functions/filerunner.sh
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
#!/bin/env sh
|
||||
|
||||
_repeat() {
|
||||
local start=1
|
||||
local end=${1:-80}
|
||||
local str="${2:-=}"
|
||||
local range=$(seq $start $end)
|
||||
for i in $range; do echo -n "${str}"; done
|
||||
}
|
||||
|
||||
_header() {
|
||||
local length="$1"
|
||||
echo -n "/="
|
||||
_repeat ${length} "="
|
||||
echo "=\\"
|
||||
}
|
||||
_value() {
|
||||
local value="$1"
|
||||
echo -n "| "
|
||||
echo -n ${value}
|
||||
echo " |"
|
||||
}
|
||||
_footer() {
|
||||
local length="$1"
|
||||
echo -n "\\="
|
||||
_repeat ${length} "="
|
||||
echo "=/"
|
||||
}
|
||||
|
||||
display() {
|
||||
local value="$1"
|
||||
_header ${#value}
|
||||
_value "${value}"
|
||||
_footer ${#value}
|
||||
}
|
||||
|
||||
runfile() {
|
||||
local command="$1"
|
||||
local commandName=$(basename $command)
|
||||
local prompt="Do you wish to run $commandName? [Ynq]"
|
||||
local display="Executing $commandName"
|
||||
|
||||
local promptLength=$((${#prompt}))
|
||||
local displayLength=${#display}
|
||||
|
||||
local maxWidth=$((promptLength > displayLength ? promptLength : displayLength))
|
||||
|
||||
_header ${maxWidth}
|
||||
|
||||
read -p "| $prompt |" -n 1 -r -s
|
||||
echo
|
||||
|
||||
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||
_footer ${maxWidth}
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ $REPLY =~ ^[Qq]$ ]]; then
|
||||
_footer ${maxWidth}
|
||||
display "Exiting..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo -n "| $display"
|
||||
_repeat $((maxWidth - displayLength)) " "
|
||||
echo " |"
|
||||
|
||||
_footer ${maxWidth}
|
||||
|
||||
if ! "$command"; then
|
||||
echo "Error: bootstrap '$command' failed" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
29
.config/yadm/bootstrap.v2/functions/pkg.sh
Normal file
29
.config/yadm/bootstrap.v2/functions/pkg.sh
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#!/bin/env sh
|
||||
|
||||
installPackages() {
|
||||
packages=$@
|
||||
|
||||
if command -v yay >/dev/null; then
|
||||
echo " using yay"
|
||||
yay -S --needed $packages
|
||||
elif command -v apt >/dev/null; then
|
||||
echo " using apt"
|
||||
apt install $packages
|
||||
else
|
||||
echo "... no supported package manager found. exiting"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
updateSystem() {
|
||||
if command -v yay >/dev/null; then
|
||||
echo " using yay"
|
||||
yay
|
||||
elif command -v apt >/dev/null; then
|
||||
echo " using apt"
|
||||
apt update
|
||||
else
|
||||
echo "... no supported package manager found. exiting"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
13
.config/yadm/bootstrap.v2/functions/set_class.sh
Executable file
13
.config/yadm/bootstrap.v2/functions/set_class.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/env sh
|
||||
|
||||
class=$(yadm config local.class)
|
||||
if [[ ! -z $class ]]; then
|
||||
yadm alt
|
||||
exit 0
|
||||
fi
|
||||
|
||||
read -p "-- Which class does this device belong to: " -r class
|
||||
|
||||
echo "-- Setting class and reloading alternative files"
|
||||
yadm config local.class $class
|
||||
yadm alt
|
||||
Loading…
Add table
Add a link
Reference in a new issue