feat(install.sh): enhance installation script with MC download, service setup, and database initialization
This commit is contained in:
@@ -1,7 +1,78 @@
|
||||
#!/bin/sh
|
||||
|
||||
### DOWNLOAD MC
|
||||
if [ ! -f /usr/local/bin/mc ]; then
|
||||
curl https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc
|
||||
chmod +x /usr/local/bin/mc
|
||||
fi
|
||||
|
||||
### UPDATE SOFTWARE
|
||||
SERVER=minio-api.laoficina1782.com
|
||||
CUSTOMER=$1
|
||||
|
||||
mc --config-dir /tmp/mc-config alias set minio https://minio-api.laoficina1782.com minioadmin LIGTNbUgQr
|
||||
mc --config-dir /tmp/mc-config mirror --remove --overwrite --exclude "backend/docker/data/**" minio/$CUSTOMER /opt/sco/
|
||||
find /opt/sco/ -type d -exec chmod 755 {} \;
|
||||
find /opt/sco/ -type f -exec chmod 644 {} \;
|
||||
chmod -R 755 /opt/sco/frontend/
|
||||
|
||||
### TMP FOLDER
|
||||
cp /usr/lib/tmpfiles.d/fs-tmp.conf /etc/tmpfiles.d/
|
||||
echo "D /tmp 1777 root root -" > /etc/tmpfiles.d/fs-tmp.conf
|
||||
|
||||
### SERVICE
|
||||
find /opt/sco/resources/services/ -type f -exec sh -c 'cp "$1" "/etc/systemd/system/$(basename "$1")"' _ {} \;
|
||||
find /opt/sco/resources/services/ -type f -exec sh -c 'systemctl enable "$(basename "$1")"' _ {} \;
|
||||
systemctl daemon-reload
|
||||
|
||||
### AUTOSTART
|
||||
rsync -a --delete /opt/sco/resources/autostart/ /home/sco/.config/autostart/
|
||||
chown -R sco:users /home/sco/.config/autostart/*
|
||||
chmod -R 644 /home/sco/.config/autostart/*
|
||||
|
||||
### CRONTAB
|
||||
crontab -u root /opt/sco/resources/crontab/root.txt
|
||||
crontab -u sco /opt/sco/resources/crontab/sco.txt
|
||||
|
||||
### PYTHON
|
||||
find /opt/sco/resources/python/ -type d -iname "packages" | while read packages_dir; do
|
||||
parent_dir=$(dirname "$packages_dir")
|
||||
req_file="$parent_dir/requirements.txt"
|
||||
if [ -f "$req_file" ]; then
|
||||
pip install -q --no-index --find-links="$packages_dir" -r "$req_file"
|
||||
fi
|
||||
done
|
||||
|
||||
### DOCKER IMAGES
|
||||
mkdir -p /tmp/images/
|
||||
find /opt/sco/resources/images/ -type f -name '*.gz' -exec sh -c 'gunzip -c "$1" > /tmp/images/"$(basename "${1%.gz}")"' _ {} \;
|
||||
find /tmp/images/ -type f -iname "*.tar" -exec docker load -i {} \;
|
||||
|
||||
### INIT CPI-SERVER DATABASES AND LOGS FOLDERS
|
||||
mkdir -p /opt/sco/backend/docker/data/cpi-server/database
|
||||
mkdir -p /opt/sco/backend/docker/data/cpi-server/logs/devices
|
||||
mkdir -p /opt/sco/backend/docker/data/cpi-server/logs/service
|
||||
touch /opt/sco/backend/docker/data/cpi-server/database/configuration.db
|
||||
touch /opt/sco/backend/docker/data/cpi-server/database/connectivity.db
|
||||
touch /opt/sco/backend/docker/data/cpi-server/database/Identity.db
|
||||
touch /opt/sco/backend/docker/data/cpi-server/database/transaction.db
|
||||
touch /opt/sco/backend/docker/data/cpi-server/database/trialdata.db
|
||||
|
||||
### INIT SYMETRIC CONFIGURATION FILE
|
||||
mkdir -p /opt/sco/backend/docker/data/symmetric
|
||||
if [ ! -f /opt/sco/backend/docker/data/symmetric/engine.properties ]; then
|
||||
LOCAL_NODE=$(hostname)
|
||||
LOCAL_IP=$(ip route get 1.1.1.1 | grep -oP '(?<=src\s)\d+(\.\d+){3}')
|
||||
cat <<EOF > /opt/sco/backend/docker/data/symmetric/engine.properties
|
||||
engine.name=$LOCAL_NODE
|
||||
group.id=fullmesh
|
||||
external.id=$LOCAL_NODE
|
||||
db.driver=com.mysql.cj.jdbc.Driver
|
||||
db.url=jdbc:mysql://$LOCAL_IP:3306/sco
|
||||
db.user=root
|
||||
db.password=U2qs&U6LA9U2
|
||||
registration.url=
|
||||
sync.url=http://$LOCAL_IP:31415/sync/$LOCAL_NODE
|
||||
start.pulled.job=true
|
||||
job.purge.period.time.ms=7200000
|
||||
EOF
|
||||
fi
|
||||
Reference in New Issue
Block a user