diff --git a/Dockerfile-DB b/Dockerfile-DB new file mode 100644 index 0000000..ae58143 --- /dev/null +++ b/Dockerfile-DB @@ -0,0 +1,2 @@ +FROM mysql:5.7 +ADD FabAccess.sql /docker-entrypoint-initdb.d \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 0a62865..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,54 +0,0 @@ -pipeline { - agent any - post { - failure { - updateGitlabCommitStatus name: 'build', state: 'failed' - } - success { - updateGitlabCommitStatus name: 'build', state: 'success' - } - aborted { - updateGitlabCommitStatus name: 'build', state: 'canceled' - } - } - options { - gitLabConnection('GitLab') - } - triggers { - gitlab(triggerOnPush: true, triggerOnMergeRequest: true, branchFilterType: 'All') - } - stages { - stage("build") { - steps { - updateGitlabCommitStatus name: 'build', state: 'running' - podTemplate( - containers: [ - containerTemplate(name: 'docker-image-build', image: 'mgoltzsche/podman', ttyEnabled: true, command: 'cat', privileged: true), - ]) { - node(POD_LABEL) { - updateGitlabCommitStatus name: 'build', state: 'pending' - checkout([$class: 'GitSCM', branches: [ - [name: '*/main'] - ], userRemoteConfigs: [ - [url: 'https://gitlab.com/luca_lutz/fabaccess.git'] - ]]) - container('docker-image-build') { - withCredentials([ - usernamePassword(credentialsId: 'docker.credentials', - usernameVariable: 'DOCKER_USERNAME', - passwordVariable: 'DOCKER_PASSWORD') - ]) { - sh 'echo $(date +%s) > /time' - sh 'echo "nameserver 10.12.42.2" > /etc/resolv.conf' - sh 'podman build --tag docker.sfz-aalen.space/hackwerk/fabaccess:$(cat /time) .' - sh 'podman login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD} docker.sfz-aalen.space' - sh 'podman push docker.sfz-aalen.space/hackwerk/fabaccess:$(cat /time)' - } - } - } - } - } - } - } -} - diff --git a/README.md b/README.md index ad8cb98..cd795f6 100644 --- a/README.md +++ b/README.md @@ -19,5 +19,7 @@ MQTT_USERNAME=user MQTT_PASSWORD=password MQTT_BROKER=mqtt MQTT_CLIENT=FabMan + +MACHINES=[[1,"lasercutter","sfz.lasercutter.trotec"],[2,"sfz.holzwerkstatt.kreissaege","kreissaege"]] ``` diff --git a/fab_access/mqtt_helper.py b/fab_access/mqtt_helper.py deleted file mode 100644 index bd5fc50..0000000 --- a/fab_access/mqtt_helper.py +++ /dev/null @@ -1,32 +0,0 @@ -from paho.mqtt import client as mqtt_client - -import config - - -def on_connect(client, userdata, flags, rc): - if rc == 0: - print("Connected to MQTT Broker!") - else: - raise Exception("Failed to connect, return code %d\n", rc) - - -class MQTTHelper(): - def __init__(self, client_name: str, username: str, password: str, broker: str, port: int): - client = mqtt_client.Client(client_name) - if username and password: - client.username_pw_set(username, password) - else: - print("Connecting to MQTT without credentials") - client.on_connect = on_connect - try: - client.connect(broker, port) - except Exception as e: - raise Exception(f"Error connecting to MQTT {broker}:{port}") from e - self.client = client - - def subscribe(self, topic: str, handler): - self.client.subscribe(topic) - self.client.on_message = handler - - def loop_forever(self): - self.client.loop_forever() diff --git a/sql/FabAccess.sql b/sql/FabAccess.sql deleted file mode 100644 index d1d9358..0000000 --- a/sql/FabAccess.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE ReaderPlug( - ReaderID INT NOT NULL, - PlugName VARCHAR(255) NOT NULL, - PermissionPath VARCHAR(255) NOT NULL, - Status BOOLEAN NOT NULL, - LastUser VARCHAR(255) NOT NULL -); - -INSERT INTO ReaderPlug( - ReaderID, PlugName, PermissionPath, Status, LastUser -) VALUES (1, 'lasercutter', 'sfz.lasercutter.trotec', false, 'luca.lutz');