Deploy scripts with stow
This commit is contained in:
@@ -1,47 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# This script installs the Hartman Lab Server Manual to each user's desktop
|
|
||||||
# Usage: script-deploy-manual USERNAME|--all
|
|
||||||
# Copyright 2021-2025 Bryan C. Roessler
|
|
||||||
# Licensed under the Apache License, Version 2.0
|
|
||||||
|
|
||||||
script-deploy-manual() {
|
|
||||||
local user_arg="$1"
|
|
||||||
local manual_url="https://docs.google.com/document/d/1K_KwAlv8Zljmy-enwmhT6gMTFutlAFglixvpLGBx0VY"
|
|
||||||
local remove=("manual.pdf" "manual.odt" "Notes.pdf" "Notes.odt" \
|
|
||||||
"README.html" "Link to Manual.desktop" "manual-images" \
|
|
||||||
"manual.html" "Manual.desktop" "manual.desktop")
|
|
||||||
local users=()
|
|
||||||
|
|
||||||
if [[ "$user_arg" == "--all" ]]; then
|
|
||||||
for d in /home/*; do [[ -d $d ]] && users+=("${d##*/}"); done
|
|
||||||
else
|
|
||||||
users+=("$user_arg")
|
|
||||||
fi
|
|
||||||
|
|
||||||
for user in "${users[@]}"; do
|
|
||||||
desktop="/home/$user/Desktop"
|
|
||||||
[[ -d $desktop ]] || continue
|
|
||||||
echo "Scanning $desktop for old manuals"
|
|
||||||
for f in "${remove[@]}"; do
|
|
||||||
if [[ -e $desktop/$f || -L $desktop/$f ]]; then
|
|
||||||
echo "Removing $desktop/$f"
|
|
||||||
rm -f "${desktop:?}/$f"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo "Installing manual to $desktop/manual.desktop"
|
|
||||||
cat <<-EOF > "$desktop/manual.desktop"
|
|
||||||
[Desktop Entry]
|
|
||||||
Encoding=UTF-8
|
|
||||||
Name=Hartman Lab Server Manual
|
|
||||||
Type=Link
|
|
||||||
URL=$manual_url
|
|
||||||
Icon=text-html
|
|
||||||
EOF
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Allow script to be safely sourced
|
|
||||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
||||||
script-deploy-manual "$@"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# Adds the scripts directory to the global PATH
|
|
||||||
# Copyright 2021-2025 Bryan C. Roessler
|
|
||||||
# Licensed under the Apache License, Version 2.0
|
|
||||||
p="${BASH_SOURCE[0]%/*}"; [[ -r $p/script-functions ]] && . "$p"/script-functions || exit 1
|
|
||||||
|
|
||||||
script-deploy-scripts() {
|
|
||||||
local profile_file="/etc/profile.d/99-hartmanlab_server_scripts.sh"
|
|
||||||
echo "Adding $p to global PATH in $profile_file"
|
|
||||||
sudo bash -c "echo 'export PATH=\"\$PATH:$p\"' > '$profile_file'"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Allow script to be safely sourced
|
|
||||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
||||||
script-deploy-scripts
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
2
stow/README
Normal file
2
stow/README
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
To deploy everything (from this dir): `sudo stow -t / config scripts`
|
||||||
|
To only deploy scripts: `sudo stow -t / scripts`
|
||||||
3
stow/deploy
Normal file
3
stow/deploy
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
sudo stow -t / usr etc
|
||||||
57
stow/scripts/usr/local/bin/script-deploy-manual
Executable file
57
stow/scripts/usr/local/bin/script-deploy-manual
Executable file
@@ -0,0 +1,57 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# This script installs the Hartman Lab Server Manual to each user's desktop
|
||||||
|
# Usage: script-deploy-manual USERNAME|--all
|
||||||
|
# Copyright 2021-2025 Bryan C. Roessler
|
||||||
|
# Licensed under the Apache License, Version 2.0
|
||||||
|
|
||||||
|
script-deploy-manual() {
|
||||||
|
local user_arg="$1"
|
||||||
|
local manual_url="https://docs.google.com/document/d/1K_KwAlv8Zljmy-enwmhT6gMTFutlAFglixvpLGBx0VY"
|
||||||
|
local remove=("manual.pdf" "manual.odt" "Notes.pdf" "Notes.odt" \
|
||||||
|
"README.html" "Link to Manual.desktop" "manual-images" \
|
||||||
|
"manual.html" "Manual.desktop" "manual.desktop")
|
||||||
|
local users=()
|
||||||
|
|
||||||
|
if [[ -z "$user_arg" || "$user_arg" == "--help" ]]; then
|
||||||
|
cat <<-EOF
|
||||||
|
Usage: script-deploy-manual USERNAME|--all
|
||||||
|
|
||||||
|
USERNAME: Specify a single user's name.
|
||||||
|
--all: Deploy the manual to all users with a Desktop directory.
|
||||||
|
EOF
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$user_arg" == "--all" ]]; then
|
||||||
|
for d in /home/*; do [[ -d $d ]] && users+=("${d##*/}"); done
|
||||||
|
else
|
||||||
|
users+=("$user_arg")
|
||||||
|
fi
|
||||||
|
|
||||||
|
for user in "${users[@]}"; do
|
||||||
|
desktop="/home/$user/Desktop"
|
||||||
|
[[ -d $desktop ]] || continue
|
||||||
|
echo "Scanning $desktop for old manuals"
|
||||||
|
for f in "${remove[@]}"; do
|
||||||
|
if [[ -e $desktop/$f || -L $desktop/$f ]]; then
|
||||||
|
echo "Removing $desktop/$f"
|
||||||
|
rm -f "${desktop:?}/$f"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "Installing manual to $desktop/manual.desktop"
|
||||||
|
cat <<-EOF > "$desktop/manual.desktop"
|
||||||
|
[Desktop Entry]
|
||||||
|
Encoding=UTF-8
|
||||||
|
Name=Hartman Lab Server Manual
|
||||||
|
Type=Link
|
||||||
|
URL=$manual_url
|
||||||
|
Icon=text-html
|
||||||
|
EOF
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Allow script to be safely sourced
|
||||||
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||||
|
script-deploy-manual "$@"
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user