Skip to content

Commit

Permalink
chore: Update installation instructions and scripts for Security Cam …
Browse files Browse the repository at this point in the history
…service
  • Loading branch information
infinitel8p committed Aug 21, 2024
1 parent ec71d84 commit 29806df
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
46 changes: 46 additions & 0 deletions client/tbd/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Installation
1. Clone the Repository

```bash
sudo git clone https://github.com/infinitel8p/Security-Cam.git /opt/security-cam
```


2. Create the Service File
```bash
sudo nano /etc/systemd/system/security-cam.service
```

Add the following to the file:

```shell
[Unit]
Description=Security Cam Flask and Node.js Servers
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/opt/security-cam
ExecStart=/bin/bash -c '
git pull &&
chmod +x /opt/security-cam/install_requirements.sh &&
cd /opt/security-cam/server && npm install &&
cd /opt/security-cam/client &&
bash /opt/security-cam/install_requirements.sh &&
chmod +x /opt/security-cam/start.sh &&
/opt/security-cam/start.sh
'
Restart=on-failure
[Install]
WantedBy=multi-user.target
```

3. Reload the systemd manager configuration: `sudo systemctl daemon-reload`

4. Enable the service to start on boot: `sudo systemctl enable security-cam.service`

5. Start the service: `sudo systemctl start security-cam.service`

6. Check the status of the service: `sudo systemctl status security-cam.service`
24 changes: 24 additions & 0 deletions install_requirements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# Update package list
sudo apt-get update

# Install system dependencies
sudo apt-get install -y python3 python3-pip nodejs npm

# Path to the requirements.txt file
REQUIREMENTS_FILE="/opt/security-cam/requirements.txt"

# Loop through each line in requirements.txt
while IFS= read -r package
do
# Extract the package name before any version specifier (e.g., flask==2.0 -> flask)
package_name=$(echo "$package" | cut -d '=' -f 1)

# Install the package using apt-get if available, otherwise fallback to pip
if apt-cache search --names-only "^python3-$package_name$" | grep -q "^python3-$package_name"; then
sudo apt-get install -y python3-$package_name
else
sudo pip3 install "$package" --break-system-packages
fi
done < "$REQUIREMENTS_FILE"
File renamed without changes.
9 changes: 9 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# Start the Node.js server
cd /opt/security-cam/server || exit
npm run dev &

# Start the Flask server
cd /opt/security-cam/client || exit
python3 main.py &

0 comments on commit 29806df

Please sign in to comment.