Compare commits

...

2 Commits

7 changed files with 154 additions and 146 deletions

View File

@@ -13,11 +13,13 @@ if [ -z "${FILENAME}" ]; then
FILENAME=$DIRECTORY FILENAME=$DIRECTORY
fi fi
FILENAME=${FILENAME} \ FILENAME=$(
${FILENAME} \
| tr '/' _ \ | tr '/' _ \
| iconv -t ascii//TRANSLIT \ | iconv -t ascii//TRANSLIT \
| sed -r s/[^a-zA-Z0-9]+/_/g \ | sed -r s/[^a-zA-Z0-9]+/_/g \
| sed -r s/^_+\|-+$//g | sed -r s/^_+\|-+$//g
)
TIMESTAMP=$(date "+%Y%m%d_%H%M%S") TIMESTAMP=$(date "+%Y%m%d_%H%M%S")
FILENAME_TIMESTAMP="${FILENAME}_${TIMESTAMP}" FILENAME_TIMESTAMP="${FILENAME}_${TIMESTAMP}"

View File

@@ -10,6 +10,14 @@ $fsCharLenght = 0;
$quota = shell_exec("quota -w"); $quota = shell_exec("quota -w");
/**
* Pad string
*
* @param string $i Input string
* @param int $n Length
* @param string $p Padding string
* @return string
*/
function pad($i, $n = 3, $p = ' ') function pad($i, $n = 3, $p = ' ')
{ {
return str_pad($i, $n, $p, STR_PAD_LEFT); return str_pad($i, $n, $p, STR_PAD_LEFT);

View File

@@ -4,20 +4,21 @@
# shellcheck source="shared.sh" # shellcheck source="shared.sh"
source "$HOME/.dotfiles/scripts/shared.sh" source "$HOME/.dotfiles/scripts/shared.sh"
have php && { ! have php && msg_err "PHP Not Available, cannot install composer" && exit 0;
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then
echo >&2 'ERROR: Invalid installer checksum' echo >&2 'ERROR: Invalid installer checksum'
rm composer-setup.php rm composer-setup.php
exit 1 exit 1
fi fi
php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php
mv composer.phar ~/.local/bin/composer
exit $RESULT
php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php
mv composer.phar ~/.local/bin/composer
exit $RESULT
} || msg_err "PHP Not Available, cannot install composer"

View File

@@ -4,8 +4,11 @@
# shellcheck source="shared.sh" # shellcheck source="shared.sh"
source "$HOME/.dotfiles/scripts/shared.sh" source "$HOME/.dotfiles/scripts/shared.sh"
have gh && { ! have gh \
extensions=( && msg_err "gh (GitHub Client) could not be found, please install it first" \
&& exit 0;
extensions=(
# GitHub CLI extension for generating a report on repository dependencies. # GitHub CLI extension for generating a report on repository dependencies.
andyfeller/gh-dependency-report andyfeller/gh-dependency-report
# GitHub CLI extension to generate montage from GitHub user avatars # GitHub CLI extension to generate montage from GitHub user avatars
@@ -23,11 +26,11 @@ have gh && {
# being an extension to view the overall health of # being an extension to view the overall health of
# an organization's use of actions # an organization's use of actions
rsese/gh-actions-status rsese/gh-actions-status
) )
msg "Starting to install GitHub CLI extensions..." msg "Starting to install GitHub CLI extensions..."
for ext in "${extensions[@]}"; do for ext in "${extensions[@]}"; do
# Trim spaces # Trim spaces
ext=${ext// /} ext=${ext// /}
# Skip comments # Skip comments
@@ -36,10 +39,7 @@ have gh && {
msg_run "Installing $ext" msg_run "Installing $ext"
gh extensions install "$ext" gh extensions install "$ext"
echo "" echo ""
done done
msg_ok "Done" msg_ok "Done"
}
! have gh \
&& msg_err "gh (GitHub Client) could not be found, please install it first"

View File

@@ -4,8 +4,9 @@
# shellcheck source=shared.sh # shellcheck source=shared.sh
source "$HOME/.dotfiles/scripts/shared.sh" source "$HOME/.dotfiles/scripts/shared.sh"
have go && { ! have go && msg "go hasn't been installed yet." && exit 0;
packages=(
packages=(
# sysadmin/scripting utilities, distributed as a single binary # sysadmin/scripting utilities, distributed as a single binary
github.com/skx/sysbox@latest github.com/skx/sysbox@latest
# Git Profile allows you to switch between user profiles in git repos # Git Profile allows you to switch between user profiles in git repos
@@ -22,9 +23,9 @@ have go && {
github.com/charmbracelet/glow@latest github.com/charmbracelet/glow@latest
# Static checker for GitHub Actions workflow files # Static checker for GitHub Actions workflow files
github.com/rhysd/actionlint/cmd/actionlint@latest github.com/rhysd/actionlint/cmd/actionlint@latest
) )
for pkg in "${packages[@]}"; do for pkg in "${packages[@]}"; do
# Trim spaces # Trim spaces
pkg=${pkg// /} pkg=${pkg// /}
# Skip comments # Skip comments
@@ -33,9 +34,7 @@ have go && {
msg_run "Installing go package:" "$pkg" msg_run "Installing go package:" "$pkg"
go install "$pkg" go install "$pkg"
echo "" echo ""
done done
msg_ok "Done" msg_ok "Done"
}
! have go && msg "go hasn't been installed yet."

View File

@@ -4,8 +4,9 @@
# shellcheck source=shared.sh # shellcheck source=shared.sh
source "$HOME/.dotfiles/scripts/shared.sh" source "$HOME/.dotfiles/scripts/shared.sh"
have npm && { ! have npm && msg_err "npm could not be found." && exit 0;
packages=(
packages=(
# This is a tool to check if your files consider your .editorconfig rules. # This is a tool to check if your files consider your .editorconfig rules.
"editorconfig-checker" "editorconfig-checker"
# Node module to create a release or a changelog from # Node module to create a release or a changelog from
@@ -19,9 +20,9 @@ have npm && {
# with linking, tagging, filtering, search, Git versioning & syncing, # with linking, tagging, filtering, search, Git versioning & syncing,
# Pandoc conversion, + more, in a single portable script. # Pandoc conversion, + more, in a single portable script.
"nb.sh" "nb.sh"
) )
for pkg in "${packages[@]}"; do for pkg in "${packages[@]}"; do
# Trim spaces # Trim spaces
pkg=${pkg// /} pkg=${pkg// /}
# Skip comments # Skip comments
@@ -35,11 +36,9 @@ have npm && {
fi fi
echo "" echo ""
done done
msg_run "Upgrading all global packages" msg_run "Upgrading all global packages"
npm -g --no-progress --no-timing --no-fund outdated npm -g --no-progress --no-timing --no-fund outdated
npm -g --no-timing --no-fund upgrade npm -g --no-timing --no-fund upgrade
}
! have npm && msg_err "npm could not be found."

View File

@@ -6,32 +6,31 @@
source "$HOME/.dotfiles/scripts/shared.sh" source "$HOME/.dotfiles/scripts/shared.sh"
set -e set -e
have ntfy && msg "ntfy already installed" have ntfy && msg "ntfy already installed" && exit 0;
! have ntfy && { case $(dfm check arch) in
case $(dfm check arch) in
Linux) Linux)
NTFY_ARCH="linux_$(arch)" NTFY_ARCH="linux_$(arch)"
;; ;;
Darwin) Darwin)
NTFY_ARCH="macOS_all" NTFY_ARCH="macOS_all"
;; ;;
esac esac
NTFY_VERSION=2.2.0 NTFY_VERSION=2.2.0
NTFY_URL="https://github.com/binwiederhier/ntfy" NTFY_URL="https://github.com/binwiederhier/ntfy"
NTFY_DEST="ntfy_${NTFY_VERSION}_${NTFY_ARCH}" NTFY_DEST="ntfy_${NTFY_VERSION}_${NTFY_ARCH}"
curl -L "$NTFY_URL/releases/download/v${NTFY_VERSION}/${NTFY_DEST}.tar.gz" \ curl -L "$NTFY_URL/releases/download/v${NTFY_VERSION}/${NTFY_DEST}.tar.gz" \
> "${NTFY_DEST}.tar.gz" > "${NTFY_DEST}.tar.gz"
tar zxvf "${NTFY_DEST}.tar.gz" tar zxvf "${NTFY_DEST}.tar.gz"
cp -a "${NTFY_DEST}/ntfy" ~/.local/bin/ntfy cp -a "${NTFY_DEST}/ntfy" ~/.local/bin/ntfy
mkdir -p ~/.config/ntfy mkdir -p ~/.config/ntfy
# copy config only if it does not exist # copy config only if it does not exist
if [ ! -f "$HOME/.config/ntfy/client.yml" ]; then if [ ! -f "$HOME/.config/ntfy/client.yml" ]; then
cp "${NTFY_DEST}/client/client.yml" ~/.config/ntfy/client.yml cp "${NTFY_DEST}/client/client.yml" ~/.config/ntfy/client.yml
fi fi
rm -rf "${NTFY_DEST}" "${NTFY_DEST}.tar.gz"
rm -rf "${NTFY_DEST}" "${NTFY_DEST}.tar.gz"
}