-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·58 lines (51 loc) · 1.99 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·58 lines (51 loc) · 1.99 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# ----------------------------------------------------------------------------
# Script Name: install.sh
# Description: Install github_init.sh script
# Author: peterweissdk
# Usage: curl -fsSL https://raw.githubusercontent.com/peterweissdk-priv/github_init/main/install.sh | bash
# ----------------------------------------------------------------------------
SCRIPT_NAME="github_init"
REPO_URL="https://raw.githubusercontent.com/peterweissdk-priv/github_init/main/github_init.sh"
DEFAULT_PATH="/usr/local/bin"
echo "Installing $SCRIPT_NAME..."
# Use default path when piped (non-interactive)
install_path="$DEFAULT_PATH"
# Create temp file
tmp_file=$(mktemp)
trap "rm -f $tmp_file" EXIT
# Download the script
echo "Downloading $SCRIPT_NAME..."
if ! curl -fsSL "$REPO_URL" -o "$tmp_file"; then
echo "Error: Failed to download script"
exit 1
fi
# Install the script
echo "Installing to $install_path/$SCRIPT_NAME..."
if [ -w "$install_path" ]; then
# User has write access
if cp "$tmp_file" "$install_path/$SCRIPT_NAME" && chmod 755 "$install_path/$SCRIPT_NAME"; then
echo "Script installed successfully to $install_path/$SCRIPT_NAME"
else
echo "Error: Failed to install script"
exit 1
fi
elif sudo -n true 2>/dev/null; then
# User has passwordless sudo
if sudo cp "$tmp_file" "$install_path/$SCRIPT_NAME" && sudo chmod 755 "$install_path/$SCRIPT_NAME"; then
echo "Script installed successfully to $install_path/$SCRIPT_NAME"
else
echo "Error: Failed to install script"
exit 1
fi
else
# User needs to enter password for sudo
echo "You need root privileges to install the script in $install_path."
if sudo cp "$tmp_file" "$install_path/$SCRIPT_NAME" && sudo chmod 755 "$install_path/$SCRIPT_NAME"; then
echo "Script installed successfully to $install_path/$SCRIPT_NAME"
else
echo "Error: Failed to install script"
exit 1
fi
fi
echo "Run 'github_init' to create a new GitHub repository."