50 lines
1.5 KiB
Bash
Executable File
50 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
source bin/helpers/func.sh
|
|
|
|
# Test for root privileges
|
|
if [ "$EUID" -ne 0 ]; then
|
|
printfe "%s\n" "red" "Please run as root"
|
|
exit 1
|
|
fi
|
|
|
|
# Firstly compile the kcm binary
|
|
printfe "%s\n" "cyan" "Compiling kcm..."
|
|
MAKE_OUTPUT=$(make 2>&1)
|
|
MAKE_EXIT_CODE=$?
|
|
if [ $MAKE_EXIT_CODE -ne 0 ]; then
|
|
printfe "%s\n" "red" "Compilation failed. Please check the output below."
|
|
echo "$MAKE_OUTPUT"
|
|
exit 1
|
|
fi
|
|
printfe "%s\n" "green" "Compilation successful."
|
|
|
|
# Remove any existing kcm installation
|
|
printfe "%s\n" "cyan" "Removing existing kcm installation..."
|
|
if [ -f "/usr/local/bin/kcm" ]; then
|
|
log_and_run rm /usr/local/bin/kcm
|
|
fi
|
|
if [ -f "/usr/share/bash-completion/completions/kcm" ]; then
|
|
log_and_run rm /usr/share/bash-completion/completions/kcm
|
|
fi
|
|
if [ -f "/usr/local/share/kcm/kcm.version" ]; then
|
|
log_and_run rm /usr/local/share/kcm/kcm.version
|
|
fi
|
|
|
|
# Copy binary files to /usr/local/bin
|
|
printfe "%s\n" "cyan" "Installing kcm..."
|
|
log_and_run cp $(pwd)/bin/kcm /usr/local/bin/kcm
|
|
log_and_run cp $(pwd)/bin/kcm-completion.bash /usr/share/bash-completion/completions/kcm
|
|
|
|
# Copy version file to /usr/local/share/kcm/kcm.version
|
|
mkdir -p /usr/local/share/kcm
|
|
log_and_run cp $(pwd)/bin/kcm.version /usr/local/share/kcm/kcm.version
|
|
|
|
# Clean up any compiled files
|
|
printfe "%s\n" "cyan" "Cleaning up..."
|
|
log_and_run rm $(pwd)/bin/kcm
|
|
log_and_run rm $(pwd)/bin/kcm-completion.bash
|
|
log_and_run rm $(pwd)/bin/kcm.version
|
|
|
|
printfe "%s\n" "green" "Installation complete."
|