feat: streamlines install / uninstall process

This commit is contained in:
Menno van Leeuwen 2025-05-20 22:09:19 +02:00
parent 71c7dd060f
commit cf9057d068
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE
5 changed files with 74 additions and 48 deletions

View File

@ -10,11 +10,11 @@ build: clean
clean:
@bin/scripts/clean.sh $(BINARY_PATH) $(COMPLETION_SCRIPT)
uninstall:
@bin/scripts/uninstall.sh
install:
@bin/scripts/install.sh
install-global:
@bin/scripts/install-global.sh
uninstall:
@bin/scripts/uninstall.sh

View File

@ -1,27 +0,0 @@
#!/usr/bin/env bash
source bin/helpers/func.sh
# Remove any existing kcm installation
if [ -f "/usr/local/bin/kcm" ]; then
printfe "%s\n" "yellow" "Removing existing kcm installation..."
rm /usr/local/bin/kcm
fi
if [ -f "/usr/share/bash-completion/completions/kcm" ]; then
printfe "%s\n" "yellow" "Removing existing kcm bash completion..."
rm /usr/share/bash-completion/completions/kcm
fi
# Copy binary files to /usr/local/bin
printfe "%s\n" "cyan" "Installing kcm..."
cp $(pwd)/bin/kcm /usr/local/bin/kcm
cp $(pwd)/bin/kcm-completion.bash /usr/share/bash-completion/completions/kcm
# In case /etc/kcm/config.yaml does not exist, create it
if [ ! -f "/etc/kcm/config.local.yaml" ]; then
printfe "%s\n" "cyan" "Creating default configuration file..."
mkdir -p /etc/kcm
cp $(pwd)/config/config.local.example.yaml /etc/kcm/config.local.yaml
fi
printfe "%s\n" "green" "Installation complete."

18
bin/scripts/install-local.sh Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
source bin/helpers/func.sh
# Create any missing directories/files
touch ~/.bash_completion
mkdir -p $HOME/.local/bin/
# Symbolically link binaries
ln -sf $(pwd)/bin/kcm $HOME/.local/bin/kcm
ln -sf $(pwd)/bin/kcm-completion.bash $HOME/.local/bin/kcm-completion.bash
# Add completion to bash_completion for kcm
sed -i '/kcm/d' ~/.bash_completion
echo "source $HOME/.local/bin/kcm-completion.bash" >> ~/.bash_completion
printfe "%s\n" "green" "Local installation complete. Binary has been installed to $HOME/.local/bin/kcm"
source ~/.bash_completion

View File

@ -1,16 +1,27 @@
#!/usr/bin/env bash
# Create any missing directories/files
touch ~/.bash_completion
mkdir -p $HOME/.local/bin/
source bin/helpers/func.sh
# Symbolically link binaries
ln -sf $(pwd)/bin/kcm $HOME/.local/bin/kcm
ln -sf $(pwd)/bin/kcm-completion.bash $HOME/.local/bin/kcm-completion.bash
# Test for root privileges
if [ "$EUID" -ne 0 ]; then
printfe "%s\n" "red" "Please run as root"
exit 1
fi
# Add completion to bash_completion for kcm
sed -i '/kcm/d' ~/.bash_completion
echo "source $HOME/.local/bin/kcm-completion.bash" >> ~/.bash_completion
# Remove any existing kcm installation
if [ -f "/usr/local/bin/kcm" ]; then
printfe "%s\n" "yellow" "Removing existing kcm installation..."
rm /usr/local/bin/kcm
fi
echo "Installation complete."
source ~/.bash_completion
if [ -f "/usr/share/bash-completion/completions/kcm" ]; then
printfe "%s\n" "yellow" "Removing existing kcm bash completion..."
rm /usr/share/bash-completion/completions/kcm
fi
# Copy binary files to /usr/local/bin
printfe "%s\n" "cyan" "Installing kcm..."
cp $(pwd)/bin/kcm /usr/local/bin/kcm
cp $(pwd)/bin/kcm-completion.bash /usr/share/bash-completion/completions/kcm
printfe "%s\n" "green" "Installation complete."

View File

@ -1,29 +1,53 @@
#!/bin/usr/env bash
#!/usr/bin/env bash
source bin/helpers/func.sh
if [ -f $HOME/.local/bin/kcm ]; then
echo "Removing kcm from $HOME/.local/bin"
printfe "%s\n" "cyan" "Removing kcm from $HOME/.local/bin"
rm $HOME/.local/bin/kcm
rm $HOME/.local/bin/T
fi
if [ -f $HOME/.local/bin/kcm-completion.bash ]; then
echo "Removing kcm-completion.bash from $HOME/.local/bin"
printfe "%s\n" "cyan" "Removing kcm-completion.bash from $HOME/.local/bin"
rm $HOME/.local/bin/kcm-completion.bash
fi
if [ -f $HOME/.local/bin/php ]; then
echo "Removing php from $HOME/.local/bin"
printfe "%s\n" "cyan" "Removing php from $HOME/.local/bin"
rm $HOME/.local/bin/php
fi
if [ -f $HOME/.local/bin/composer ]; then
echo "Removing composer from $HOME/.local/bin"
printfe "%s\n" "cyan" "Removing composer from $HOME/.local/bin"
rm $HOME/.local/bin/composer
fi
if [ -f $HOME/.local/bin/phpstan ]; then
echo "Removing phpstan from $HOME/.local/bin"
printfe "%s\n" "cyan" "Removing phpstan from $HOME/.local/bin"
rm $HOME/.local/bin/phpstan
fi
echo "Uninstall complete."
if [ -f /usr/share/bash-completion/completions/kcm ]; then
# Check root privileges
if [ "$EUID" -ne 0 ]; then
printfe "%s\n" "red" "Please run as root"
exit 1
fi
printfe "%s\n" "cyan" "Removing kcm bash completion from /usr/share/bash-completion/completions"
rm /usr/share/bash-completion/completions/kcm
fi
if [ -f /usr/local/bin/kcm ]; then
# Check root privileges
if [ "$EUID" -ne 0 ]; then
printfe "%s\n" "red" "Please run as root"
exit 1
fi
printfe "%s\n" "cyan" "Removing kcm from /usr/local/bin"
rm /usr/local/bin/kcm
fi
printfe "%s\n" "green" "Uninstall complete."