first commit
This commit is contained in:
commit
867db34472
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
16
.idea/dev.iml
Normal file
16
.idea/dev.iml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/backend/auth/data" isTestSource="false" packagePrefix="Authentication" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/backend/bee/data" isTestSource="false" packagePrefix="Bee" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/backend/file/data" isTestSource="false" packagePrefix="File" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/backend/homepage/data" isTestSource="false" packagePrefix="Homepage" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/backend/mytube/data" isTestSource="false" packagePrefix="MyTube" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/backend/notification/data" isTestSource="false" packagePrefix="Notification" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/systems/backend/mytube/data" isTestSource="false" packagePrefix="MyTube" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/dev.iml" filepath="$PROJECT_DIR$/.idea/dev.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
22
.idea/php.xml
Normal file
22
.idea/php.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="MessDetectorOptionsConfiguration">
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PHPCSFixerOptionsConfiguration">
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PHPCodeSnifferOptionsConfiguration">
|
||||||
|
<option name="highlightLevel" value="WARNING" />
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PhpProjectSharedConfiguration" php_language_level="8.2">
|
||||||
|
<option name="suggestChangeDefaultLanguageLevel" value="false" />
|
||||||
|
</component>
|
||||||
|
<component name="PhpStanOptionsConfiguration">
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PsalmOptionsConfiguration">
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/vcs.xml
Normal file
8
.idea/vcs.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/systems/backend/mytube" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/systems/frontend/mytube" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
12
bin/denv
Executable file
12
bin/denv
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ENVIRONMENT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/../../
|
||||||
|
|
||||||
|
denv() {
|
||||||
|
if [ ! -z $1 ]
|
||||||
|
then
|
||||||
|
$ENVIRONMENT_DIR/$1
|
||||||
|
else
|
||||||
|
cd $ENVIRONMENT_DIR
|
||||||
|
fi
|
||||||
|
}
|
||||||
28
bin/drun
Executable file
28
bin/drun
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
drun() {
|
||||||
|
# Überprüfen, ob die richtige Anzahl Argumente übergeben wurden
|
||||||
|
if [ $# -lt 2 ]; then
|
||||||
|
echo "Verwendung: drun <Container-Name> <Befehl>"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Container-Namen extrahieren
|
||||||
|
local CONTAINER_NAME="$1"
|
||||||
|
shift # Das erste Argument entfernen
|
||||||
|
|
||||||
|
# Den Rest der Argumente als Befehlszeichenfolge zusammenfügen
|
||||||
|
local COMMAND="$@"
|
||||||
|
|
||||||
|
# Container-ID mithilfe des Container-Namens finden
|
||||||
|
local CONTAINER_ID=$(docker ps -qf "name=$CONTAINER_NAME-app")
|
||||||
|
|
||||||
|
# Überprüfen, ob der Container gefunden wurde
|
||||||
|
if [ -z "$CONTAINER_ID" ]; then
|
||||||
|
echo "Container '$CONTAINER_NAME' wurde nicht gefunden."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Befehl im Container ausführen
|
||||||
|
docker exec -it "$CONTAINER_ID" $COMMAND
|
||||||
|
}
|
||||||
11
bin/git
Executable file
11
bin/git
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
acp() {
|
||||||
|
git add .
|
||||||
|
git commit -m "$@"
|
||||||
|
git push
|
||||||
|
}
|
||||||
|
|
||||||
|
co() {
|
||||||
|
git checkout $1
|
||||||
|
}
|
||||||
19
bin/script/exec
Executable file
19
bin/script/exec
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
COMMAND="$@"
|
||||||
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
|
||||||
|
echo "Execute ${COMMAND} in denv"
|
||||||
|
|
||||||
|
#MAC
|
||||||
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
docker compose -f "${SCRIPT_DIR}/../../docker/docker-compose-mac.yml" $COMMAND
|
||||||
|
|
||||||
|
#LINUX
|
||||||
|
elif [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||||
|
docker compose -f "${SCRIPT_DIR}/../../docker/docker-compose.yml" $COMMAND
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "Dieses Skript wird auf deinem Gerät nicht unterstützt"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
20
bin/script/foreachSystem
Executable file
20
bin/script/foreachSystem
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
EXEC_DIR=$(pwd)
|
||||||
|
FILE_TO_EXECUTE=$1
|
||||||
|
|
||||||
|
if [ ! -z $1 ]
|
||||||
|
then
|
||||||
|
echo "Execute " $1 " in each system"
|
||||||
|
else
|
||||||
|
echo "Execute foreachSystem failed, because no parameter was provided"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
for SYSTEM in systems/*/*/ ; do
|
||||||
|
echo "executing ${FILE_TO_EXECUTE} in ${SYSTEM}"
|
||||||
|
cd $SYSTEM
|
||||||
|
./bin/script/$FILE_TO_EXECUTE
|
||||||
|
cd $EXEC_DIR
|
||||||
|
done
|
||||||
10
bin/script/prune
Executable file
10
bin/script/prune
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
docker stop $(docker ps -aq)
|
||||||
|
|
||||||
|
docker system prune -f
|
||||||
|
|
||||||
|
docker network create homepage
|
||||||
|
|
||||||
|
./pull
|
||||||
|
./bin/script/init
|
||||||
15
bin/script/pull
Executable file
15
bin/script/pull
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
EXEC_DIR=$(pwd)
|
||||||
|
|
||||||
|
echo "Execute git pull in each system"
|
||||||
|
|
||||||
|
#echo "denv"
|
||||||
|
#git pull
|
||||||
|
|
||||||
|
for SYSTEM in $EXEC_DIR/systems/*/*/ ; do
|
||||||
|
echo $SYSTEM
|
||||||
|
cd $SYSTEM
|
||||||
|
git pull
|
||||||
|
cd $EXEC_DIR
|
||||||
|
done
|
||||||
54
bin/script/setup
Executable file
54
bin/script/setup
Executable file
@ -0,0 +1,54 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo $OSTYPE
|
||||||
|
|
||||||
|
#MAC
|
||||||
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
home="$HOME"
|
||||||
|
|
||||||
|
#LINUX
|
||||||
|
elif [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||||
|
home="$HOME"
|
||||||
|
else
|
||||||
|
echo "Dieses Skript wird nicht unter macOS oder Linux unterstützt."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
script_path=$(pwd)
|
||||||
|
environment=$(basename $script_path)
|
||||||
|
|
||||||
|
echo "source ~/$environment/bin/script/denv" >> ~/.profile
|
||||||
|
echo "source ~/$environment/bin/script/drun" >> ~/.profile
|
||||||
|
echo "source ~/$environment/bin/script/git" >> ~/.profile
|
||||||
|
|
||||||
|
echo Running in $script_path
|
||||||
|
echo environment = $environment
|
||||||
|
|
||||||
|
# $1 = frontend/backend
|
||||||
|
# $2 = repo name
|
||||||
|
fetch_repository() {
|
||||||
|
if [ ! -d "$1" ];
|
||||||
|
then
|
||||||
|
echo "Create $1"
|
||||||
|
mkdir -p "$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $1
|
||||||
|
|
||||||
|
if [ ! -d "$2" ];
|
||||||
|
then
|
||||||
|
gh repo clone TheFlawww/$2-$1 $2
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $script_path
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#fetch all backends
|
||||||
|
fetch_repository backend weedkeeper
|
||||||
|
|
||||||
|
#fetch all frontends
|
||||||
|
fetch_repository frontend weedkeeper
|
||||||
|
|
||||||
|
# initialize
|
||||||
|
./bin/script/init
|
||||||
14
bin/script/upgrade
Executable file
14
bin/script/upgrade
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
|
||||||
|
$SCRIPT_DIR/pull
|
||||||
|
source $SCRIPT_DIR/../source
|
||||||
|
|
||||||
|
drun weedkeeper-backend composer da
|
||||||
|
drun weedkeeper-backend composer install
|
||||||
|
drun weedkeeper-backend composer dmm
|
||||||
|
drun weedkeeper-backend composer console rbac:update
|
||||||
|
|
||||||
|
drun weedkeeper-frontend npm i
|
||||||
|
drun weedkeeper-frontend npm run build
|
||||||
7
bin/source
Executable file
7
bin/source
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
|
||||||
|
source $SCRIPT_DIR/denv
|
||||||
|
source $SCRIPT_DIR/drun
|
||||||
|
source $SCRIPT_DIR/git
|
||||||
4
build
Executable file
4
build
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
./bin/script/exec build
|
||||||
|
./bin/script/foreachSystem build
|
||||||
1
docker/.gitignore
vendored
Normal file
1
docker/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
letsencrypt/*
|
||||||
27
docker/docker-compose.yml
Normal file
27
docker/docker-compose.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
networks:
|
||||||
|
weedkeeper:
|
||||||
|
name: weedkeeper
|
||||||
|
|
||||||
|
services:
|
||||||
|
traefik:
|
||||||
|
image: traefik:v3.0
|
||||||
|
networks:
|
||||||
|
- weedkeeper
|
||||||
|
command:
|
||||||
|
- "--providers.docker=true"
|
||||||
|
- "--entrypoints.web.address=:80"
|
||||||
|
- "--entrypoints.web.http.redirections.entrypoint.to=websecure"
|
||||||
|
- "--entrypoints.web.http.redirections.entrypoint.scheme=https"
|
||||||
|
- "--entrypoints.websecure.address=:443"
|
||||||
|
- "--certificatesresolvers.le.acme.tlschallenge=true"
|
||||||
|
- "--certificatesresolvers.le.acme.email=florian_feistel@outlook.de"
|
||||||
|
- "--certificatesresolvers.le.acme.storage=/letsencrypt/acme.json"
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
- "443:443"
|
||||||
|
- "8080:8080"
|
||||||
|
volumes:
|
||||||
|
- "./letsencrypt:/letsencrypt"
|
||||||
|
- "/var/run/docker.sock:/var/run/docker.sock"
|
||||||
|
labels:
|
||||||
|
- "traefik.http.routers.traefik.rule=Host(`traefik.weedkeeper.de`)"
|
||||||
4
down
Executable file
4
down
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
./bin/script/exec down
|
||||||
|
./bin/script/foreachSystem down
|
||||||
4
init
Executable file
4
init
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
./bin/script/exec init
|
||||||
|
./bin/script/foreachSystem init
|
||||||
37
python/capture-thermometer-data.py
Normal file
37
python/capture-thermometer-data.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import asyncio
|
||||||
|
import json
|
||||||
|
from datetime import datetime
|
||||||
|
from bleak import BleakScanner
|
||||||
|
|
||||||
|
async def handle_discovery(device, advertisement_data):
|
||||||
|
if device.address == "DB:17:6C:7D:81:F6":
|
||||||
|
keys = list(advertisement_data.manufacturer_data.keys())
|
||||||
|
humKey = keys[len(keys)-1]
|
||||||
|
battery = humKey & 0xFF
|
||||||
|
temperature = (humKey >> 8)/10.0
|
||||||
|
if humKey < 32767: #If Key is bigger than a smallint, temperature is lower than one byte (256)
|
||||||
|
temperature = temperature + 25.6
|
||||||
|
|
||||||
|
data = {}
|
||||||
|
data['temp'] = temperature
|
||||||
|
data['battery'] = battery / 256.0;
|
||||||
|
data['humid'] = advertisement_data.manufacturer_data[humKey][1]
|
||||||
|
data['timestamp'] = datetime.now().strftime("%d.%m.%Y %H:%M:%S")
|
||||||
|
|
||||||
|
jsonString = json.dumps(data)
|
||||||
|
with open("/home/flo/local-weedkeeper/systems/backend/weedkeeper/var/temperature.data", "a") as dataFile:
|
||||||
|
dataFile.write(jsonString+",\n")
|
||||||
|
#print(jsonString)
|
||||||
|
await scanner.stop()
|
||||||
|
|
||||||
|
async def scan():
|
||||||
|
global scanner
|
||||||
|
scanner = BleakScanner(handle_discovery)
|
||||||
|
await scanner.start()
|
||||||
|
await asyncio.sleep(10)
|
||||||
|
await scanner.stop()
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
await scan()
|
||||||
|
|
||||||
|
asyncio.run(main())
|
||||||
4
stop
Executable file
4
stop
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
./bin/script/exec stop
|
||||||
|
./bin/script/foreachSystem stop
|
||||||
2
systems/.gitignore
vendored
Normal file
2
systems/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
||||||
Loading…
Reference in New Issue
Block a user