Skip to content

Commit 1b96a86

Browse files
Refactor README.md and install_influx.sh scripts
1 parent bec9223 commit 1b96a86

2 files changed

Lines changed: 24 additions & 27 deletions

File tree

README.md

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,6 @@ System Guard is a Flask app designed to monitor server stats such as CPU, Memory
1818
- Role-based dashboards tailored for Developer, Admin, IT Manager, and Manager roles (upcoming feature).
1919
- Update security updates with a single click or automatically update to the latest version to simplify maintenance.
2020

21-
## Old Features 🚀
22-
23-
- Administrators can manage user accounts by creating, updating, or deleting users.
24-
- Admin-level access is required for configuring settings, managing users, and adjusting security and notification - preferences.
25-
- Historical performance data can be viewed as charts, aiding in trend analysis.
26-
- Supports network speed testing directly from the server.
27-
- Provides the ability to terminate resource-heavy processes with a single command.
28-
- Real-time server metric monitoring keeps data consistently updated.
29-
- The interface is responsive and optimized for various devices including mobile, tablets, and desktops.
30-
- The system can automatically update to the latest version to simplify maintenance.
31-
- Installation can be done quickly via a bash script for easy setup.
32-
- Notifications are sent to users and admins when a process is manually terminated.
33-
- Offers website monitoring tasks that trigger email alerts when a website becomes unavailable.
34-
- Configurable email alerts for various actions across the server.
35-
- Option to download historical data in CSV format for detailed analysis (upcoming feature).
36-
- Server status monitoring with alerts for server downtime or recovery (upcoming feature).
37-
3821
## Get started 🛠️
3922

4023
- Check the [Installation.md](/src/docs/installation.md) file for installation instructions.

src/scripts/install_influx.sh

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,33 @@ CONTAINER_NAME="influxdb"
66
NETWORK_NAME="influx_network"
77
DATA_DIR="./influxdb_data"
88
INFLUXDB_USER="admin" # Change this to your desired username
9-
INFLUXDB_PASSWORD="admin_password" # Change this to your desired password
10-
INFLUXDB_ORG="systemguard" # Change this to your desired organization name
9+
INFLUXDB_PASSWORD="admin_password" # Change this to your desired password
10+
INFLUXDB_ORG="systemguard" # Change this to your desired organization name
1111
INFLUXDB_BUCKET="system_metrics" # Change this to your desired initial bucket (database) name
12-
# demo influxdb token | change this to your own token
13-
INFLUXDB_TOKEN=""
12+
INFLUXDB_TOKEN="" # Demo InfluxDB token | Change this to your own token
1413

1514
# Export the INFLUXDB_TOKEN to be used later in your app
16-
export "INFLUXDB_TOKEN"=$INFLUXDB_TOKEN
15+
export INFLUXDB_TOKEN="$INFLUXDB_TOKEN"
16+
17+
# Function to get the appropriate username, even when running as root
18+
get_user_name() {
19+
if [ "$(whoami)" = "root" ]; then
20+
LOGNAME_USER=$(logname 2>/dev/null)
21+
if [ $? -ne 0 ]; then
22+
USER_NAME=$(cat /etc/passwd | grep '/home' | cut -d: -f1 | tail -n 1)
23+
else
24+
USER_NAME=$LOGNAME_USER
25+
fi
26+
else
27+
USER_NAME=$(whoami)
28+
fi
29+
echo "$USER_NAME"
30+
}
31+
32+
USER_NAME=$(get_user_name)
1733

1834
# Create a data directory for InfluxDB
19-
rm -rf $DATA_DIR
20-
mkdir -p $DATA_DIR
35+
sudo -u "$USER_NAME" mkdir -p "$DATA_DIR"
2136

2237
# Stop and remove existing InfluxDB container if it exists
2338
if [ "$(docker ps -aq -f name=$CONTAINER_NAME)" ]; then
@@ -33,7 +48,7 @@ if sudo lsof -i :8086; then
3348
sudo fuser -k 8086/tcp
3449
fi
3550

36-
# Create a Docker network
51+
# Create a Docker network if it doesn't exist
3752
echo "Creating Docker network..."
3853
docker network create $NETWORK_NAME || true # Avoid error if the network already exists
3954

@@ -48,7 +63,7 @@ docker run -d \
4863
--network $NETWORK_NAME \
4964
--restart=always \
5065
-p 8086:8086 \
51-
-v $PWD/$DATA_DIR:/var/lib/influxdb2 \
66+
-v "$PWD/$DATA_DIR:/var/lib/influxdb2" \
5267
-e DOCKER_INFLUXDB_INIT_MODE=setup \
5368
-e DOCKER_INFLUXDB_INIT_USERNAME=$INFLUXDB_USER \
5469
-e DOCKER_INFLUXDB_INIT_PASSWORD=$INFLUXDB_PASSWORD \
@@ -57,6 +72,5 @@ docker run -d \
5772
-e DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=$INFLUXDB_TOKEN \
5873
influxdb:$INFLUXDB_VERSION
5974

60-
6175
# Output completion message
6276
echo "InfluxDB setup completed! Access it at http://localhost:8086 with your credentials."

0 commit comments

Comments
 (0)