-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·101 lines (91 loc) · 2.34 KB
/
uninstall.sh
File metadata and controls
executable file
·101 lines (91 loc) · 2.34 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
INSTALL_DIR="${HOME}/.phpctl"
SYMLINK_DIR="/usr/local/bin"
while getopts "hi:s:" opt; do
case $opt in
h)
echo "Uninstall phpctl."
echo ""
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -h Display this help message and exit"
echo " -i <directory> Set the installation directory (default: $HOME/.phpctl)"
echo " -s <directory> Set the symlink directory (default: /usr/local/bin)"
exit 0
;;
i)
INSTALL_DIR="$OPTARG"
;;
s)
SYMLINK_DIR="$OPTARG"
;;
\?) # Handle invalid options
echo "Error: Invalid option: -$OPTARG" >&2
echo "Try '$0 -h' for more information." >&2
exit 1
;;
:) # Handle missing arguments for options that require them
echo "Error: Option -$OPTARG requires an argument." >&2
echo "Try '$0 -h' for more information." >&2
exit 1
;;
esac
done
# Shift off the options and their arguments, so that any remaining
# positional parameters (if any) are correctly handled.
shift $((OPTIND - 1))
# Compatibility with previous script version
if [[ $SYMLINK_DIR = "/usr/local/bin" && -n ${1} ]]; then
SYMLINK_DIR=$1
fi
if [ ! -w "${SYMLINK_DIR}" ]; then
SUDO="sudo"
else
SUDO=""
fi
if [[ -n $SUDO ]]; then
echo "Running in elevated mode. This might require sudo for operations in ${SYMLINK_DIR}."
fi
LINKS=(
composer
composer-require-checker
co-phpunit
couscous
deptrac
exakat
frankenphp
infection
notty
pest
php
phpcbf
phpcs
php-cs-fixer
phpctl
phpmd
phpstan
phpunit
pint
rector
watchr
)
# Removing symlink
echo "Removing symbolic links..."
for link in "${LINKS[@]}"; do
if [ -L "${SYMLINK_DIR}/${link}" ]; then
$SUDO rm "${SYMLINK_DIR}/${link}"
echo "Removed ${SYMLINK_DIR}/${link}"
else
echo "Link ${SYMLINK_DIR}/${link} does not exist, skipping."
fi
done
# Opcional: removing directory
echo -e "\nDo you want to remove the installation directory (${INSTALL_DIR})? (Y/n) "
read -r answer
if [ "$answer" != "${answer#[Yy]}" ]; then
rm -rf "$INSTALL_DIR"
echo "Removed installation directory: ${INSTALL_DIR}"
else
echo "Skipping removal of installation directory."
fi
echo "Uninstallation complete."