-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
56 lines (47 loc) · 1.38 KB
/
install
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
#!/bin/bash
# _
# | |__ _ __ _ __
# | '_ \| '__| '_ \
# | |_) | | | | | |
# |_.__/|_| |_| |_|
#
# Author: Andrianos Papamarkou
#
# https://github.com/apapamarkou/batch-rename-cli
#
# Get the directory of the installation script
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SOURCE_SCRIPT="$SCRIPT_DIR/brn"
TARGET_PATH="/usr/bin/brn"
# Function to print error messages
error() {
echo "Error: $1" >&2
exit 1
}
# Check if script is run with sudo
if [ "$EUID" -ne 0 ]; then
error "This script must be run with sudo privileges"
fi
# Check if source script exists
if [ ! -f "$SOURCE_SCRIPT" ]; then
error "Could not find source script at $SOURCE_SCRIPT"
fi
# Check if Python 3 is installed
if ! command -v python3 &> /dev/null; then
error "Python 3 is required but not installed"
fi
# Make the script executable
chmod +x "$SOURCE_SCRIPT" || error "Failed to make script executable"
# Copy script to /usr/bin
cp "$SOURCE_SCRIPT" "$TARGET_PATH" || error "Failed to copy script to $TARGET_PATH"
# Verify installation
if [ -f "$TARGET_PATH" ] && [ -x "$TARGET_PATH" ]; then
echo "Installation successful! You can now use 'brn' command from anywhere"
echo
echo "Usage examples:"
echo " brn *.jpg --count 001"
echo " brn *.png --sort-size desc --count 001"
echo " brn --help"
else
error "Installation verification failed"
fi