-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·82 lines (76 loc) · 2.28 KB
/
install.sh
File metadata and controls
executable file
·82 lines (76 loc) · 2.28 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
#!/bin/bash
if [[ $(whoami) == "root" ]]; then
echo "Warning: This will install spaste locally as root, you probaby want to run this as your own user!"
sleep 10
fi
echo "Preparing to install SPaste client..."
if ! command -v "perl" 2>&1 >/dev/null && ! command -v "openssl" 2>&1 >/dev/null; then
echo "Please first install the openssl package for your distro, this will not work without it!"
echo " Redhat based: $ sudo dnf install openssl"
echo " Debian based: $ sudo apt install openssl"
echo " Arch based: $ sudo pacman -S openssl"
exit 1
fi
SPSTR="alias sp='timeout 1s openssl s_client -quiet -servername spaste.oxasploits.com \
-verify_return_error -connect spaste.oxasploits.com:8866 2>/dev/null | grep -v END |\
tr -d \"\n\"; echo'"
SHF=""
isinst()
{
if [[ "$1" != "upgrade" ]]; then
if [[ $(cat $SHF | grep -c "alias sp=") -gt 0 ]]; then
echo "SPaste seems to be already installed!"
exit 1
fi
if [[ -x "$HOME/.local/bin/sp" ]]; then
echo "Spaste seems to be already installed!"
exit 1
fi
fi
}
installo()
{
if [[ -w "${SHF}" ]]; then
echo $SPSTR >>$SHF
echo "Sucessfully installed!"
echo "To complete the install, please run: source ${SHF}"
exit 0
else
return 1
fi
}
installp()
{
echo "Installing perl client..."
if mkdir -p $HOME/.local/bin; then
if cp bin/paste-client.pl $HOME/.local/bin/sp; then
chmod +x $HOME/.local/bin/sp
echo "Installed perl script locally!"
echo "Please make sure ~/.local/bin is in your \$PATH."
else
echo "Could not install script in local bin dir!"
fi
else
echo "Could not create dir for script!"
fi
exit 0
}
if command -v "openssl" 2>&1 >/dev/null; then
if [[ $(ps -p $PPID | grep -v CMD | awk '{print $NF}') == "bash" ]]; then
SHF="$HOME/.bashrc"
isinst $1
installo || installp
elif [[ $(ps -p $PPID | grep -v CMD | awk '{print $NF}') == "zsh" ]]; then
SHF="$HOME/.zshrc"
isinst $1
installo || installp
elif [[ $(ps -p $PPID | grep -v CMD | awk '{print $NF}') == "sh" ]]; then
SHF="$HOME/.profile"
isinst $1
installo || installp
else
echo "Couldn't detect shell, falling back to perl client!" && installp
fi
else
echo "Didn't find openssl, falling back to perl client!" && installp
fi