automated terminal push
This commit is contained in:
23
Dockerfile
23
Dockerfile
@@ -32,26 +32,3 @@ RUN bash installs/cron.bash
|
||||
COPY provision/startup/startup.sh /startup.sh
|
||||
|
||||
##
|
||||
|
||||
|
||||
####
|
||||
|
||||
COPY ping.script /tmp/ping.bash
|
||||
|
||||
RUN chmod +x /tmp/ping.bash
|
||||
|
||||
COPY ping2.script /tmp/ping2.bash
|
||||
|
||||
RUN chmod +x /tmp/ping2.bash
|
||||
|
||||
RUN ls -lha /tmp/
|
||||
|
||||
####
|
||||
|
||||
COPY cronfile /etc/cron.d/cronfile
|
||||
|
||||
# Give execution rights on the cron job
|
||||
RUN chmod 0644 /etc/cron.d/cronfile
|
||||
|
||||
# Apply the cron job
|
||||
RUN crontab -u root /etc/cron.d/cronfile
|
||||
|
||||
0
compose.template
Executable file → Normal file
0
compose.template
Executable file → Normal file
73
compose.yaml
Normal file
73
compose.yaml
Normal file
@@ -0,0 +1,73 @@
|
||||
services:
|
||||
|
||||
|
||||
##########################################
|
||||
##
|
||||
## orchestration / yankee-desktop-remix
|
||||
##
|
||||
##########################################001
|
||||
|
||||
yankee-desktop-remix-001:
|
||||
container_name: yankee-desktop-remix-001
|
||||
image: softwareshinobi/yankee-desktop-remix
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- yankee-nfs-downloads:/root/Downloads
|
||||
hostname: yankee-desktop-001
|
||||
ports:
|
||||
- "20012:22"
|
||||
- "20018:80"
|
||||
- "20019:5900"
|
||||
environment:
|
||||
TZ: America/Bogota
|
||||
USER_UID: 1000
|
||||
USER_GID: 1000
|
||||
USER: root
|
||||
PASSWORD: yankee
|
||||
HTTP_PASSWORD: yankee
|
||||
|
||||
|
||||
##########################################
|
||||
##
|
||||
## orchestration / yankee-desktop-remix
|
||||
##
|
||||
##########################################002
|
||||
|
||||
yankee-desktop-remix-002:
|
||||
container_name: yankee-desktop-remix-002
|
||||
image: softwareshinobi/yankee-desktop-remix
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- yankee-nfs-downloads:/root/Downloads
|
||||
hostname: yankee-desktop-002
|
||||
ports:
|
||||
- "20022:22"
|
||||
- "20028:80"
|
||||
- "20029:5900"
|
||||
environment:
|
||||
TZ: America/Bogota
|
||||
USER_UID: 1000
|
||||
USER_GID: 1000
|
||||
USER: root
|
||||
PASSWORD: yankee
|
||||
HTTP_PASSWORD: yankee
|
||||
|
||||
##########################################
|
||||
##
|
||||
## volumes / yankee-desktop-remix
|
||||
##
|
||||
##########################################
|
||||
|
||||
volumes:
|
||||
yankee-nfs-downloads:
|
||||
driver_opts:
|
||||
type: "nfs"
|
||||
o: nfsvers=4,addr=osiris.yankee.embanet.online,nolock,hard,rw
|
||||
device: ":/"
|
||||
|
||||
109
compose1x.bash
Executable file
109
compose1x.bash
Executable file
@@ -0,0 +1,109 @@
|
||||
#!/bin/bash
|
||||
|
||||
##
|
||||
|
||||
set -e
|
||||
|
||||
set -x
|
||||
|
||||
##
|
||||
|
||||
reset
|
||||
|
||||
clear
|
||||
|
||||
##
|
||||
|
||||
|
||||
##
|
||||
|
||||
processorCount=`grep -c '^processor' /proc/cpuinfo`
|
||||
|
||||
processorCount=1
|
||||
|
||||
echo "num cpus / "$processorCount
|
||||
|
||||
for i in $(seq 2 "$processorCount"); do
|
||||
|
||||
echo "Processing unit: $i"
|
||||
|
||||
##
|
||||
|
||||
rm -f compose.yaml
|
||||
|
||||
echo "services:" >> compose.yaml
|
||||
|
||||
##
|
||||
|
||||
for x in $(seq 1 "$processorCount"); do
|
||||
|
||||
i=$(printf "%03d" "$x")
|
||||
|
||||
# Create the service definition
|
||||
service_def=$(cat <<EOF
|
||||
|
||||
|
||||
##########################################
|
||||
##
|
||||
## orchestration / yankee-desktop-remix
|
||||
##
|
||||
##########################################$i
|
||||
|
||||
yankee-desktop-remix-$i:
|
||||
container_name: yankee-desktop-remix-$i
|
||||
image: softwareshinobi/yankee-desktop-remix
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- yankee-nfs-downloads:/root/Downloads
|
||||
hostname: yankee-desktop-$i
|
||||
ports:
|
||||
- "2${i}2:22"
|
||||
- "2${i}8:80"
|
||||
- "2${i}9:5900"
|
||||
environment:
|
||||
TZ: America/Bogota
|
||||
USER_UID: 1000
|
||||
USER_GID: 1000
|
||||
USER: root
|
||||
PASSWORD: yankee
|
||||
HTTP_PASSWORD: yankee
|
||||
|
||||
EOF
|
||||
)
|
||||
|
||||
# Append the service definition to compose.yaml
|
||||
echo "$service_def" >> compose.yaml
|
||||
|
||||
done
|
||||
|
||||
|
||||
# Add the volumes section ONCE after the loop (outside)
|
||||
cat <<EOF >> compose.yaml
|
||||
|
||||
##########################################
|
||||
##
|
||||
## volumes / yankee-desktop-remix
|
||||
##
|
||||
##########################################
|
||||
|
||||
volumes:
|
||||
yankee-nfs-downloads:
|
||||
driver_opts:
|
||||
type: "nfs"
|
||||
o: nfsvers=4,addr=osiris.yankee.embanet.online,nolock,hard,rw
|
||||
device: ":/"
|
||||
|
||||
EOF
|
||||
#... your commands to process each unit...
|
||||
|
||||
done
|
||||
##
|
||||
|
||||
docker compose down --remove-orphans
|
||||
|
||||
docker compose up -d
|
||||
|
||||
docker stats
|
||||
@@ -113,6 +113,13 @@ chmod +x *.sh
|
||||
|
||||
####
|
||||
|
||||
echo "scheduling the cron job"
|
||||
|
||||
bash smart-cron-builder.bash
|
||||
|
||||
echo "cron job scheduled"
|
||||
|
||||
####
|
||||
|
||||
exec /bin/tini -- supervisord -n -c /etc/supervisor/supervisord.conf
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
reset
|
||||
|
||||
clear
|
||||
|
||||
python3 smart-cron-builder.py
|
||||
@@ -1,149 +0,0 @@
|
||||
import datetime
|
||||
import subprocess
|
||||
import socket
|
||||
import os
|
||||
import requests
|
||||
|
||||
def buildLogDirectory():
|
||||
|
||||
return "/tmp/root/Downloads/.logs/"
|
||||
|
||||
def buildLogFileName():
|
||||
|
||||
logFileDir = buildLogDirectory()
|
||||
|
||||
try:
|
||||
|
||||
response = requests.get("https://api.ipify.org?format=json") # Or another similar service
|
||||
|
||||
response.raise_for_status() # Check for HTTP errors (4xx or 5xx)
|
||||
|
||||
ip_data = response.json()
|
||||
|
||||
server_ip = ip_data['ip']
|
||||
|
||||
print("server_ip / ",ip_data['ip'])
|
||||
|
||||
server_hostname = socket.gethostname()
|
||||
|
||||
print("server_hostname / ",server_hostname)
|
||||
|
||||
node_id= logFileDir + "yankee-node-" + server_ip + "-" + server_hostname + ".log"
|
||||
|
||||
return node_id
|
||||
|
||||
except socket.gaierror:
|
||||
|
||||
return "!!error!!"
|
||||
|
||||
def buildCronExecuteTime():
|
||||
|
||||
current_time = datetime.datetime.now()
|
||||
|
||||
new_minute = (current_time.minute + 2) % 60 # The % operator performs the wrap-around
|
||||
|
||||
print("new_minute / ",new_minute)
|
||||
|
||||
new_hour = current_time.hour + (current_time.minute + 5) // 60 # Integer division for hour increment
|
||||
|
||||
print("new_hour / ",new_hour)
|
||||
|
||||
cron = str(new_minute) + " " + str(new_hour) + " " + "* * *"
|
||||
|
||||
return cron
|
||||
|
||||
def buildCronSituation():
|
||||
|
||||
return buildCronExecuteTime() +" python3 /yankee-gnome-fire-consumer/consumer.py >> " + buildLogFileName() + " 2>&1"
|
||||
|
||||
####
|
||||
|
||||
cronTiming = buildCronExecuteTime()
|
||||
|
||||
print("cronTiming / ",cronTiming)
|
||||
|
||||
##
|
||||
|
||||
logger = buildLogFileName();
|
||||
|
||||
print("logger / ",logger)
|
||||
|
||||
##
|
||||
|
||||
cronFile = buildCronSituation();
|
||||
|
||||
print()
|
||||
print(cronFile)
|
||||
print()
|
||||
|
||||
|
||||
|
||||
def createLogDir():
|
||||
|
||||
log_dir = buildLogDirectory()
|
||||
|
||||
print("creating log dir",log_dir)
|
||||
|
||||
try:
|
||||
if not os.path.exists(log_dir): # Check if the directory exists
|
||||
os.makedirs(log_dir) # Create the directory (and any necessary parent directories)
|
||||
print(f"Directory '{log_dir}' created successfully.")
|
||||
else:
|
||||
print(f"Directory '{log_dir}' already exists.")
|
||||
return True # Directory exists or was created successfully
|
||||
|
||||
except OSError as e:
|
||||
print(f"Error creating directory '{log_dir}': {e}")
|
||||
return False
|
||||
|
||||
##
|
||||
|
||||
|
||||
def writeCrontabSituation():
|
||||
|
||||
file_path ="crontabX"
|
||||
|
||||
crontab_text = """
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
* * * * * python3 /yankee-gnome-fire-consumer/consumer.py >> /var/log/yankee-downloader.log 2>&1
|
||||
|
||||
* * * * * /tmp/ping2.bash >> /var/log/cron.log 2>&1"""
|
||||
|
||||
try:
|
||||
# Check if the file exists and delete if it does
|
||||
if os.path.exists(file_path):
|
||||
os.remove(file_path)
|
||||
|
||||
with open(file_path, "w") as f:
|
||||
|
||||
sep="\n"
|
||||
|
||||
f.write("SHELL=/bin/bash")
|
||||
f.write(sep)
|
||||
f.write(sep)
|
||||
|
||||
f.write("PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
|
||||
f.write(sep)
|
||||
f.write(sep)
|
||||
|
||||
f.write(buildCronSituation())
|
||||
f.write(sep)
|
||||
f.write(sep)
|
||||
|
||||
f.write("* * * * * /tmp/ping2.bash >> /var/log/cron.log 2>&1")
|
||||
f.write(sep)
|
||||
f.write(sep)
|
||||
|
||||
print(f"Crontab written to '{file_path}' successfully.")
|
||||
|
||||
return True
|
||||
|
||||
except OSError as e:
|
||||
print(f"Error writing to file '{file_path}': {e}")
|
||||
return False
|
||||
|
||||
####################
|
||||
createLogDir()
|
||||
|
||||
writeCrontabSituation()
|
||||
Reference in New Issue
Block a user