Webux Lab

By Studio Webux

Setup Zinc with Docker on Linux

TG
Tommy Gingras Studio Webux 2022-09-23

How to quickly setup zinc on a linux machine (Rocky Linux)

#!/bin/bash

USER=""
PUBLIC_IP=""
ZINC_ADMIN_PASSWORD=""
ZINC_USER_PASSWORD=""
ZINC_USER=""

##
## Docker Volumes
##
mkdir -p /DATA

##
## DOCKER
##
dnf install -y yum-utils

yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

dnf install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin

systemctl start docker
systemctl enable docker

##
## Hardening
##

###
### Updates
###
dnf update -y

###
### User
###
adduser ${USER}
passwd ${USER}
usermod -aG wheel ${USER}

###
### sshd
###
sed -i 's/.*PermitRootLogin .*/PermitRootLogin no/' /etc/ssh/sshd_config
sed -i 's/.*PasswordAuthentication .*/PasswordAuthentication no/' /etc/ssh/sshd_config
sed -i 's/.*PubkeyAuthentication .*/PubkeyAuthentication yes/' /etc/ssh/sshd_config
systemctl restart sshd

###
### Firewall
###
dnf install firewalld -y
systemctl enable firewalld
systemctl start firewalld

firewall-cmd --state

firewall-cmd --get-default-zone

firewall-cmd --permanent --add-port=22/tcp
firewall-cmd --permanent --add-port=4080/tcp
firewall-cmd --reload
firewall-cmd --list-ports

###
### NTP
###
dnf install chrony -y
systemctl start chronyd
systemctl enable chronyd

##
## ZInc Instance
##

### https://github.com/zinclabs/zinc

mkdir -p /data/zinc-1
chmod a+rwx /data/zinc-1
docker run \
    --restart=always \
    -d \
    -v /data/zinc-1/:/data \
    -p 4080:4080 \
    -e DATA_PATH="/data" \
    -e ZINC_FIRST_ADMIN_USER=${USER} \
    -e ZINC_FIRST_ADMIN_PASSWORD=${ZINC_ADMIN_PASSWORD} \
    -e ZINC_TELEMETRY=false \
    -e ZINC_SENTRY=false \
    -e ZINC_PROMETHEUS_ENABLE=false \
    --name zinc public.ecr.aws/h9e2j3o7/zinc:latest

##
## ZInc Setup
##

curl \
    -X POST \
    -u ${USER}:${ZINC_ADMIN_PASSWORD} \
    -H "Content-Type: application/json" \
    -d '{"_id":"'${ZINC_USER}'", "name":"'${ZINC_USER}'", "role":"user", "password":"'${ZINC_USER_PASSWORD}'"}' \
    http://${PUBLIC_IP}:4080/api/user

Voila !


Search