-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
43 lines (34 loc) · 1.33 KB
/
install.sh
File metadata and controls
43 lines (34 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
set -euo pipefail
# Define destination for the helper script
BIN_DIR="/usr/local/bin"
UTIL_NAME="new-script"
# Check for root privileges
if [[ ${EUID} -ne 0 ]]; then
echo "This script must be run as root (use sudo)"
exit 1
fi
echo "Starting installation..."
# --- Install Utility Script ---
echo "Installing '${UTIL_NAME}' utility to ${BIN_DIR}..."
# We need to know where the script-templates repo is to tell new-script where to find templates
# Let's find the absolute path of this install.sh script's directory
REPO_PATH="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Create a configuration for our new-script utility
mkdir -p /etc/script-templates
echo "TEMPLATE_REPO_PATH=${REPO_PATH}" >/etc/script-templates/config
cp ./scriptize/utils/new-script "${BIN_DIR}/${UTIL_NAME}"
chmod 755 "${BIN_DIR}/${UTIL_NAME}"
echo "'${UTIL_NAME}' utility installed."
# --- Check for Recommended Dependencies ---
echo ""
echo "Checking for recommended tools..."
for cmd in shellcheck shfmt bats; do
if ! command -v "${cmd}" &>/dev/null; then
echo "WARNING: '${cmd}' is not installed. It is highly recommended for script development."
else
echo "✓ ${cmd} is installed."
fi
done
echo -e "\nInstallation complete!"
echo "You can now create new scripts using: ${UTIL_NAME} <bash|python> <your_script_name>"