Skip to content

Commit 37c13f1

Browse files
chore: miniconda installation script added
1 parent 93c929d commit 37c13f1

3 files changed

Lines changed: 94 additions & 2 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ It will install the SystemGuard app and its dependencies in the crontab and it w
4040

4141
- Anaconda3/Miniconda3
4242

43+
```bash
44+
# install miniconda3 if not installed already
45+
chmod +x src/scripts/install_miniconda.sh && ./src/scripts/install_miniconda.sh
46+
```
47+
4348
## Features 🚀
4449

4550
- Monitor server stats like CPU, Memory, Disk, and Network.

setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ check_status() {
320320
log "No cron job found for SystemGuard."
321321
fi
322322

323-
# Check if any of SystemGuard's services are running (example check for a specific service)
324-
if pgrep -f "dashboard.sh" > /dev/null; then
323+
log "Performing health check on localhost:5005..."
324+
if curl -s --head $HOST_URL | grep "200 OK" > /dev/null; then
325325
log "SystemGuard services are running."
326326
else
327327
log "SystemGuard services are not running."

src/scripts/install_miniconda.sh

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
3+
LOG_FILE="/tmp/miniconda_installation.log"
4+
MINICONDA_SCRIPT_URL="https://raw.githubusercontent.com/codeperfectplus/HackScripts/main/setup/install_miniconda.sh"
5+
MINICONDA_SCRIPT_PATH="/tmp/install_miniconda.sh"
6+
EXPECTED_CHECKSUM="abe9fde50a47831e7d17bee0d16af4bd5ea01e79ee6d744912a9bd3b31c1e4f0" # Replace with the actual checksum
7+
8+
log() {
9+
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOG_FILE"
10+
}
11+
12+
get_user_home() {
13+
if [ -n "$SUDO_USER" ]; then
14+
TARGET_USER="$SUDO_USER"
15+
else
16+
TARGET_USER="$LOGNAME"
17+
fi
18+
USER_HOME=$(eval echo ~$TARGET_USER)
19+
echo "$USER_HOME"
20+
}
21+
22+
USER_HOME=$(get_user_home)
23+
AUTO_CONFIRM=false
24+
25+
install_miniconda() {
26+
log "Starting Miniconda installation process."
27+
28+
if [ "$AUTO_CONFIRM" = false ]; then
29+
echo "Do you want to install Miniconda? (y/n)"
30+
read -r answer
31+
if [ ! "$answer" = "y" ]; then
32+
log "Miniconda installation skipped by user."
33+
return
34+
fi
35+
else
36+
log "Auto-confirmation enabled, proceeding with installation."
37+
fi
38+
39+
log "Downloading Miniconda installation script to /tmp directory."
40+
if wget "$MINICONDA_SCRIPT_URL" -O "$MINICONDA_SCRIPT_PATH"; then
41+
log "Miniconda installation script downloaded successfully."
42+
else
43+
log "Failed to download Miniconda installation script."
44+
return 1
45+
fi
46+
47+
log "Verifying script integrity using checksum."
48+
DOWNLOAD_CHECKSUM=$(sha256sum "$MINICONDA_SCRIPT_PATH" | awk '{print $1}')
49+
echo "Downloaded checksum: $DOWNLOAD_CHECKSUM"
50+
if [ "$DOWNLOAD_CHECKSUM" = "$EXPECTED_CHECKSUM" ]; then
51+
log "Checksum verification passed."
52+
else
53+
log "Checksum verification failed. Aborting installation."
54+
return 1
55+
fi
56+
57+
chmod +x "$MINICONDA_SCRIPT_PATH"
58+
59+
log "Running Miniconda installation script."
60+
if "$MINICONDA_SCRIPT_PATH"; then
61+
log "Miniconda installation script executed successfully."
62+
else
63+
log "Miniconda installation script execution failed."
64+
return 1
65+
fi
66+
67+
if [ -d "$USER_HOME/miniconda3" ]; then
68+
log "Miniconda installed successfully."
69+
else
70+
log "Miniconda installation failed."
71+
return 1
72+
fi
73+
74+
log "Cleaning up installation files."
75+
rm "$MINICONDA_SCRIPT_PATH" || log "Failed to remove installation script."
76+
77+
log "Miniconda installation process completed."
78+
}
79+
80+
while getopts "y" opt; do
81+
case $opt in
82+
y) AUTO_CONFIRM=true ;;
83+
*) echo "Usage: $0 [-y]"; exit 1 ;;
84+
esac
85+
done
86+
87+
install_miniconda

0 commit comments

Comments
 (0)