-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new Brew Auto Update Installer to improve installation process.
- Loading branch information
Showing
2 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/zsh | ||
|
||
# Install Brew Autoupdate System from GitHub Repository | ||
clear | ||
echo "Installing Brew Autoupdate System..." | ||
echo | ||
|
||
# Define variables using readonly to prevent accidental modification | ||
readonly BIN_FOLDER="$HOME/bin" | ||
readonly LAUNCHD_FOLDER="$HOME/Launchd" | ||
|
||
# Function to display error messages based on the return code | ||
display_message() { | ||
local ret_code=$1 | ||
case $ret_code in | ||
0) | ||
echo "Download completed successfully." | ||
;; | ||
1) | ||
echo "Usage error or download canceled by user." | ||
;; | ||
2) | ||
echo "Download failed. This could be due to a network issue or the file not existing on GitHub." | ||
;; | ||
3) | ||
echo "Error: curl is not installed. Please install curl to run this script." | ||
;; | ||
*) | ||
echo "An unknown error occurred with exit code $ret_code." | ||
;; | ||
esac | ||
} | ||
|
||
# Make User Bin Direcory and Download Shell Scripts | ||
mkdir -p "$BIN_FOLDER" | ||
cd "$BIN_FOLDER" | ||
|
||
# Run the GitHub download script | ||
GithubDownloader.sh iAGorynT Brew-Autoupdate main bin/Brewautom2.sh | ||
ret_code=$? | ||
|
||
# Call the display_message function with the return code | ||
display_message $ret_code | ||
echo | ||
|
||
# Run the GitHub download script | ||
GithubDownloader.sh iAGorynT Brew-Autoupdate main bin/BrewitLaunchd.sh | ||
ret_code=$? | ||
|
||
# Call the display_message function with the return code | ||
display_message $ret_code | ||
echo | ||
|
||
# Make User Launchd Direcory and Download Plist Files | ||
mkdir -p "$LAUNCHD_FOLDER" | ||
cd "$LAUNCHD_FOLDER" | ||
|
||
# Run the GitHub download script | ||
$HOME/bin/GithubDownloader.sh iAGorynT Brew-Autoupdate main Launchd/Launchd.plist | ||
ret_code=$? | ||
|
||
# Call the display_message function with the return code | ||
display_message $ret_code | ||
echo | ||
|
||
# Completed Message | ||
echo "Installation Completed..." | ||
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/zsh | ||
|
||
download_github_file() { | ||
# Check if curl is installed | ||
if ! command -v curl &>/dev/null; then | ||
echo "Error: curl is not installed. Please install curl to use this script." | ||
return 3 | ||
fi | ||
|
||
# Check if all required arguments are provided | ||
if [ "$#" -ne 4 ]; then | ||
echo "Usage: $0 owner repo branch filepath" | ||
echo "Example: $0 microsoft vscode main README.md" | ||
return 1 | ||
fi | ||
|
||
local owner=$1 | ||
local repo=$2 | ||
local branch=$3 | ||
local filepath=$4 | ||
local github_raw_url="https://raw.githubusercontent.com/${owner}/${repo}/${branch}/${filepath}" | ||
local filename=$(basename "$filepath") | ||
|
||
# Check if the file already exists and prompt for overwrite | ||
if [ -f "$filename" ]; then | ||
read "overwrite?File $filename already exists. Overwrite? (y/N): " | ||
if [[ ! "$overwrite" =~ ^[Yy]$ ]]; then | ||
echo "Download canceled." | ||
return 1 | ||
fi | ||
fi | ||
|
||
# Attempt to download the file | ||
echo "Downloading ${filename} from ${github_raw_url}..." | ||
|
||
if curl -L -o "$filename" "$github_raw_url"; then | ||
echo "Successfully downloaded ${filename}" | ||
echo "File saved as: $(pwd)/${filename}" | ||
return 0 | ||
else | ||
echo "Error: Failed to download the file from ${github_raw_url}" | ||
return 2 | ||
fi | ||
} | ||
|
||
download_github_file "$@" | ||
# Pass the function's return status to the shell | ||
exit $? |