Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,27 @@
# Define paths
BIN_NAME="typy"
LOCAL_DIR="$HOME/.local/share"
BIN_PATH="$/usr/bin"
CONFIG_PATH="$LOCAL_DIR/$BIN_NAME/words.txt"
INSTALL_DIR="$HOME/your-repo"
GIT_TAG="v0.7.0"

# Function to move binary with appropriate privileges
move_binary() {
if command -v sudo &> /dev/null; then
sudo mv /tmp/$BIN_NAME /usr/bin/$BIN_NAME
sudo chmod +x /usr/bin/$BIN_NAME
elif command -v doas &> /dev/null; then
doas mv /tmp/$BIN_NAME /usr/bin/$BIN_NAME
doas chmod +x /usr/bin/$BIN_NAME
elif [ "$(id -u)" -eq 0 ]; then
mv /tmp/$BIN_NAME /usr/bin/$BIN_NAME
chmod +x /usr/bin/$BIN_NAME
else
echo "Please run this script with elevated privileges (sudo, doas, or as root)."
exit 1
fi
}

# Create directories if they don't exist
mkdir -p "$LOCAL_DIR/$BIN_NAME"

Expand All @@ -16,10 +32,9 @@ echo "Downloading and installing $BIN_NAME..."
curl -L https://github.com/Pazl27/typy-cli/releases/download/$GIT_TAG/$BIN_NAME -o /tmp/$BIN_NAME

# Move the binary to /usr/bin and make it executable
sudo mv /tmp/$BIN_NAME /usr/bin/$BIN_NAME
sudo chmod +x /usr/bin/$BIN_NAME
move_binary

# # Move any required files to the ~/.local folder (e.g., configuration files)
# Move any required files to the ~/.local folder (e.g., configuration files)
echo "Setting up configuration files..."
curl -L https://github.com/Pazl27/typy-cli/releases/download/$GIT_TAG/words.txt -o "$CONFIG_PATH"

Expand Down
16 changes: 15 additions & 1 deletion scripts/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,23 @@ BIN_PATH="/usr/bin/$BIN_NAME"
CONFIG_PATH="$LOCAL_DIR/$BIN_NAME/words.txt"
CONFIG_DIR="$LOCAL_DIR/$BIN_NAME"

# Function to remove the binary with appropriate privileges
remove_binary() {
if command -v sudo &> /dev/null; then
sudo rm -f "$BIN_PATH"
elif command -v doas &> /dev/null; then
doas rm -f "$BIN_PATH"
elif [ "$(id -u)" -eq 0 ]; then
rm -f "$BIN_PATH"
else
echo "Please run this script with elevated privileges (sudo, doas, or as root)."
exit 1
fi
}

# Remove the binary
echo "Removing $BIN_NAME binary..."
sudo rm -f "$BIN_PATH"
remove_binary

# Remove configuration files
echo "Removing configuration files..."
Expand Down