-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate.sh
61 lines (51 loc) · 1.71 KB
/
update.sh
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
#!/bin/bash
# GitHub repository details
REPO_OWNER="KaliforniaGator"
REPO_NAME="SecShell"
FILE_PATH="secshell.cpp"
# GitHub API URL to fetch the file content
GITHUB_API_URL="https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/contents/$FILE_PATH"
# Function to download using curl
download_with_curl() {
curl -H "Accept: application/vnd.github.v3.raw" -o secshell.cpp "$GITHUB_API_URL"
}
# Function to download using wget
download_with_wget() {
wget --header="Accept: application/vnd.github.v3.raw" -O secshell.cpp "$GITHUB_API_URL"
}
# Try to download using curl, fallback to wget if curl is not available
echo "Downloading the latest version of secshell.cpp..."
if command -v curl &> /dev/null; then
download_with_curl
elif command -v wget &> /dev/null; then
download_with_wget
else
echo "Neither curl nor wget is installed. Please install one of them to proceed."
exit 1
fi
# Check if the download was successful
if [ $? -ne 0 ]; then
echo "Failed to download secshell.cpp. Please check your internet connection and the URL."
exit 1
fi
# Compile secshell.cpp using g++ or clang
echo "Compiling secshell.cpp..."
# Check if g++ is available
if command -v g++ &> /dev/null; then
COMPILER="g++"
# Check if clang is available
elif command -v clang++ &> /dev/null; then
COMPILER="clang++"
else
echo "Neither g++ nor clang++ found. Please install one of them to compile secshell.cpp."
exit 1
fi
# Compile the file
$COMPILER secshell.cpp -o secshell -lreadline
# Check if the compilation was successful
if [ $? -eq 0 ]; then
echo "Compilation successful! The executable 'secshell' has been created."
else
echo "Compilation failed. Please check the error messages above."
exit 1
fi