#!/bin/bash

# shellcheck disable=SC2034

#region JSON
CMD_LIST_CONFIG_JSON=$(cat <<EOF
[
  {
    "section": "APACHE",
    "items": [
      {"label": "Restart apache", "cmd": "apache2ctl restart", "bin": "apache2ctl"},
      {"label": "Status", "cmd": "service apache2 status", "bin": "apache2"}
    ]
  },
  {
    "section": "SYSTEM",
    "items": [
      {"label": "Edit main cron", "cmd": "crontab -e", "bin": "crontab"},
      {"label": "Restart service", "cmd": "/etc/init.d/service_name restart"},
      {"label": "Display journal", "cmd": "journalctl -xe", "bin": "journalctl"},
      {"label": "Reload .bashrc", "cmd": "source ~/.bashrc"}
    ]
  },
   {
     "section": "SECURITY",
     "items": [
       {"label": "Firewall rules", "cmd": "ufw status verbose", "bin": "ufw"}
     ]
   },
  {
    "section": "TOOLS",
    "items": [
      {"label": "Disk space", "cmd": "ncdu", "bin": "ncdu"},
      {"label": "Network stats", "cmd": "htop", "bin": "htop"}
    ]
  },
  {
    "section": "UTILS",
    "items": [
      {"label": "Display loaded functions", "cmd": "declare -F"}
    ]
  },
  {
    "section": "NETWORK DEBUG",
    "items": [
      {"label": "Port debug", "cmd": "ss -tulnw | column -t"},
      {"label": "Port tcp opened ext", "cmd": "ss -tlnw | column -t"},
      {"label": "Unlock 1024 port for not Root user", "cmd": "setcap 'cap_net_bind_service=+ep' /usr/lib/jellyfin/bin/jellyfin"},
      {"label": "Test SSL Validity", "cmd" : "openssl x509 -in /var/lib/step-ca/.step/certs/root_ca.crt -noout -dates"}
   ]
  },
  {
    "section": "SYSTEM DEBUG",
    "items": [
      {"label": "Exec errors", "cmd": "journalctl -xe -p err"},
      {"label": "Boot errors", "cmd": "journalctl -b -p err"},
      {"label": "Service errors", "cmd": "systemctl --failed"}
    ]
  },
  {
    "section": "PROXMOX",
    "items": [
      {"label": "Change vm password", "cmd": "pct exec ID -- passwd root","bin": "pct"},
      {"label": "Enter a VM without pass", "cmd": "pct enter ID","bin": "pct"},
      {"label": "Mount from Prox to VM", "cmd": "pct set ID -mp0 /mnt/synology_series,mp=/srv/media/series","bin": "pct"},
      {"label": "Change VM configuration", "cmd": "nano /etc/pve/lxc/ID.conf","bin": "pct"},
      {"label": "Restart VM", "cmd": "pct stop ID && pct start ID","bin": "pct"}
    ]
  }
]
EOF
)
#endregion