From 4175b8d5f6766b26bd7f1863d2a1ef1bd2d6bcfe Mon Sep 17 00:00:00 2001 From: tteckster Date: Wed, 22 Mar 2023 20:48:20 -0400 Subject: [PATCH] The latest iteration of the scripts (#1220) --- ct/adguard-v5.sh | 444 ------------- ct/adguard.sh | 87 +++ ct/alpine-adguard-v5.sh | 486 --------------- ct/alpine-adguard.sh | 87 +++ ct/alpine-docker-v5.sh | 465 -------------- ct/alpine-docker.sh | 77 +++ ct/alpine-grafana-v5.sh | 482 -------------- ct/alpine-grafana.sh | 94 +++ ct/alpine-v5.sh | 419 ------------- ct/alpine-vaultwarden-v5.sh | 456 -------------- ct/alpine-vaultwarden.sh | 87 +++ ct/alpine-zigbee2mqtt-v5.sh | 460 -------------- ct/alpine-zigbee2mqtt.sh | 79 +++ ct/alpine.sh | 70 +++ ct/{archlinux-v5.sh => archlinux.sh} | 3 +- ct/audiobookshelf-v5.sh | 421 ------------- ct/audiobookshelf.sh | 69 +++ ct/autobrr-v5.sh | 437 ------------- ct/autobrr.sh | 80 +++ ct/blocky-v5.sh | 425 ------------- ct/blocky.sh | 67 ++ ct/casaos-v5.sh | 453 -------------- ct/casaos.sh | 70 +++ ct/changedetection-v5.sh | 426 ------------- ct/changedetection.sh | 69 +++ ct/cronicle-v5.sh | 468 -------------- ct/cronicle.sh | 108 ++++ ct/daemonsync-v5.sh | 427 ------------- ct/daemonsync.sh | 69 +++ ct/dashy-v5.sh | 452 -------------- ct/dashy.sh | 95 +++ ct/debian-v5.sh | 419 ------------- ct/debian.sh | 67 ++ ct/deconz-v5.sh | 442 ------------- ct/deconz.sh | 69 +++ ct/deluge-v5.sh | 427 ------------- ct/deluge.sh | 70 +++ ct/devuan-v5.sh | 419 ------------- ct/devuan.sh | 67 ++ ct/docker-v5.sh | 446 ------------- ct/docker.sh | 68 ++ ct/emby-v5.sh | 460 -------------- ct/emby.sh | 80 +++ ct/emqx-v5.sh | 421 ------------- ct/emqx.sh | 69 +++ ct/esphome-v5.sh | 434 ------------- ct/esphome.sh | 77 +++ ct/go2rtc-v5.sh | 421 ------------- ct/go2rtc.sh | 70 +++ ct/grafana-v5.sh | 427 ------------- ct/grafana.sh | 70 +++ ct/grocy-v5.sh | 426 ------------- ct/grocy.sh | 69 +++ ct/heimdalldashboard-v5.sh | 506 --------------- ct/heimdalldashboard.sh | 149 +++++ ct/homeassistant-core-v5.sh | 586 ------------------ ct/homeassistant-core.sh | 216 +++++++ ct/homeassistant-v5.sh | 520 ---------------- ct/homeassistant.sh | 138 +++++ ct/homebridge-v5.sh | 427 ------------- ct/homebridge.sh | 70 +++ ct/homepage-v5.sh | 433 ------------- ct/homepage.sh | 76 +++ ct/homer-v5.sh | 450 -------------- ct/homer.sh | 93 +++ ct/hyperion-v5.sh | 441 ------------- ct/hyperion.sh | 71 +++ ct/influxdb-v5.sh | 425 ------------- ct/influxdb.sh | 68 ++ ct/iobroker-v5.sh | 427 ------------- ct/iobroker.sh | 70 +++ ct/jackett-v5.sh | 425 ------------- ct/jackett.sh | 69 +++ ct/jellyfin-v5.sh | 450 -------------- ct/jellyfin.sh | 70 +++ ct/k0s-v5.sh | 425 ------------- ct/k0s.sh | 68 ++ ct/kavita-v5.sh | 426 ------------- ct/kavita.sh | 69 +++ ct/keycloak-v5.sh | 428 ------------- ct/keycloak.sh | 71 +++ ct/lidarr-v5.sh | 426 ------------- ct/lidarr.sh | 69 +++ ct/magicmirror-v5.sh | 429 ------------- ct/magicmirror.sh | 72 +++ ct/mariadb-v5.sh | 425 ------------- ct/mariadb.sh | 68 ++ ct/meshcentral-v5.sh | 427 ------------- ct/meshcentral.sh | 70 +++ ct/motioneye-v5.sh | 426 ------------- ct/motioneye.sh | 69 +++ ct/mqtt-v5.sh | 424 ------------- ct/mqtt.sh | 68 ++ ct/n8n-v5.sh | 427 ------------- ct/n8n.sh | 70 +++ ct/navidrome-v5.sh | 437 ------------- ct/navidrome.sh | 80 +++ ct/nextcloudpi-v5.sh | 427 ------------- ct/nextcloudpi.sh | 70 +++ ct/nginxproxymanager-v5.sh | 535 ---------------- ct/nginxproxymanager.sh | 180 ++++++ ct/nocodb-v5.sh | 429 ------------- ct/nocodb.sh | 72 +++ ct/node-red-v5.sh | 462 -------------- ct/node-red.sh | 105 ++++ ct/omada-v5.sh | 439 ------------- ct/omada.sh | 70 +++ ct/omv-v5.sh | 438 ------------- ct/omv.sh | 70 +++ ct/openhab-v5.sh | 428 ------------- ct/openhab.sh | 71 +++ ct/paperless-ngx-v5.sh | 495 --------------- ct/paperless-ngx.sh | 142 +++++ ct/photoprism-v5.sh | 452 -------------- ct/photoprism.sh | 99 +++ ct/pihole-v5.sh | 427 ------------- ct/pihole.sh | 71 +++ ct/plex-v5.sh | 460 -------------- ct/plex.sh | 81 +++ ct/podman-homeassistant-v5.sh | 497 --------------- ct/podman-homeassistant.sh | 121 ++++ ct/podman-v5.sh | 425 ------------- ct/podman.sh | 69 +++ ct/postgresql-v5.sh | 425 ------------- ct/postgresql.sh | 69 +++ ct/prometheus-v5.sh | 427 ------------- ct/prometheus.sh | 71 +++ ct/prowlarr-v5.sh | 426 ------------- ct/prowlarr.sh | 70 +++ ct/qbittorrent-v5.sh | 426 ------------- ct/qbittorrent.sh | 70 +++ ct/radarr-v5.sh | 426 ------------- ct/radarr.sh | 70 +++ ct/readarr-v5.sh | 426 ------------- ct/readarr.sh | 70 +++ ct/rockylinux-v5.sh | 400 ------------ ct/rockylinux.sh | 69 +++ ct/rstptoweb-v5.sh | 420 ------------- ct/rstptoweb.sh | 69 +++ ct/sabnzbd-v5.sh | 432 ------------- ct/sabnzbd.sh | 76 +++ ct/scrypted-v5.sh | 442 ------------- ct/scrypted.sh | 72 +++ ct/shinobi-v5.sh | 441 ------------- ct/shinobi.sh | 74 +++ ct/sonarr-v5.sh | 426 ------------- ct/sonarr.sh | 70 +++ ct/syncthing-v5.sh | 428 ------------- ct/syncthing.sh | 72 +++ ct/tdarr-v5.sh | 426 ------------- ct/tdarr.sh | 70 +++ ct/technitiumdns-v5.sh | 436 ------------- ct/technitiumdns.sh | 80 +++ ct/transmission-v5.sh | 426 ------------- ct/transmission.sh | 70 +++ ct/trilium-v5.sh | 446 ------------- ct/trilium.sh | 90 +++ ct/ubuntu-v5.sh | 431 ------------- ct/ubuntu.sh | 68 ++ ct/umbrel-v5.sh | 452 -------------- ct/umbrel.sh | 70 +++ ct/unifi-v5.sh | 427 ------------- ct/unifi.sh | 71 +++ ct/uptimekuma-v5.sh | 444 ------------- ct/uptimekuma.sh | 88 +++ ct/vaultwarden-v5.sh | 498 --------------- ct/vaultwarden.sh | 145 +++++ ct/whisparr-v5.sh | 427 ------------- ct/whisparr.sh | 71 +++ ct/whoogle-v5.sh | 426 ------------- ct/whoogle.sh | 70 +++ ct/wikijs-v5.sh | 449 -------------- ct/wikijs.sh | 93 +++ ct/wireguard-v5.sh | 479 -------------- ct/wireguard.sh | 123 ++++ ct/yunohost-v5.sh | 426 ------------- ct/yunohost.sh | 70 +++ ct/zigbee2mqtt-v5.sh | 486 --------------- ct/zigbee2mqtt.sh | 134 ++++ ct/zwave-js-ui-v5.sh | 455 -------------- ct/zwave-js-ui.sh | 87 +++ install/adguard-install.sh | 37 ++ install/adguard-v5-install.sh | 125 ---- install/alpine-adguard-install.sh | 35 ++ install/alpine-adguard-v5-install.sh | 123 ---- install/alpine-docker-install.sh | 61 ++ install/alpine-docker-v5-install.sh | 150 ----- install/alpine-grafana-install.sh | 31 + install/alpine-grafana-v5-install.sh | 118 ---- install/alpine-vaultwarden-install.sh | 38 ++ install/alpine-vaultwarden-v5-install.sh | 126 ---- install/alpine-zigbee2mqtt-install.sh | 28 + install/alpine-zigbee2mqtt-v5-install.sh | 117 ---- install/audiobookshelf-install.sh | 36 ++ install/audiobookshelf-v5-install.sh | 123 ---- install/autobrr-install.sh | 57 ++ install/autobrr-v5-install.sh | 144 ----- ...blocky-v5-install.sh => blocky-install.sh} | 105 +--- install/casaos-install.sh | 45 ++ install/casaos-v5-install.sh | 133 ---- install/changedetection-install.sh | 50 ++ install/changedetection-v5-install.sh | 137 ---- install/cronicle-install.sh | 56 ++ install/cronicle-v5-install.sh | 143 ----- install/daemonsync-install.sh | 35 ++ install/daemonsync-v5-install.sh | 123 ---- install/dashy-install.sh | 65 ++ install/dashy-v5-install.sh | 153 ----- install/debian-install.sh | 28 + install/debian-v5-install.sh | 115 ---- install/deconz-install.sh | 58 ++ install/deconz-v5-install.sh | 146 ----- install/deluge-install.sh | 73 +++ install/deluge-v5-install.sh | 160 ----- install/devuan-install.sh | 28 + install/devuan-v5-install.sh | 98 --- install/docker-install.sh | 77 +++ install/docker-v5-install.sh | 165 ----- install/emby-install.sh | 52 ++ install/emby-v5-install.sh | 140 ----- install/emqx-install.sh | 34 + install/emqx-v5-install.sh | 121 ---- install/esphome-install.sh | 54 ++ install/esphome-v5-install.sh | 142 ----- install/go2rtc-install.sh | 51 ++ install/go2rtc-v5-install.sh | 138 ----- install/grafana-install.sh | 41 ++ install/grafana-v5-install.sh | 131 ---- install/grocy-install.sh | 72 +++ install/grocy-v5-install.sh | 160 ----- install/heimdalldashboard-install.sh | 65 ++ install/heimdalldashboard-v5-install.sh | 153 ----- install/homeassistant-core-install.sh | 107 ++++ install/homeassistant-core-v5-install.sh | 195 ------ install/homeassistant-install.sh | 92 +++ install/homeassistant-v5-install.sh | 180 ------ install/homebridge-install.sh | 44 ++ install/homebridge-v5-install.sh | 132 ---- install/homepage-install.sh | 65 ++ install/homepage-v5-install.sh | 152 ----- install/homer-install.sh | 54 ++ install/homer-v5-install.sh | 141 ----- install/hyperion-install.sh | 39 ++ install/hyperion-v5-install.sh | 126 ---- install/influxdb-install.sh | 61 ++ install/influxdb-v5-install.sh | 149 ----- install/iobroker-install.sh | 32 + install/iobroker-v5-install.sh | 120 ---- install/jackett-install.sh | 54 ++ install/jackett-v5-install.sh | 141 ----- install/jellyfin-install.sh | 76 +++ install/jellyfin-v5-install.sh | 164 ----- install/k0s-install.sh | 43 ++ install/k0s-v5-install.sh | 130 ---- install/kavita-install.sh | 54 ++ install/kavita-v5-install.sh | 142 ----- install/keycloak-install.sh | 51 ++ install/keycloak-v5-install.sh | 139 ----- install/lidarr-install.sh | 60 ++ install/lidarr-v5-install.sh | 147 ----- ...r-v5-install.sh => magicmirror-install.sh} | 106 +--- install/mariadb-install.sh | 43 ++ install/mariadb-v5-install.sh | 131 ---- install/meshcentral-install.sh | 43 ++ install/meshcentral-v5-install.sh | 131 ---- install/motioneye-install.sh | 62 ++ install/motioneye-v5-install.sh | 150 ----- install/mqtt-install.sh | 39 ++ install/mqtt-v5-install.sh | 127 ---- install/n8n-install.sh | 54 ++ install/n8n-v5-install.sh | 142 ----- install/navidrome-install.sh | 84 +++ install/navidrome-v5-install.sh | 171 ----- install/nextcloudpi-install.sh | 35 ++ install/nextcloudpi-v5-install.sh | 122 ---- ...nstall.sh => nginxproxymanager-install.sh} | 106 +--- install/nocodb-install.sh | 61 ++ install/nocodb-v5-install.sh | 149 ----- install/node-red-install.sh | 64 ++ install/node-red-v5-install.sh | 152 ----- install/omada-install.sh | 39 ++ install/omada-v5-install.sh | 127 ---- install/omv-install.sh | 50 ++ install/omv-v5-install.sh | 138 ----- install/openhab-install.sh | 49 ++ install/openhab-v5-install.sh | 137 ---- ...v5-install.sh => paperless-ngx-install.sh} | 107 +--- ...sm-v5-install.sh => photoprism-install.sh} | 106 +--- install/pihole-install.sh | 54 ++ install/pihole-v5-install.sh | 143 ----- install/plex-install.sh | 55 ++ install/plex-v5-install.sh | 143 ----- install/podman-homeassistant-install.sh | 54 ++ install/podman-homeassistant-v5-install.sh | 142 ----- install/podman-install.sh | 34 + install/podman-v5-install.sh | 121 ---- ...ql-v5-install.sh => postgresql-install.sh} | 109 +--- install/prometheus-install.sh | 64 ++ install/prometheus-v5-install.sh | 152 ----- install/prowlarr-install.sh | 58 ++ install/prowlarr-v5-install.sh | 145 ----- install/qbittorrent-install.sh | 46 ++ install/qbittorrent-v5-install.sh | 133 ---- install/radarr-install.sh | 58 ++ install/radarr-v5-install.sh | 145 ----- install/readarr-install.sh | 58 ++ install/readarr-v5-install.sh | 145 ----- install/rstptoweb-install.sh | 61 ++ install/rstptoweb-v5-install.sh | 148 ----- install/sabnzbd-install.sh | 62 ++ install/sabnzbd-v5-install.sh | 149 ----- install/scrypted-install.sh | 117 ++++ install/scrypted-v5-install.sh | 203 ------ install/shinobi-install.sh | 90 +++ install/shinobi-v5-install.sh | 178 ------ install/sonarr-install.sh | 37 ++ install/sonarr-v5-install.sh | 125 ---- install/syncthing-install.sh | 41 ++ install/syncthing-v5-install.sh | 128 ---- install/tdarr-install.sh | 85 +++ install/tdarr-v5-install.sh | 172 ----- install/technitiumdns-install.sh | 43 ++ install/technitiumdns-v5-install.sh | 131 ---- install/transmission-install.sh | 36 ++ install/transmission-v5-install.sh | 123 ---- install/trilium-install.sh | 59 ++ install/trilium-v5-install.sh | 146 ----- install/ubuntu-install.sh | 28 + install/ubuntu-v5-install.sh | 116 ---- install/umbrel-install.sh | 46 ++ install/umbrel-v5-install.sh | 133 ---- install/unifi-install.sh | 40 ++ install/unifi-v5-install.sh | 129 ---- install/uptimekuma-install.sh | 61 ++ install/uptimekuma-v5-install.sh | 149 ----- ...n-v5-install.sh => vaultwarden-install.sh} | 106 +--- install/whisparr-install.sh | 58 ++ install/whisparr-v5-install.sh | 145 ----- install/whoogle-install.sh | 50 ++ install/whoogle-v5-install.sh | 138 ----- install/wikijs-install.sh | 78 +++ install/wikijs-v5-install.sh | 166 ----- install/wireguard-install.sh | 49 ++ install/wireguard-v5-install.sh | 138 ----- install/yunohost-install.sh | 38 ++ install/yunohost-v5-install.sh | 125 ---- install/zigbee2mqtt-install.sh | 77 +++ install/zigbee2mqtt-v5-install.sh | 165 ----- install/zwave-js-ui-install.sh | 54 ++ install/zwave-js-ui-v5-install.sh | 142 ----- misc/alpine-install.func | 116 ++++ misc/alpine.func | 400 ++++++++++++ misc/debian.func | 403 ++++++++++++ misc/docker.func | 409 ++++++++++++ misc/install.func | 133 ++++ misc/ubuntu.func | 428 +++++++++++++ vm/haos-vm-v5.sh | 323 +++++----- ...ik-routeros-v5.sh => mikrotik-routeros.sh} | 273 ++++---- vm/{pimox-haos-vm-v5.sh => pimox-haos-vm.sh} | 315 +++++----- 359 files changed, 14171 insertions(+), 52404 deletions(-) delete mode 100644 ct/adguard-v5.sh create mode 100644 ct/adguard.sh delete mode 100644 ct/alpine-adguard-v5.sh create mode 100644 ct/alpine-adguard.sh delete mode 100644 ct/alpine-docker-v5.sh create mode 100644 ct/alpine-docker.sh delete mode 100644 ct/alpine-grafana-v5.sh create mode 100644 ct/alpine-grafana.sh delete mode 100644 ct/alpine-v5.sh delete mode 100644 ct/alpine-vaultwarden-v5.sh create mode 100644 ct/alpine-vaultwarden.sh delete mode 100644 ct/alpine-zigbee2mqtt-v5.sh create mode 100644 ct/alpine-zigbee2mqtt.sh create mode 100644 ct/alpine.sh rename ct/{archlinux-v5.sh => archlinux.sh} (99%) delete mode 100644 ct/audiobookshelf-v5.sh create mode 100644 ct/audiobookshelf.sh delete mode 100644 ct/autobrr-v5.sh create mode 100644 ct/autobrr.sh delete mode 100644 ct/blocky-v5.sh create mode 100644 ct/blocky.sh delete mode 100644 ct/casaos-v5.sh create mode 100644 ct/casaos.sh delete mode 100644 ct/changedetection-v5.sh create mode 100644 ct/changedetection.sh delete mode 100644 ct/cronicle-v5.sh create mode 100644 ct/cronicle.sh delete mode 100644 ct/daemonsync-v5.sh create mode 100644 ct/daemonsync.sh delete mode 100644 ct/dashy-v5.sh create mode 100644 ct/dashy.sh delete mode 100644 ct/debian-v5.sh create mode 100644 ct/debian.sh delete mode 100644 ct/deconz-v5.sh create mode 100644 ct/deconz.sh delete mode 100644 ct/deluge-v5.sh create mode 100644 ct/deluge.sh delete mode 100644 ct/devuan-v5.sh create mode 100644 ct/devuan.sh delete mode 100644 ct/docker-v5.sh create mode 100644 ct/docker.sh delete mode 100644 ct/emby-v5.sh create mode 100644 ct/emby.sh delete mode 100644 ct/emqx-v5.sh create mode 100644 ct/emqx.sh delete mode 100644 ct/esphome-v5.sh create mode 100644 ct/esphome.sh delete mode 100644 ct/go2rtc-v5.sh create mode 100644 ct/go2rtc.sh delete mode 100644 ct/grafana-v5.sh create mode 100644 ct/grafana.sh delete mode 100644 ct/grocy-v5.sh create mode 100644 ct/grocy.sh delete mode 100644 ct/heimdalldashboard-v5.sh create mode 100644 ct/heimdalldashboard.sh delete mode 100644 ct/homeassistant-core-v5.sh create mode 100644 ct/homeassistant-core.sh delete mode 100644 ct/homeassistant-v5.sh create mode 100644 ct/homeassistant.sh delete mode 100644 ct/homebridge-v5.sh create mode 100644 ct/homebridge.sh delete mode 100644 ct/homepage-v5.sh create mode 100644 ct/homepage.sh delete mode 100644 ct/homer-v5.sh create mode 100644 ct/homer.sh delete mode 100644 ct/hyperion-v5.sh create mode 100644 ct/hyperion.sh delete mode 100644 ct/influxdb-v5.sh create mode 100644 ct/influxdb.sh delete mode 100644 ct/iobroker-v5.sh create mode 100644 ct/iobroker.sh delete mode 100644 ct/jackett-v5.sh create mode 100644 ct/jackett.sh delete mode 100644 ct/jellyfin-v5.sh create mode 100644 ct/jellyfin.sh delete mode 100644 ct/k0s-v5.sh create mode 100644 ct/k0s.sh delete mode 100644 ct/kavita-v5.sh create mode 100644 ct/kavita.sh delete mode 100644 ct/keycloak-v5.sh create mode 100644 ct/keycloak.sh delete mode 100644 ct/lidarr-v5.sh create mode 100644 ct/lidarr.sh delete mode 100644 ct/magicmirror-v5.sh create mode 100644 ct/magicmirror.sh delete mode 100644 ct/mariadb-v5.sh create mode 100644 ct/mariadb.sh delete mode 100644 ct/meshcentral-v5.sh create mode 100644 ct/meshcentral.sh delete mode 100644 ct/motioneye-v5.sh create mode 100644 ct/motioneye.sh delete mode 100644 ct/mqtt-v5.sh create mode 100644 ct/mqtt.sh delete mode 100644 ct/n8n-v5.sh create mode 100644 ct/n8n.sh delete mode 100644 ct/navidrome-v5.sh create mode 100644 ct/navidrome.sh delete mode 100644 ct/nextcloudpi-v5.sh create mode 100644 ct/nextcloudpi.sh delete mode 100644 ct/nginxproxymanager-v5.sh create mode 100644 ct/nginxproxymanager.sh delete mode 100644 ct/nocodb-v5.sh create mode 100644 ct/nocodb.sh delete mode 100644 ct/node-red-v5.sh create mode 100644 ct/node-red.sh delete mode 100644 ct/omada-v5.sh create mode 100644 ct/omada.sh delete mode 100644 ct/omv-v5.sh create mode 100644 ct/omv.sh delete mode 100644 ct/openhab-v5.sh create mode 100644 ct/openhab.sh delete mode 100644 ct/paperless-ngx-v5.sh create mode 100644 ct/paperless-ngx.sh delete mode 100644 ct/photoprism-v5.sh create mode 100644 ct/photoprism.sh delete mode 100644 ct/pihole-v5.sh create mode 100644 ct/pihole.sh delete mode 100644 ct/plex-v5.sh create mode 100644 ct/plex.sh delete mode 100644 ct/podman-homeassistant-v5.sh create mode 100644 ct/podman-homeassistant.sh delete mode 100644 ct/podman-v5.sh create mode 100644 ct/podman.sh delete mode 100644 ct/postgresql-v5.sh create mode 100644 ct/postgresql.sh delete mode 100644 ct/prometheus-v5.sh create mode 100644 ct/prometheus.sh delete mode 100644 ct/prowlarr-v5.sh create mode 100644 ct/prowlarr.sh delete mode 100644 ct/qbittorrent-v5.sh create mode 100644 ct/qbittorrent.sh delete mode 100644 ct/radarr-v5.sh create mode 100644 ct/radarr.sh delete mode 100644 ct/readarr-v5.sh create mode 100644 ct/readarr.sh delete mode 100644 ct/rockylinux-v5.sh create mode 100644 ct/rockylinux.sh delete mode 100644 ct/rstptoweb-v5.sh create mode 100644 ct/rstptoweb.sh delete mode 100644 ct/sabnzbd-v5.sh create mode 100644 ct/sabnzbd.sh delete mode 100644 ct/scrypted-v5.sh create mode 100644 ct/scrypted.sh delete mode 100644 ct/shinobi-v5.sh create mode 100644 ct/shinobi.sh delete mode 100644 ct/sonarr-v5.sh create mode 100644 ct/sonarr.sh delete mode 100644 ct/syncthing-v5.sh create mode 100644 ct/syncthing.sh delete mode 100644 ct/tdarr-v5.sh create mode 100644 ct/tdarr.sh delete mode 100644 ct/technitiumdns-v5.sh create mode 100644 ct/technitiumdns.sh delete mode 100644 ct/transmission-v5.sh create mode 100644 ct/transmission.sh delete mode 100644 ct/trilium-v5.sh create mode 100644 ct/trilium.sh delete mode 100644 ct/ubuntu-v5.sh create mode 100644 ct/ubuntu.sh delete mode 100644 ct/umbrel-v5.sh create mode 100644 ct/umbrel.sh delete mode 100644 ct/unifi-v5.sh create mode 100644 ct/unifi.sh delete mode 100644 ct/uptimekuma-v5.sh create mode 100644 ct/uptimekuma.sh delete mode 100644 ct/vaultwarden-v5.sh create mode 100644 ct/vaultwarden.sh delete mode 100644 ct/whisparr-v5.sh create mode 100644 ct/whisparr.sh delete mode 100644 ct/whoogle-v5.sh create mode 100644 ct/whoogle.sh delete mode 100644 ct/wikijs-v5.sh create mode 100644 ct/wikijs.sh delete mode 100644 ct/wireguard-v5.sh create mode 100644 ct/wireguard.sh delete mode 100644 ct/yunohost-v5.sh create mode 100644 ct/yunohost.sh delete mode 100644 ct/zigbee2mqtt-v5.sh create mode 100644 ct/zigbee2mqtt.sh delete mode 100644 ct/zwave-js-ui-v5.sh create mode 100644 ct/zwave-js-ui.sh create mode 100644 install/adguard-install.sh delete mode 100644 install/adguard-v5-install.sh create mode 100644 install/alpine-adguard-install.sh delete mode 100644 install/alpine-adguard-v5-install.sh create mode 100644 install/alpine-docker-install.sh delete mode 100644 install/alpine-docker-v5-install.sh create mode 100644 install/alpine-grafana-install.sh delete mode 100644 install/alpine-grafana-v5-install.sh create mode 100644 install/alpine-vaultwarden-install.sh delete mode 100644 install/alpine-vaultwarden-v5-install.sh create mode 100644 install/alpine-zigbee2mqtt-install.sh delete mode 100644 install/alpine-zigbee2mqtt-v5-install.sh create mode 100644 install/audiobookshelf-install.sh delete mode 100644 install/audiobookshelf-v5-install.sh create mode 100644 install/autobrr-install.sh delete mode 100644 install/autobrr-v5-install.sh rename install/{blocky-v5-install.sh => blocky-install.sh} (79%) create mode 100644 install/casaos-install.sh delete mode 100644 install/casaos-v5-install.sh create mode 100644 install/changedetection-install.sh delete mode 100644 install/changedetection-v5-install.sh create mode 100644 install/cronicle-install.sh delete mode 100644 install/cronicle-v5-install.sh create mode 100644 install/daemonsync-install.sh delete mode 100644 install/daemonsync-v5-install.sh create mode 100644 install/dashy-install.sh delete mode 100644 install/dashy-v5-install.sh create mode 100644 install/debian-install.sh delete mode 100644 install/debian-v5-install.sh create mode 100644 install/deconz-install.sh delete mode 100644 install/deconz-v5-install.sh create mode 100644 install/deluge-install.sh delete mode 100644 install/deluge-v5-install.sh create mode 100644 install/devuan-install.sh delete mode 100644 install/devuan-v5-install.sh create mode 100644 install/docker-install.sh delete mode 100644 install/docker-v5-install.sh create mode 100644 install/emby-install.sh delete mode 100644 install/emby-v5-install.sh create mode 100644 install/emqx-install.sh delete mode 100644 install/emqx-v5-install.sh create mode 100644 install/esphome-install.sh delete mode 100644 install/esphome-v5-install.sh create mode 100644 install/go2rtc-install.sh delete mode 100644 install/go2rtc-v5-install.sh create mode 100644 install/grafana-install.sh delete mode 100644 install/grafana-v5-install.sh create mode 100644 install/grocy-install.sh delete mode 100644 install/grocy-v5-install.sh create mode 100644 install/heimdalldashboard-install.sh delete mode 100644 install/heimdalldashboard-v5-install.sh create mode 100644 install/homeassistant-core-install.sh delete mode 100644 install/homeassistant-core-v5-install.sh create mode 100644 install/homeassistant-install.sh delete mode 100644 install/homeassistant-v5-install.sh create mode 100644 install/homebridge-install.sh delete mode 100644 install/homebridge-v5-install.sh create mode 100644 install/homepage-install.sh delete mode 100644 install/homepage-v5-install.sh create mode 100644 install/homer-install.sh delete mode 100644 install/homer-v5-install.sh create mode 100644 install/hyperion-install.sh delete mode 100644 install/hyperion-v5-install.sh create mode 100644 install/influxdb-install.sh delete mode 100644 install/influxdb-v5-install.sh create mode 100644 install/iobroker-install.sh delete mode 100644 install/iobroker-v5-install.sh create mode 100644 install/jackett-install.sh delete mode 100644 install/jackett-v5-install.sh create mode 100644 install/jellyfin-install.sh delete mode 100644 install/jellyfin-v5-install.sh create mode 100644 install/k0s-install.sh delete mode 100644 install/k0s-v5-install.sh create mode 100644 install/kavita-install.sh delete mode 100644 install/kavita-v5-install.sh create mode 100644 install/keycloak-install.sh delete mode 100644 install/keycloak-v5-install.sh create mode 100644 install/lidarr-install.sh delete mode 100644 install/lidarr-v5-install.sh rename install/{magicmirror-v5-install.sh => magicmirror-install.sh} (61%) create mode 100644 install/mariadb-install.sh delete mode 100644 install/mariadb-v5-install.sh create mode 100644 install/meshcentral-install.sh delete mode 100644 install/meshcentral-v5-install.sh create mode 100644 install/motioneye-install.sh delete mode 100644 install/motioneye-v5-install.sh create mode 100644 install/mqtt-install.sh delete mode 100644 install/mqtt-v5-install.sh create mode 100644 install/n8n-install.sh delete mode 100644 install/n8n-v5-install.sh create mode 100644 install/navidrome-install.sh delete mode 100644 install/navidrome-v5-install.sh create mode 100644 install/nextcloudpi-install.sh delete mode 100644 install/nextcloudpi-v5-install.sh rename install/{nginxproxymanager-v5-install.sh => nginxproxymanager-install.sh} (62%) create mode 100644 install/nocodb-install.sh delete mode 100644 install/nocodb-v5-install.sh create mode 100644 install/node-red-install.sh delete mode 100644 install/node-red-v5-install.sh create mode 100644 install/omada-install.sh delete mode 100644 install/omada-v5-install.sh create mode 100644 install/omv-install.sh delete mode 100644 install/omv-v5-install.sh create mode 100644 install/openhab-install.sh delete mode 100644 install/openhab-v5-install.sh rename install/{paperless-ngx-v5-install.sh => paperless-ngx-install.sh} (64%) rename install/{photoprism-v5-install.sh => photoprism-install.sh} (53%) create mode 100644 install/pihole-install.sh delete mode 100644 install/pihole-v5-install.sh create mode 100644 install/plex-install.sh delete mode 100644 install/plex-v5-install.sh create mode 100644 install/podman-homeassistant-install.sh delete mode 100644 install/podman-homeassistant-v5-install.sh create mode 100644 install/podman-install.sh delete mode 100644 install/podman-v5-install.sh rename install/{postgresql-v5-install.sh => postgresql-install.sh} (60%) create mode 100644 install/prometheus-install.sh delete mode 100644 install/prometheus-v5-install.sh create mode 100644 install/prowlarr-install.sh delete mode 100644 install/prowlarr-v5-install.sh create mode 100644 install/qbittorrent-install.sh delete mode 100644 install/qbittorrent-v5-install.sh create mode 100644 install/radarr-install.sh delete mode 100644 install/radarr-v5-install.sh create mode 100644 install/readarr-install.sh delete mode 100644 install/readarr-v5-install.sh create mode 100644 install/rstptoweb-install.sh delete mode 100644 install/rstptoweb-v5-install.sh create mode 100644 install/sabnzbd-install.sh delete mode 100644 install/sabnzbd-v5-install.sh create mode 100644 install/scrypted-install.sh delete mode 100644 install/scrypted-v5-install.sh create mode 100644 install/shinobi-install.sh delete mode 100644 install/shinobi-v5-install.sh create mode 100644 install/sonarr-install.sh delete mode 100644 install/sonarr-v5-install.sh create mode 100644 install/syncthing-install.sh delete mode 100644 install/syncthing-v5-install.sh create mode 100644 install/tdarr-install.sh delete mode 100644 install/tdarr-v5-install.sh create mode 100644 install/technitiumdns-install.sh delete mode 100644 install/technitiumdns-v5-install.sh create mode 100644 install/transmission-install.sh delete mode 100644 install/transmission-v5-install.sh create mode 100644 install/trilium-install.sh delete mode 100644 install/trilium-v5-install.sh create mode 100644 install/ubuntu-install.sh delete mode 100644 install/ubuntu-v5-install.sh create mode 100644 install/umbrel-install.sh delete mode 100644 install/umbrel-v5-install.sh create mode 100644 install/unifi-install.sh delete mode 100644 install/unifi-v5-install.sh create mode 100644 install/uptimekuma-install.sh delete mode 100644 install/uptimekuma-v5-install.sh rename install/{vaultwarden-v5-install.sh => vaultwarden-install.sh} (50%) create mode 100644 install/whisparr-install.sh delete mode 100644 install/whisparr-v5-install.sh create mode 100644 install/whoogle-install.sh delete mode 100644 install/whoogle-v5-install.sh create mode 100644 install/wikijs-install.sh delete mode 100644 install/wikijs-v5-install.sh create mode 100644 install/wireguard-install.sh delete mode 100644 install/wireguard-v5-install.sh create mode 100644 install/yunohost-install.sh delete mode 100644 install/yunohost-v5-install.sh create mode 100644 install/zigbee2mqtt-install.sh delete mode 100644 install/zigbee2mqtt-v5-install.sh create mode 100644 install/zwave-js-ui-install.sh delete mode 100644 install/zwave-js-ui-v5-install.sh create mode 100644 misc/alpine-install.func create mode 100644 misc/alpine.func create mode 100644 misc/debian.func create mode 100644 misc/docker.func create mode 100644 misc/install.func create mode 100644 misc/ubuntu.func rename vm/{mikrotik-routeros-v5.sh => mikrotik-routeros.sh} (51%) rename vm/{pimox-haos-vm-v5.sh => pimox-haos-vm.sh} (50%) diff --git a/ct/adguard-v5.sh b/ct/adguard-v5.sh deleted file mode 100644 index 73a5eb9c..00000000 --- a/ct/adguard-v5.sh +++ /dev/null @@ -1,444 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ___ __ __ - / | ____/ /___ ___v5______ __________/ / - / /| |/ __ / __ / / / / __ / ___/ __ / - / ___ / /_/ / /_/ / /_/ / /_/ / / / /_/ / -/_/ |_\__,_/\__, /\__,_/\__,_/_/ \__,_/ - /____/ - -EOF -} -header_info -echo -e "Loading..." -APP="Adguard" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Stopping AdguardHome" -systemctl stop AdGuardHome -msg_ok "Stopped AdguardHome" - -msg_info "Updating AdguardHome" -wget -qL https://static.adguard.com/adguardhome/release/AdGuardHome_linux_amd64.tar.gz -tar -xvf AdGuardHome_linux_amd64.tar.gz &>/dev/null -mkdir -p adguard-backup -cp -r /opt/AdGuardHome/AdGuardHome.yaml /opt/AdGuardHome/data adguard-backup/ -cp AdGuardHome/AdGuardHome /opt/AdGuardHome/AdGuardHome -cp -r adguard-backup/* /opt/AdGuardHome/ -msg_ok "Updated AdguardHome" - -msg_info "Starting AdguardHome" -systemctl start AdGuardHome -msg_ok "Started AdguardHome" - -msg_info "Cleaning Up" -rm -rf AdGuardHome_linux_amd64.tar.gz AdGuardHome adguard-backup -msg_ok "Cleaned" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/AdGuardHome ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} Setup should be reachable by going to the following URL. - ${BL}http://${IP}:3000${CL} \n" diff --git a/ct/adguard.sh b/ct/adguard.sh new file mode 100644 index 00000000..682fc877 --- /dev/null +++ b/ct/adguard.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ___ __ __ + / | ____/ /___ ___ ______ __________/ / + / /| |/ __ / __ / / / / __ / ___/ __ / + / ___ / /_/ / /_/ / /_/ / /_/ / / / /_/ / +/_/ |_\__,_/\__, /\__,_/\__,_/_/ \__,_/ + /____/ + +EOF +} +header_info +echo -e "Loading..." +APP="Adguard" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/AdGuardHome ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Stopping AdguardHome" +systemctl stop AdGuardHome +msg_ok "Stopped AdguardHome" + +msg_info "Updating AdguardHome" +wget -qL https://static.adguard.com/adguardhome/release/AdGuardHome_linux_amd64.tar.gz +tar -xvf AdGuardHome_linux_amd64.tar.gz &>/dev/null +mkdir -p adguard-backup +cp -r /opt/AdGuardHome/AdGuardHome.yaml /opt/AdGuardHome/data adguard-backup/ +cp AdGuardHome/AdGuardHome /opt/AdGuardHome/AdGuardHome +cp -r adguard-backup/* /opt/AdGuardHome/ +msg_ok "Updated AdguardHome" + +msg_info "Starting AdguardHome" +systemctl start AdGuardHome +msg_ok "Started AdguardHome" + +msg_info "Cleaning Up" +rm -rf AdGuardHome_linux_amd64.tar.gz AdGuardHome adguard-backup +msg_ok "Cleaned" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} Setup should be reachable by going to the following URL. + ${BL}http://${IP}:3000${CL} \n" diff --git a/ct/alpine-adguard-v5.sh b/ct/alpine-adguard-v5.sh deleted file mode 100644 index 4ed5ea19..00000000 --- a/ct/alpine-adguard-v5.sh +++ /dev/null @@ -1,486 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - ___ __ __ - / | ____/ /___ ___v5______ __________/ / - / /| |/ __ / __ / / / / __ / ___/ __ / - / ___ / /_/ / /_/ / /_/ / /_/ / / / /_/ / -/_/ |_\__,_/\__, /\__,_/\__,_/_/ \__,_/ - /____/ Alpine - -EOF -} -header_info -echo -e "Loading..." -APP="Alpine-AdGuard" -var_disk="0.3" -var_cpu="1" -var_ram="256" -var_os="alpine" -var_version="3.17" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}alpine${CL}" - PW="-password alpine" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -timezone=$(cat /etc/timezone) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { - header_info - normal=$(echo "\033[m") - menu=$(echo "\033[36m") - number=$(echo "\033[33m") - fgred=$(echo "\033[31m") - printf "\n${menu}*********************************************${normal}\n" - printf "${menu}**${number} 1)${normal} Update LXC OS \n" - printf "${menu}**${number} 2)${normal} Update AdGuardHome\n" - printf "${menu}*********************************************${normal}\n" - printf "Please choose an option from the menu, or ${fgred}x${normal} to exit." - read opt - -while [ "$opt" != "" ]; do - case $opt in - 1) - clear - echo -e "${fgred}Update LXC OS${normal}" - msg_info "Updating LXC OS" - apk update &>/dev/null - apk upgrade &>/dev/null - msg_ok "Update Successfull" - - break - ;; - 2) - clear - echo -e "${fgred}Update AdGuardHome${normal}" - msg_info "Stopping AdguardHome" - /opt/AdGuardHome/AdGuardHome -s stop &>/dev/null - msg_ok "Stopped AdguardHome" - - VER=$(curl -sqI https://github.com/AdguardTeam/AdGuardHome/releases/latest | awk -F '/' '/^location/ {print substr($NF, 1, length($NF)-1)}'); - msg_info "Updating AdguardHome to $VER" - wget -q "https://github.com/AdguardTeam/AdGuardHome/releases/download/$VER/AdGuardHome_linux_amd64.tar.gz" - tar -xvf AdGuardHome_linux_amd64.tar.gz &>/dev/null - mkdir -p adguard-backup - cp -rf /opt/AdGuardHome/AdGuardHome.yaml /opt/AdGuardHome/data adguard-backup/ - cp AdGuardHome/AdGuardHome /opt/AdGuardHome/AdGuardHome - cp -r adguard-backup/* /opt/AdGuardHome/ - msg_ok "Updated AdguardHome" - - msg_info "Starting AdguardHome" - /opt/AdGuardHome/AdGuardHome -s start &>/dev/null - msg_ok "Started AdguardHome" - - msg_info "Cleaning Up" - rm -rf AdGuardHome_linux_amd64.tar.gz AdGuardHome adguard-backup - msg_ok "Cleaned" - msg_ok "Update Successfull" - - break - ;; - x) - clear - echo -e "⚠ User exited script \n" - exit - ;; - \n) - clear - echo -e "⚠ User exited script \n" - exit - ;; - *) - clear - echo -e "Please choose an option from the menu" - update_script - ;; - esac -done - - -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if [[ ! -d /opt/AdGuardHome ]]; then - msg_error "No ${APP} Installation Found!" - else - update_script - fi -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- ash -c "$(wget -qO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:3000${CL} \n" diff --git a/ct/alpine-adguard.sh b/ct/alpine-adguard.sh new file mode 100644 index 00000000..4604fbcb --- /dev/null +++ b/ct/alpine-adguard.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/alpine.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + ___ __ __ + / | ____/ /___ ___ ______ __________/ / + / /| |/ __ / __ / / / / __ / ___/ __ / + / ___ / /_/ / /_/ / /_/ / /_/ / / / /_/ / +/_/ |_\__,_/\__, /\__,_/\__,_/_/ \__,_/ + /____/ Alpine + +EOF +} +header_info +echo -e "Loading..." +APP="Alpine-AdGuard" +var_disk="0.3" +var_cpu="1" +var_ram="256" +var_os="alpine" +var_version="3.17" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="-password alpine" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + while true; do + CHOICE=$( + whiptail --title "SUPPORT" --menu "Select option" 11 58 2 \ + "1" "Update LXC OS" \ + "2" "Manually Update AdGuardHome" 3>&2 2>&1 1>&3 + ) + exit_status=$? + if [ $exit_status == 1 ]; then + clear + exit-script + fi + header_info + case $CHOICE in + 1) + apk update && apk upgrade + exit + ;; + 2) + header_info + echo "In the process of creating a method to update" + exit + ;; + esac + done +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:3000${CL} \n" diff --git a/ct/alpine-docker-v5.sh b/ct/alpine-docker-v5.sh deleted file mode 100644 index b220ed08..00000000 --- a/ct/alpine-docker-v5.sh +++ /dev/null @@ -1,465 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - ____ __ - / __ \____ _____/ /_v5__ _____ - / / / / __ \/ ___/ //_/ _ \/ ___/ - / /_/ / /_/ / /__/ ,< / __/ / -/_____/\____/\___/_/|_|\___/_/ - Alpine - -EOF -} -header_info -echo -e "Loading..." -APP="Alpine-Docker" -var_disk="2" -var_cpu="1" -var_ram="1024" -var_os="alpine" -var_version="3.17" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}alpine${CL}" - PW="-password alpine" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" On \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -timezone=$(cat /etc/timezone) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { - header_info - normal=$(echo "\033[m") - menu=$(echo "\033[36m") - number=$(echo "\033[33m") - fgred=$(echo "\033[31m") - printf "\n${menu}*********************************************${normal}\n" - printf "${menu}**${number} 1)${normal} Update ${APP} \n" - printf "\n${menu}*********************************************${normal}\n" - printf "Please choose an option from the menu, or ${fgred}x${normal} to exit." - read opt - -while [ "$opt" != "" ]; do - case $opt in - 1) - clear - echo -e "${fgred}Update ${APP}${normal}" - apk update &>/dev/null - apk upgrade &>/dev/null - - break - ;; - x) - exit - ;; - \n) - exit - ;; - *) - clear - echo -e "Please choose an option from the menu" - update_script - ;; - esac -done -exit -} -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if [[ ! -d /etc/docker ]]; then - msg_error "No ${APP} Installation Found!" - else - update_script - fi -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$CT_TYPE" == "0" ]; then - LXC_CONFIG=/etc/pve/lxc/${CTID}.conf - cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -lxc.cgroup2.devices.allow: c 188:* rwm -lxc.cgroup2.devices.allow: c 189:* rwm -lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir -lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file -EOF -fi -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- ash -c "$(wget -qO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" diff --git a/ct/alpine-docker.sh b/ct/alpine-docker.sh new file mode 100644 index 00000000..21bd2144 --- /dev/null +++ b/ct/alpine-docker.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/alpine.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + ____ __ + / __ \____ _____/ /_ __ _____ + / / / / __ \/ ___/ //_/ _ \/ ___/ + / /_/ / /_/ / /__/ ,< / __/ / +/_____/\____/\___/_/|_|\___/_/ + Alpine + +EOF +} +header_info +echo -e "Loading..." +APP="Alpine-Docker" +var_disk="2" +var_cpu="1" +var_ram="1024" +var_os="alpine" +var_version="3.17" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="-password alpine" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +while true; do + CHOICE=$( + whiptail --title "SUPPORT" --menu "Select option" 11 58 1 \ + "1" "Check for Docker Updates" 3>&2 2>&1 1>&3 + ) + exit_status=$? + if [ $exit_status == 1 ]; then + clear + exit-script + fi + header_info + case $CHOICE in + 1) + apk update && apk upgrade + exit + ;; + esac +done + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/alpine-grafana-v5.sh b/ct/alpine-grafana-v5.sh deleted file mode 100644 index d9abeb4f..00000000 --- a/ct/alpine-grafana-v5.sh +++ /dev/null @@ -1,482 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - ______ ____ - / ____/________ _/ __/___ _____v5____ _ - / / __/ ___/ __ / /_/ __ / __ \/ __ / -/ /_/ / / / /_/ / __/ /_/ / / / / /_/ / -\____/_/ \__,_/_/ \__,_/_/ /_/\__,_/ - Alpine - -EOF -} -header_info -echo -e "Loading..." -APP="Alpine-Grafana" -var_disk="0.5" -var_cpu="1" -var_ram="256" -var_os="alpine" -var_version="3.17" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}alpine${CL}" - PW="-password alpine" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -timezone=$(cat /etc/timezone) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { - header_info - normal=$(echo "\033[m") - menu=$(echo "\033[36m") - number=$(echo "\033[33m") - fgred=$(echo "\033[31m") - LXCIP=$(ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) - printf "\n${menu}*********************************************${normal}\n" - printf "${menu}**${number} 1)${normal} Update LXC OS + Grafana \n" - printf "${menu}**${number} 2)${normal} Allow 0.0.0.0 for listening \n" - printf "${menu}**${number} 3)${normal} Allow only ${LXCIP} for listening \n" - printf "${menu}*********************************************${normal}\n" - printf "Please choose an option from the menu, or ${fgred}x${normal} to exit." - read opt - -while [ "$opt" != "" ]; do - case $opt in - 1) - clear - echo -e "${fgred}Update LXC OS${normal}" - msg_info "Updating LXC OS + Grafana" - apk update &>/dev/null - apk upgrade &>/dev/null - msg_ok "Update Successfull" - - break - ;; - 2) - clear - echo -e "${fgred}Updating Grafana Config with IP: ${LXCIP}${normal}" - msg_info "Stopping Grafana" - service grafana stop &>/dev/null - sed -i -e "s/cfg:server.http_addr=.*/cfg:server.http_addr=0.0.0.0/g" /etc/conf.d/grafana - msg_ok "Restarted Grafana" - service grafana start &>/dev/null - - break - ;; - 3) - clear - echo -e "${fgred}Updating Grafana Config with host IP: ${LXCIP}${normal}" - msg_info "Stopping Grafana" - service grafana stop &>/dev/null - sed -i -e "s/cfg:server.http_addr=.*/cfg:server.http_addr=$LXCIP/g" /etc/conf.d/grafana - msg_ok "Restarted Grafana" - service grafana start &>/dev/null - - break - ;; - x) - clear - echo -e "⚠ User exited script \n" - exit - ;; - \n) - clear - echo -e "⚠ User exited script \n" - exit - ;; - *) - clear - echo -e "Please choose an option from the menu" - update_script - ;; - esac -done - - -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if [[ ! -f /etc/conf.d/grafana ]]; then - msg_error "No ${APP} Installation Found!" - else - update_script - fi -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- ash -c "$(wget -qO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:3000${CL} \n" diff --git a/ct/alpine-grafana.sh b/ct/alpine-grafana.sh new file mode 100644 index 00000000..4dd13bda --- /dev/null +++ b/ct/alpine-grafana.sh @@ -0,0 +1,94 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/alpine.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + ______ ____ + / ____/________ _/ __/___ _____ ____ _ + / / __/ ___/ __ / /_/ __ / __ \/ __ / +/ /_/ / / / /_/ / __/ /_/ / / / / /_/ / +\____/_/ \__,_/_/ \__,_/_/ /_/\__,_/ + Alpine + +EOF +} +header_info +echo -e "Loading..." +APP="Alpine-Grafana" +var_disk="0.5" +var_cpu="1" +var_ram="256" +var_os="alpine" +var_version="3.17" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="-password alpine" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + LXCIP=$(ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) + while true; do + CHOICE=$( + whiptail --title "SUPPORT" --menu "Select option" --cancel-button Exit-Script 11 58 3 \ + "1" "Check for Grafana Updates" \ + "2" "Allow 0.0.0.0 for listening" \ + "3" "Allow only ${LXCIP} for listening" 3>&2 2>&1 1>&3 + ) + exit_status=$? + if [ $exit_status == 1 ]; then + clear + exit-script + fi + header_info + case $CHOICE in + 1) + apk update && apk upgrade + exit + ;; + 2) + sed -i -e "s/cfg:server.http_addr=.*/cfg:server.http_addr=0.0.0.0/g" /etc/conf.d/grafana + service grafana restart + exit + ;; + 3) + sed -i -e "s/cfg:server.http_addr=.*/cfg:server.http_addr=$LXCIP/g" /etc/conf.d/grafana + service grafana restart + exit + ;; + esac + done +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:3000${CL} \n" diff --git a/ct/alpine-v5.sh b/ct/alpine-v5.sh deleted file mode 100644 index 6357beb8..00000000 --- a/ct/alpine-v5.sh +++ /dev/null @@ -1,419 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ___ v5 __ _ - / | / /___ (_)___ ___ - / /| | / / __ \/ / __ \/ _ \ - / ___ |/ / /_/ / / / / / __/ -/_/ |_/_/ .___/_/_/ /_/\___/ - /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Alpine" -var_disk="0.1" -var_cpu="1" -var_ram="512" -var_os="alpine" -var_version="3.17" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}alpine${CL}" - PW="-password alpine" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apk update &>/dev/null -apk upgrade &>/dev/null -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} ${var_version} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" diff --git a/ct/alpine-vaultwarden-v5.sh b/ct/alpine-vaultwarden-v5.sh deleted file mode 100644 index 731adbc7..00000000 --- a/ct/alpine-vaultwarden-v5.sh +++ /dev/null @@ -1,456 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - _ __ ____ __ -| | / /___ ___ __/ / /__ ______ __________/ /__v5____ -| | / / __ `/ / / / / __/ | /| / / __ `/ ___/ __ / _ \/ __ \ -| |/ / /_/ / /_/ / / /_ | |/ |/ / /_/ / / / /_/ / __/ / / / -|___/\__,_/\__,_/_/\__/ |__/|__/\__,_/_/ \__,_/\___/_/ /_/ - Alpine - -EOF -} -header_info -echo -e "Loading..." -APP="Alpine-Vaultwarden" -var_disk="0.3" -var_cpu="1" -var_ram="256" -var_os="alpine" -var_version="3.17" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}alpine${CL}" - PW="-password alpine" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -timezone=$(cat /etc/timezone) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { - header_info - normal=$(echo "\033[m") - menu=$(echo "\033[36m") - number=$(echo "\033[33m") - fgred=$(echo "\033[31m") - printf "\n${menu}*********************************************${normal}\n" - printf "${menu}**${number} 1)${normal} Update Vaultwarden \n" - printf "${menu}**${number} 2)${normal} View Admin Token\n" - printf "\n${menu}*********************************************${normal}\n" - printf "Please choose an option from the menu, or ${fgred}x${normal} to exit." - read opt - -while [ "$opt" != "" ]; do - case $opt in - 1) - clear - echo -e "${fgred}Update Vaultwarden${normal}" - apk update &>/dev/null - apk upgrade &>/dev/null - - break - ;; - 2) - clear - echo -e "${fgred}View the Admin Token${normal}" - cat /etc/conf.d/vaultwarden | grep "ADMIN_TOKEN" | awk '{print substr($2, 7) }' - - break - ;; - x) - exit - ;; - \n) - exit - ;; - *) - clear - echo -e "Please choose an option from the menu" - update_script - ;; - esac -done -exit -} -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if [[ ! -f /etc/conf.d/vaultwarden ]]; then - msg_error "No ${APP} Installation Found!" - else - update_script - fi -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- ash -c "$(wget -qO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8000${CL} \n" diff --git a/ct/alpine-vaultwarden.sh b/ct/alpine-vaultwarden.sh new file mode 100644 index 00000000..0f6c9930 --- /dev/null +++ b/ct/alpine-vaultwarden.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/alpine.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + _ __ ____ __ +| | / /___ ___ __/ / /__ ______ __________/ /__ ____ +| | / / __ `/ / / / / __/ | /| / / __ `/ ___/ __ / _ \/ __ \ +| |/ / /_/ / /_/ / / /_ | |/ |/ / /_/ / / / /_/ / __/ / / / +|___/\__,_/\__,_/_/\__/ |__/|__/\__,_/_/ \__,_/\___/_/ /_/ + Alpine + +EOF +} +header_info +echo -e "Loading..." +APP="Alpine-Vaultwarden" +var_disk="0.3" +var_cpu="1" +var_ram="256" +var_os="alpine" +var_version="3.17" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="-password alpine" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + while true; do + CHOICE=$( + whiptail --title "SUPPORT" --menu "Select option" 11 58 2 \ + "1" "Update VaultWarden" \ + "2" "Show Admin Token" 3>&2 2>&1 1>&3 + ) + exit_status=$? + if [ $exit_status == 1 ]; then + clear + exit-script + fi + header_info + case $CHOICE in + 1) + apk update && apk upgrade + exit + ;; + 2) + whiptail --title "ADMIN TOKEN" --msgbox "$(cat /etc/conf.d/vaultwarden | grep ADMIN_TOKEN | awk '{print substr($2, 13) }')" 7 68 + clear + exit + ;; + esac + done +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8000${CL} \n" diff --git a/ct/alpine-zigbee2mqtt-v5.sh b/ct/alpine-zigbee2mqtt-v5.sh deleted file mode 100644 index ed80ad45..00000000 --- a/ct/alpine-zigbee2mqtt-v5.sh +++ /dev/null @@ -1,460 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - _____ _ __ ___ __ _______ ____________ -/__ / (_)___ _/ /_ ___v5___ |__ \ / |/ / __ \/_ __/_ __/ - / / / / __ / __ \/ _ \/ _ \__/ // /|_/ / / / / / / / / - / /__/ / /_/ / /_/ / __/ __/ __// / / / /_/ / / / / / -/____/_/\__, /_.___/\___/\___/____/_/ /_/\___\_\/_/ /_/ - /____/ Alpine - -EOF -} -header_info -echo -e "Loading..." -APP="Alpine-Zigbee2MQTT" -var_disk="0.3" -var_cpu="1" -var_ram="256" -var_os="alpine" -var_version="3.17" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" - CT_TYPE="0" - echo -e "${DGN}Using Root Password: ${BGN}alpine${CL}" - PW="-password alpine" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" OFF \ - "0" "Privileged" ON \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -timezone=$(cat /etc/timezone) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { - header_info - normal=$(echo "\033[m") - menu=$(echo "\033[36m") - number=$(echo "\033[33m") - fgred=$(echo "\033[31m") - printf "\n${menu}*********************************************${normal}\n" - printf "${menu}**${number} 1)${normal} Update ${APP} \n" - printf "\n${menu}*********************************************${normal}\n" - printf "Please choose an option from the menu, or ${fgred}x${normal} to exit." - read opt - -while [ "$opt" != "" ]; do - case $opt in - 1) - clear - echo -e "${fgred}Update ${APP}${normal}" - apk update &>/dev/null - apk upgrade &>/dev/null - - break - ;; - x) - exit - ;; - \n) - exit - ;; - *) - clear - echo -e "Please choose an option from the menu" - update_script - ;; - esac -done -exit -} -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if [[ ! -f /etc/zigbee2mqtt/configuration.yaml ]]; then - msg_error "No ${APP} Installation Found!" - else - update_script - fi -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -if [ "$CT_TYPE" == "0" ]; then - LXC_CONFIG=/etc/pve/lxc/${CTID}.conf - cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -lxc.cgroup2.devices.allow: c 188:* rwm -lxc.cgroup2.devices.allow: c 189:* rwm -lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir -lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file -EOF -fi -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- ash -c "$(wget -qO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" diff --git a/ct/alpine-zigbee2mqtt.sh b/ct/alpine-zigbee2mqtt.sh new file mode 100644 index 00000000..28bcaf3b --- /dev/null +++ b/ct/alpine-zigbee2mqtt.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/alpine.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + _____ _ __ ___ __ _______ ____________ +/__ / (_)___ _/ /_ ___ ___ |__ \ / |/ / __ \/_ __/_ __/ + / / / / __ / __ \/ _ \/ _ \__/ // /|_/ / / / / / / / / + / /__/ / /_/ / /_/ / __/ __/ __// / / / /_/ / / / / / +/____/_/\__, /_.___/\___/\___/____/_/ /_/\___\_\/_/ /_/ + /____/ Alpine + +EOF +} +header_info +echo -e "Loading..." +APP="Alpine-Zigbee2MQTT" +var_disk="0.3" +var_cpu="1" +var_ram="256" +var_os="alpine" +var_version="3.17" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="-password alpine" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + while true; do + CHOICE=$( + whiptail --title "SUPPORT" --menu "Select option" 11 58 1 \ + "1" "Check for Zigbee2MQTT Updates" 3>&2 2>&1 1>&3 + ) + exit_status=$? + if [ $exit_status == 1 ]; then + clear + exit-script + fi + header_info + case $CHOICE in + 1) + apk update && apk upgrade + exit + ;; + esac + done +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/alpine.sh b/ct/alpine.sh new file mode 100644 index 00000000..19074a97 --- /dev/null +++ b/ct/alpine.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/alpine.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ___ __ _ + / | / /___ (_)___ ___ + / /| | / / __ \/ / __ \/ _ \ + / ___ |/ / /_/ / / / / / __/ +/_/ |_/_/ .___/_/_/ /_/\___/ + /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Alpine" +var_disk="0.1" +var_cpu="1" +var_ram="512" +var_os="alpine" +var_version="3.17" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="-password alpine" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +UPD=$(whiptail --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 1 \ + "1" "Check for Alpine Updates" ON \ + 3>&1 1>&2 2>&3) + +header_info +if [ "$UPD" == "1" ]; then +apk update && apk upgrade +exit; +fi +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/archlinux-v5.sh b/ct/archlinux.sh similarity index 99% rename from ct/archlinux-v5.sh rename to ct/archlinux.sh index 26385a0a..62f04bb3 100644 --- a/ct/archlinux-v5.sh +++ b/ct/archlinux.sh @@ -8,9 +8,8 @@ function header_info { clear cat <<"EOF" - ___ __ __ _ - / | __________/ /_ v5 / / (_)___ __ ___ __ + / | __________/ /_ / / (_)___ __ ___ __ / /| | / ___/ ___/ __ \ / / / / __ \/ / / / |/_/ / ___ |/ / / /__/ / / / / /___/ / / / / /_/ /> < /_/ |_/_/ \___/_/ /_/ /_____/_/_/ /_/\__,_/_/|_| diff --git a/ct/audiobookshelf-v5.sh b/ct/audiobookshelf-v5.sh deleted file mode 100644 index ca4e5c9b..00000000 --- a/ct/audiobookshelf-v5.sh +++ /dev/null @@ -1,421 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ___ __ __ __ ______ - ____ ___ ______/ (_)___v5/ /_ ____ ____ / /_______/ /_ ___ / / __/ - / __ `/ / / / __ / / __ \/ __ \/ __ \/ __ \/ //_/ ___/ __ \/ _ \/ / /_ -/ /_/ / /_/ / /_/ / / /_/ / /_/ / /_/ / /_/ / ,< (__ ) / / / __/ / __/ -\__,_/\__,_/\__,_/_/\____/_.___/\____/\____/_/|_/____/_/ /_/\___/_/_/ - -EOF -} -header_info -echo -e "Loading..." -APP="audiobookshelf" -var_disk="4" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" - CT_TYPE="0" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" OFF \ - "0" "Privileged" ON \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating $APP LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated $APP LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:13378${CL} \n" diff --git a/ct/audiobookshelf.sh b/ct/audiobookshelf.sh new file mode 100644 index 00000000..7e1de964 --- /dev/null +++ b/ct/audiobookshelf.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ___ __ __ __ ______ + ____ ___ ______/ (_)___ / /_ ____ ____ / /_______/ /_ ___ / / __/ + / __ `/ / / / __ / / __ \/ __ \/ __ \/ __ \/ //_/ ___/ __ \/ _ \/ / /_ +/ /_/ / /_/ / /_/ / / /_/ / /_/ / /_/ / /_/ / ,< (__ ) / / / __/ / __/ +\__,_/\__,_/\__,_/_/\____/_.___/\____/\____/_/|_/____/_/ /_/\___/_/_/ + +EOF +} +header_info +echo -e "Loading..." +APP="audiobookshelf" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:13378${CL} \n" diff --git a/ct/autobrr-v5.sh b/ct/autobrr-v5.sh deleted file mode 100644 index b0ad08cc..00000000 --- a/ct/autobrr-v5.sh +++ /dev/null @@ -1,437 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ___ __ __ - / | __ __/ /_____ / /_v5__________ - / /| |/ / / / __/ __ \/ __ \/ ___/ ___/ - / ___ / /_/ / /_/ /_/ / /_/ / / / / -/_/ |_\__,_/\__/\____/_.___/_/ /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Autobrr" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Stopping ${APP} LXC" -systemctl stop autobrr.service -msg_ok "Stopped ${APP} LXC" - -msg_info "Updating ${APP} LXC" -rm -rf /usr/local/bin/* -wget -q $(curl -s https://api.github.com/repos/autobrr/autobrr/releases/latest | grep download | grep linux_x86_64 | cut -d\" -f4) -tar -C /usr/local/bin -xzf autobrr*.tar.gz -rm -rf autobrr*.tar.gz -msg_ok "Updated ${APP} LXC" - -msg_info "Starting ${APP} LXC" -systemctl start autobrr.service -msg_ok "Started ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /root/.config/autobrr/config.toml ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:7474${CL} \n" diff --git a/ct/autobrr.sh b/ct/autobrr.sh new file mode 100644 index 00000000..7571c138 --- /dev/null +++ b/ct/autobrr.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ___ __ __ + / | __ __/ /_____ / /_ __________ + / /| |/ / / / __/ __ \/ __ \/ ___/ ___/ + / ___ / /_/ / /_/ /_/ / /_/ / / / / +/_/ |_\__,_/\__/\____/_.___/_/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Autobrr" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /root/.config/autobrr/config.toml ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Stopping ${APP} LXC" +systemctl stop autobrr.service +msg_ok "Stopped ${APP} LXC" + +msg_info "Updating ${APP} LXC" +rm -rf /usr/local/bin/* +wget -q $(curl -s https://api.github.com/repos/autobrr/autobrr/releases/latest | grep download | grep linux_x86_64 | cut -d\" -f4) +tar -C /usr/local/bin -xzf autobrr*.tar.gz +rm -rf autobrr*.tar.gz +msg_ok "Updated ${APP} LXC" + +msg_info "Starting ${APP} LXC" +systemctl start autobrr.service +msg_ok "Started ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:7474${CL} \n" diff --git a/ct/blocky-v5.sh b/ct/blocky-v5.sh deleted file mode 100644 index 64b905d2..00000000 --- a/ct/blocky-v5.sh +++ /dev/null @@ -1,425 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __ __ - / __ )/ /___v5_____/ /____ __ - / __ / / __ \/ ___/ //_/ / / / - / /_/ / / /_/ / /__/ ,< / /_/ / -/_____/_/\____/\___/_/|_|\__, / - /____/ -EOF -} -header_info -echo -e "Loading..." -APP="Blocky" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/blocky ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" diff --git a/ct/blocky.sh b/ct/blocky.sh new file mode 100644 index 00000000..cfa21ed8 --- /dev/null +++ b/ct/blocky.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ____ __ __ + / __ )/ /___ _____/ /____ __ + / __ / / __ \/ ___/ //_/ / / / + / /_/ / / /_/ / /__/ ,< / /_/ / +/_____/_/\____/\___/_/|_|\__, / + /____/ +EOF +} +header_info +echo -e "Loading..." +APP="Blocky" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/casaos-v5.sh b/ct/casaos-v5.sh deleted file mode 100644 index 7c00c6b3..00000000 --- a/ct/casaos-v5.sh +++ /dev/null @@ -1,453 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ______ ____ _____ - / ____/___ __v5______ _/ __ \/ ___/ - / / / __ `/ ___/ __ `/ / / /\__ \ -/ /___/ /_/ (__ ) /_/ / /_/ /___/ / -\____/\__,_/____/\__,_/\____//____/ - -EOF -} -header_info -echo -e "Loading..." -APP="CasaOS" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Fuse Overlayfs (ZFS): ${BGN}No${CL}" - FUSE="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "FUSE OVERLAYFS" --yesno "(ZFS) Enable Fuse Overlayfs?" 10 58); then - FUSE="yes" -else - FUSE="no" -fi - echo -e "${DGN}Enable Fuse Overlayfs (ZFS): ${BGN}$FUSE${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /etc/docker ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$FUSE" == "yes" ]; then -FEATURES="fuse=1,keyctl=1,nesting=1" -else -FEATURES="keyctl=1,nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export ST=$FUSE -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$CT_TYPE" == "0" ]; then -cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: c 188:* rwm -lxc.cgroup2.devices.allow: c 189:* rwm -lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir -lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file -EOF -fi -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} Setup should be reachable by going to the following URL. - ${BL}http://${IP} ${CL} \n" diff --git a/ct/casaos.sh b/ct/casaos.sh new file mode 100644 index 00000000..e7bcf8e2 --- /dev/null +++ b/ct/casaos.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/docker.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ______ ____ _____ + / ____/___ __________ _/ __ \/ ___/ + / / / __ `/ ___/ __ `/ / / /\__ \ +/ /___/ /_/ (__ ) /_/ / /_/ /___/ / +\____/\__,_/____/\__,_/\____//____/ + +EOF +} +header_info +echo -e "Loading..." +APP="CasaOS" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + FUSE="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} Setup should be reachable by going to the following URL. + ${BL}http://${IP} ${CL} \n" diff --git a/ct/changedetection-v5.sh b/ct/changedetection-v5.sh deleted file mode 100644 index 64899ce7..00000000 --- a/ct/changedetection-v5.sh +++ /dev/null @@ -1,426 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ________ ____ __ __ _ - / ____/ /_v5____ _____ ____ ____ / __ \___ / /____ _____/ /_(_)___ ____ - / / / __ \/ __ `/ __ \/ __ `/ _ \ / / / / _ \/ __/ _ \/ ___/ __/ / __ \/ __ \ -/ /___/ / / / /_/ / / / / /_/ / __/ / /_/ / __/ /_/ __/ /__/ /_/ / /_/ / / / / -\____/_/ /_/\__,_/_/ /_/\__, /\___/ /_____/\___/\__/\___/\___/\__/_/\____/_/ /_/ - /____/ -EOF -} -header_info -echo -e "Loading..." -APP="Change Detection" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -pip3 install changedetection.io --upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/systemd/system/changedetection.service ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:5000${CL} \n" diff --git a/ct/changedetection.sh b/ct/changedetection.sh new file mode 100644 index 00000000..3f94891c --- /dev/null +++ b/ct/changedetection.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ________ ____ __ __ _ + / ____/ /_ ____ _____ ____ ____ / __ \___ / /____ _____/ /_(_)___ ____ + / / / __ \/ __ `/ __ \/ __ `/ _ \ / / / / _ \/ __/ _ \/ ___/ __/ / __ \/ __ \ +/ /___/ / / / /_/ / / / / /_/ / __/ / /_/ / __/ /_/ __/ /__/ /_/ / /_/ / / / / +\____/_/ /_/\__,_/_/ /_/\__, /\___/ /_____/\___/\__/\___/\___/\__/_/\____/_/ /_/ + /____/ +EOF +} +header_info +echo -e "Loading..." +APP="Change Detection" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/systemd/system/changedetection.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +pip3 install changedetection.io --upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:5000${CL} \n" diff --git a/ct/cronicle-v5.sh b/ct/cronicle-v5.sh deleted file mode 100644 index 890b08cc..00000000 --- a/ct/cronicle-v5.sh +++ /dev/null @@ -1,468 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ______ _ __ - / ____/________v5____ (_)____/ /__ - / / / ___/ __ \/ __ \/ / ___/ / _ \ -/ /___/ / / /_/ / / / / / /__/ / __/ -\____/_/ \____/_/ /_/_/\___/_/\___/ - -EOF -} -header_info -echo -e "Loading..." -APP="Cronicle" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -hostname="$(hostname)" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info -SERVER="y" - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -UPD=$(whiptail --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 2 \ - "1" "Update ${APP}" ON \ - "2" "Install ${APP} Worker" OFF \ - 3>&1 1>&2 2>&3) - -header_info -if [ "$UPD" == "1" ]; then - if [[ ! -d /opt/cronicle ]]; then - msg_error "No ${APP} Installation Found!"; - exit - fi -msg_info "Updating ${APP}" -/opt/cronicle/bin/control.sh upgrade &>/dev/null -msg_ok "Updated ${APP}" -exit -fi -if [ "$UPD" == "2" ]; then -LATEST=$(curl -sL https://api.github.com/repos/jhuckaby/Cronicle/releases/latest | grep '"tag_name":' | cut -d'"' -f4) -IP=$(hostname -I | awk '{print $1}') -msg_info "Installing Dependencies" - -apt-get install -y git &>/dev/null -apt-get install -y make &>/dev/null -apt-get install -y g++ &>/dev/null -apt-get install -y gcc &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -bash <(curl -fsSL https://deb.nodesource.com/setup_16.x) &>/dev/null -msg_ok "Set up Node.js Repository" - -msg_info "Installing Node.js" -apt-get install -y nodejs &>/dev/null -msg_ok "Installed Node.js" - -msg_info "Installing Cronicle Worker" -mkdir -p /opt/cronicle -cd /opt/cronicle -tar zxvf <(curl -fsSL https://github.com/jhuckaby/Cronicle/archive/${LATEST}.tar.gz) --strip-components 1 &>/dev/null -npm install &>/dev/null -node bin/build.js dist &>/dev/null -sed -i "s/localhost:3012/${IP}:3012/g" /opt/cronicle/conf/config.json -/opt/cronicle/bin/control.sh start &>/dev/null -cp /opt/cronicle/bin/cronicled.init /etc/init.d/cronicled &>/dev/null -chmod 775 /etc/init.d/cronicled -update-rc.d cronicled defaults &>/dev/null -msg_ok "Installed Cronicle Worker on $hostname" -echo -e "\n Add Masters secret key to /opt/cronicle/conf/config.json \n" -exit -fi -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export SERV=$SERVER -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} Primary should be reachable by going to the following URL. - ${BL}http://${IP}:3012${CL} admin|admin \n" diff --git a/ct/cronicle.sh b/ct/cronicle.sh new file mode 100644 index 00000000..85019ee5 --- /dev/null +++ b/ct/cronicle.sh @@ -0,0 +1,108 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ______ _ __ + / ____/________ ____ (_)____/ /__ + / / / ___/ __ \/ __ \/ / ___/ / _ \ +/ /___/ / / /_/ / / / / / /__/ / __/ +\____/_/ \____/_/ /_/_/\___/_/\___/ + +EOF +} +header_info +echo -e "Loading..." +APP="Cronicle" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +if [[ ! -d /opt/cronicle ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +UPD=$(whiptail --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 2 \ + "1" "Update ${APP}" ON \ + "2" "Install ${APP} Worker" OFF \ + 3>&1 1>&2 2>&3) + +header_info +msg_info "Updating ${APP}" +/opt/cronicle/bin/control.sh upgrade &>/dev/null +msg_ok "Updated ${APP}" +exit +fi +if [ "$UPD" == "2" ]; then +LATEST=$(curl -sL https://api.github.com/repos/jhuckaby/Cronicle/releases/latest | grep '"tag_name":' | cut -d'"' -f4) +IP=$(hostname -I | awk '{print $1}') +msg_info "Installing Dependencies" + +apt-get install -y git &>/dev/null +apt-get install -y make &>/dev/null +apt-get install -y g++ &>/dev/null +apt-get install -y gcc &>/dev/null +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +bash <(curl -fsSL https://deb.nodesource.com/setup_16.x) &>/dev/null +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +apt-get install -y nodejs &>/dev/null +msg_ok "Installed Node.js" + +msg_info "Installing Cronicle Worker" +mkdir -p /opt/cronicle +cd /opt/cronicle +tar zxvf <(curl -fsSL https://github.com/jhuckaby/Cronicle/archive/${LATEST}.tar.gz) --strip-components 1 &>/dev/null +npm install &>/dev/null +node bin/build.js dist &>/dev/null +sed -i "s/localhost:3012/${IP}:3012/g" /opt/cronicle/conf/config.json +/opt/cronicle/bin/control.sh start &>/dev/null +cp /opt/cronicle/bin/cronicled.init /etc/init.d/cronicled &>/dev/null +chmod 775 /etc/init.d/cronicled +update-rc.d cronicled defaults &>/dev/null +msg_ok "Installed Cronicle Worker on $hostname" +echo -e "\n Add Masters secret key to /opt/cronicle/conf/config.json \n" +exit +fi +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} Primary should be reachable by going to the following URL. + ${BL}http://${IP}:3012${CL} admin|admin \n" diff --git a/ct/daemonsync-v5.sh b/ct/daemonsync-v5.sh deleted file mode 100644 index bb50f147..00000000 --- a/ct/daemonsync-v5.sh +++ /dev/null @@ -1,427 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ _____ - / __ \____ ____ ____ ___ ____ ____ / ___/__v5______ _____ - / / / / __ / _ \/ __ __ \/ __ \/ __ \ \__ \/ / / / __ \/ ___/ - / /_/ / /_/ / __/ / / / / / /_/ / / / / ___/ / /_/ / / / / /__ -/_____/\__,_/\___/_/ /_/ /_/\____/_/ /_/ /____/\__, /_/ /_/\___/ - /____/ -EOF -} -header_info -echo -e "Loading..." -APP="Daemon Sync" -var_disk="8" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /etc/daemonsync ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8084${CL} \n" diff --git a/ct/daemonsync.sh b/ct/daemonsync.sh new file mode 100644 index 00000000..5b0a2ee6 --- /dev/null +++ b/ct/daemonsync.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ____ _____ + / __ \____ ____ ____ ___ ____ ____ / ___/__ ______ _____ + / / / / __ / _ \/ __ __ \/ __ \/ __ \ \__ \/ / / / __ \/ ___/ + / /_/ / /_/ / __/ / / / / / /_/ / / / / ___/ / /_/ / / / / /__ +/_____/\__,_/\___/_/ /_/ /_/\____/_/ /_/ /____/\__, /_/ /_/\___/ + /____/ +EOF +} +header_info +echo -e "Loading..." +APP="Daemon Sync" +var_disk="8" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8084${CL} \n" diff --git a/ct/dashy-v5.sh b/ct/dashy-v5.sh deleted file mode 100644 index 0b63ea64..00000000 --- a/ct/dashy-v5.sh +++ /dev/null @@ -1,452 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __ - / __ \____ ______/ /_ __ __ - / / / / __ / ___/ __ \/ / / / - / /_/ / /_/ (__ ) / / / /_/ / -/_____/\__,_/____/_/ /_/\__, / - v5 /____/ -EOF -} -header_info -echo -e "Loading..." -APP="Dashy" -var_disk="6" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Stopping ${APP}" -systemctl stop dashy -msg_ok "Stopped ${APP}" - -msg_info "Backing up conf.yml" -cd ~ -cp -R /dashy/public/conf.yml conf.yml -msg_ok "Backed up conf.yml" - -msg_info "Updating Dashy" -cd /dashy -git merge &>/dev/null -git pull origin master &>/dev/null -yarn &>/dev/null -yarn build &>/dev/null -msg_ok "Updated Dashy" - -msg_info "Restoring conf.yml" -cd ~ -cp -R conf.yml /dashy/public -msg_ok "Restored conf.yml" - -msg_info "Cleaning" -rm -rf conf.yml -msg_ok "Cleaned" - -msg_info "Starting Dashy" -systemctl start dashy -msg_ok "Started Dashy" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/systemd/system/dashy.service ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:4000${CL} \n" diff --git a/ct/dashy.sh b/ct/dashy.sh new file mode 100644 index 00000000..63338364 --- /dev/null +++ b/ct/dashy.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ____ __ + / __ \____ ______/ /_ __ __ + / / / / __ / ___/ __ \/ / / / + / /_/ / /_/ (__ ) / / / /_/ / +/_____/\__,_/____/_/ /_/\__, / + /____/ +EOF +} +header_info +echo -e "Loading..." +APP="Dashy" +var_disk="6" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /dashy/public/ ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Stopping ${APP}" +systemctl stop dashy +msg_ok "Stopped ${APP}" + +msg_info "Backing up conf.yml" +cd ~ +cp -R /dashy/public/conf.yml conf.yml +msg_ok "Backed up conf.yml" + +msg_info "Updating Dashy" +cd /dashy +git merge &>/dev/null +git pull origin master &>/dev/null +yarn &>/dev/null +yarn build &>/dev/null +msg_ok "Updated Dashy" + +msg_info "Restoring conf.yml" +cd ~ +cp -R conf.yml /dashy/public +msg_ok "Restored conf.yml" + +msg_info "Cleaning" +rm -rf conf.yml +msg_ok "Cleaned" + +msg_info "Starting Dashy" +systemctl start dashy +msg_ok "Started Dashy" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:4000${CL} \n" diff --git a/ct/debian-v5.sh b/ct/debian-v5.sh deleted file mode 100644 index b0c885f4..00000000 --- a/ct/debian-v5.sh +++ /dev/null @@ -1,419 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __ _ - / __ \___v5/ /_ (_)___ _____ - / / / / _ \/ __ \/ / __ `/ __ \ - / /_/ / __/ /_/ / / /_/ / / / / -/_____/\___/_.___/_/\__,_/_/ /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Debian" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating $APP LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated $APP LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} ${var_version} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" diff --git a/ct/debian.sh b/ct/debian.sh new file mode 100644 index 00000000..3ece2f2a --- /dev/null +++ b/ct/debian.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ____ __ _ + / __ \___ / /_ (_)___ _____ + / / / / _ \/ __ \/ / __ `/ __ \ + / /_/ / __/ /_/ / / /_/ / / / / +/_____/\___/_.___/_/\__,_/_/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Debian" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" \ No newline at end of file diff --git a/ct/deconz-v5.sh b/ct/deconz-v5.sh deleted file mode 100644 index cdeb7a75..00000000 --- a/ct/deconz-v5.sh +++ /dev/null @@ -1,442 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ __________ _ _______ - ____/ /v5 / ____/ __ \/ | / /__ / - / __ / _ \/ / / / / / |/ / / / -/ /_/ / __/ /___/ /_/ / /| / / /__ -\__,_/\___/\____/\____/_/ |_/ /____/ - -EOF -} -header_info -echo -e "Loading..." -APP="deCONZ" -var_disk="4" -var_cpu="2" -var_ram="1024" -var_os="ubuntu" -var_version="20.04" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}" - echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" - CT_TYPE="0" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/apt/sources.list.d/deconz.list ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -if [ "$CT_TYPE" == "0" ]; then - LXC_CONFIG=/etc/pve/lxc/${CTID}.conf - cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -lxc.cgroup2.devices.allow: c 188:* rwm -lxc.cgroup2.devices.allow: c 189:* rwm -lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir -lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file -EOF -fi -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}${CL}\n" diff --git a/ct/deconz.sh b/ct/deconz.sh new file mode 100644 index 00000000..d43073f8 --- /dev/null +++ b/ct/deconz.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/ubuntu.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ __________ _ _______ + ____/ /__ / ____/ __ \/ | / /__ / + / __ / _ \/ / / / / / |/ / / / +/ /_/ / __/ /___/ /_/ / /| / / /__ +\__,_/\___/\____/\____/_/ |_/ /____/ + +EOF +} +header_info +echo -e "Loading..." +APP="deCONZ" +var_disk="4" +var_cpu="2" +var_ram="1024" +var_os="ubuntu" +var_version="20.04" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="0" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/apt/sources.list.d/deconz.list ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}${CL}\n" diff --git a/ct/deluge-v5.sh b/ct/deluge-v5.sh deleted file mode 100644 index 7d95aa64..00000000 --- a/ct/deluge-v5.sh +++ /dev/null @@ -1,427 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __ - / __ \___ / /_v5______ ____ - / / / / _ \/ / / / / __ `/ _ \ - / /_/ / __/ / /_/ / /_/ / __/ -/_____/\___/_/\__,_/\__, /\___/ - /____/ - -EOF -} -header_info -echo -e "Loading..." -APP="Deluge" -var_disk="4" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating $APP LXC" -apt-get update &>/dev/null -pip3 install deluge[all] --upgrade -msg_ok "Updated $APP LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/systemd/system/deluged.service ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8112${CL} \n" diff --git a/ct/deluge.sh b/ct/deluge.sh new file mode 100644 index 00000000..da8ce1eb --- /dev/null +++ b/ct/deluge.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ____ __ + / __ \___ / /_ ______ ____ + / / / / _ \/ / / / / __ `/ _ \ + / /_/ / __/ / /_/ / /_/ / __/ +/_____/\___/_/\__,_/\__, /\___/ + /____/ + +EOF +} +header_info +echo -e "Loading..." +APP="Deluge" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/systemd/system/deluged.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +pip3 install deluge[all] --upgrade +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8112${CL} \n" diff --git a/ct/devuan-v5.sh b/ct/devuan-v5.sh deleted file mode 100644 index ac845530..00000000 --- a/ct/devuan-v5.sh +++ /dev/null @@ -1,419 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ - / __ \___ _ ____ ______v5____ - / / / / _ \ | / / / / / __ `/ __ \ - / /_/ / __/ |/ / /_/ / /_/ / / / / -/_____/\___/|___/\__,_/\__,_/_/ /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Devuan" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="devuan" -var_version="4.0" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}$NSAPP${CL}" - PW="-password $NSAPP" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating $APP LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated $APP LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} ${var_version} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" diff --git a/ct/devuan.sh b/ct/devuan.sh new file mode 100644 index 00000000..6c51b605 --- /dev/null +++ b/ct/devuan.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ____ + / __ \___ _ ____ ______ ____ + / / / / _ \ | / / / / / __ `/ __ \ + / /_/ / __/ |/ / /_/ / /_/ / / / / +/_____/\___/|___/\__,_/\__,_/_/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Devuan" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="devuan" +var_version="4.0" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/docker-v5.sh b/ct/docker-v5.sh deleted file mode 100644 index 677398a0..00000000 --- a/ct/docker-v5.sh +++ /dev/null @@ -1,446 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __ - / __ \____ _____/ /_v5__ _____ - / / / / __ \/ ___/ //_/ _ \/ ___/ - / /_/ / /_/ / /__/ ,< / __/ / -/_____/\____/\___/_/|_|\___/_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Docker" -var_disk="4" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Fuse Overlayfs (ZFS): ${BGN}No${CL}" - FUSE="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "FUSE OVERLAYFS" --yesno "(ZFS) Enable Fuse Overlayfs?" 10 58); then - FUSE="yes" -else - FUSE="no" -fi - echo -e "${DGN}Enable Fuse Overlayfs (ZFS): ${BGN}$FUSE${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$FUSE" == "yes" ]; then -FEATURES="fuse=1,keyctl=1,nesting=1" -else -FEATURES="keyctl=1,nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export ST=$FUSE -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$CT_TYPE" == "0" ]; then -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: c 188:* rwm -lxc.cgroup2.devices.allow: c 189:* rwm -lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir -lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file -EOF -fi -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" diff --git a/ct/docker.sh b/ct/docker.sh new file mode 100644 index 00000000..37ca3808 --- /dev/null +++ b/ct/docker.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/docker.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ____ __ + / __ \____ _____/ /_ __ _____ + / / / / __ \/ ___/ //_/ _ \/ ___/ + / /_/ / /_/ / /__/ ,< / __/ / +/_____/\____/\___/_/|_|\___/_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Docker" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + FUSE="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/emby-v5.sh b/ct/emby-v5.sh deleted file mode 100644 index d138f812..00000000 --- a/ct/emby-v5.sh +++ /dev/null @@ -1,460 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ______ __ - / ____/___ v5_ / /_ __ __ - / __/ / __ __ \/ __ \/ / / / - / /___/ / / / / / /_/ / /_/ / -/_____/_/ /_/ /_/_.___/\__, / - /____/ -EOF -} -header_info -echo -e "Loading..." -APP="Emby" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="ubuntu" -var_version="20.04" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}" - echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" - CT_TYPE="0" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if var_version=$(whiptail --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 4 \ - "18.04" "Bionic" OFF \ - "20.04" "Focal" ON \ - "22.04" "Jammy" OFF \ - "22.10" "Kinetic" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Ubuntu Version: ${BGN}$var_version${CL}" -else - exit-script -fi -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" OFF \ - "0" "Privileged" ON \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -LATEST=$(curl -sL https://api.github.com/repos/MediaBrowser/Emby.Releases/releases/latest | grep '"tag_name":' | cut -d'"' -f4) -msg_info "Stopping ${APP}" -systemctl stop emby-server -msg_ok "Stopped ${APP}" - -msg_info "Updating ${APP}" -wget https://github.com/MediaBrowser/Emby.Releases/releases/download/${LATEST}/emby-server-deb_${LATEST}_amd64.deb &>/dev/null -dpkg -i emby-server-deb_${LATEST}_amd64.deb &>/dev/null -rm emby-server-deb_${LATEST}_amd64.deb -msg_ok "Updated ${APP}" - -msg_info "Starting ${APP}" -systemctl start emby-server -msg_ok "Started ${APP}" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/emby-server ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -if [ "$CT_TYPE" == "0" ]; then - LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: c 226:0 rwm -lxc.cgroup2.devices.allow: c 226:128 rwm -lxc.cgroup2.devices.allow: c 29:0 rwm -lxc.mount.entry: /dev/fb0 dev/fb0 none bind,optional,create=file -lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir -lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file -EOF -fi -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8096${CL}\n" diff --git a/ct/emby.sh b/ct/emby.sh new file mode 100644 index 00000000..dd296190 --- /dev/null +++ b/ct/emby.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/ubuntu.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ______ __ + / ____/___ ___ / /_ __ __ + / __/ / __ __ \/ __ \/ / / / + / /___/ / / / / / /_/ / /_/ / +/_____/_/ /_/ /_/_.___/\__, / + /____/ +EOF +} +header_info +echo -e "Loading..." +APP="Emby" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="ubuntu" +var_version="20.04" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="0" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/emby-server ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +LATEST=$(curl -sL https://api.github.com/repos/MediaBrowser/Emby.Releases/releases/latest | grep '"tag_name":' | cut -d'"' -f4) +msg_info "Stopping ${APP}" +systemctl stop emby-server +msg_ok "Stopped ${APP}" + +msg_info "Updating ${APP}" +wget https://github.com/MediaBrowser/Emby.Releases/releases/download/${LATEST}/emby-server-deb_${LATEST}_amd64.deb &>/dev/null +dpkg -i emby-server-deb_${LATEST}_amd64.deb &>/dev/null +rm emby-server-deb_${LATEST}_amd64.deb +msg_ok "Updated ${APP}" + +msg_info "Starting ${APP}" +systemctl start emby-server +msg_ok "Started ${APP}" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8096${CL}\n" diff --git a/ct/emqx-v5.sh b/ct/emqx-v5.sh deleted file mode 100644 index 45bbd9fa..00000000 --- a/ct/emqx-v5.sh +++ /dev/null @@ -1,421 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ________ _______v5 _ __ - / ____/ |/ / __ \ | |/ / - / __/ / /|_/ / / / / | / - / /___/ / / / /_/ / / | -/_____/_/ /_/\___\_\/_/|_| - -EOF -} -header_info -echo -e "Loading..." -APP="EMQX" -var_disk="4" -var_cpu="2" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} Setup should be reachable by going to the following URL. - ${BL}http://${IP}:18083${CL} \n" diff --git a/ct/emqx.sh b/ct/emqx.sh new file mode 100644 index 00000000..69afa53d --- /dev/null +++ b/ct/emqx.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ________ _______ _ __ + / ____/ |/ / __ \ | |/ / + / __/ / /|_/ / / / / | / + / /___/ / / / /_/ / / | +/_____/_/ /_/\___\_\/_/|_| + +EOF +} +header_info +echo -e "Loading..." +APP="EMQX" +var_disk="4" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} Setup should be reachable by going to the following URL. + ${BL}http://${IP}:18083${CL} \n" diff --git a/ct/esphome-v5.sh b/ct/esphome-v5.sh deleted file mode 100644 index 5cb1c4f2..00000000 --- a/ct/esphome-v5.sh +++ /dev/null @@ -1,434 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ___________ ____ __ __ - / ____/ ___// __ \/ / / /___v5____ ___ ___ - / __/ \__ \/ /_/ / /_/ / __ \/ __ `__ \/ _ \ - / /___ ___/ / ____/ __ / /_/ / / / / / / __/ -/_____//____/_/ /_/ /_/\____/_/ /_/ /_/\___/ - -EOF -} -header_info -echo -e "Loading..." -APP="ESPHome" -var_disk="4" -var_cpu="2" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Stopping ESPHome" -systemctl stop esphomeDashboard -msg_ok "Stopped ESPHome" - -msg_info "Updating ESPHome" -pip3 install esphome --upgrade &>/dev/null -msg_ok "Updated ESPHome" - -msg_info "Starting ESPHome" -systemctl start esphomeDashboard -msg_ok "Started ESPHome" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /usr/local/bin/esphome ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:6052${CL} \n" diff --git a/ct/esphome.sh b/ct/esphome.sh new file mode 100644 index 00000000..1c25bd4f --- /dev/null +++ b/ct/esphome.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ___________ ____ __ __ + / ____/ ___// __ \/ / / /___ ____ ___ ___ + / __/ \__ \/ /_/ / /_/ / __ \/ __ `__ \/ _ \ + / /___ ___/ / ____/ __ / /_/ / / / / / / __/ +/_____//____/_/ /_/ /_/\____/_/ /_/ /_/\___/ + +EOF +} +header_info +echo -e "Loading..." +APP="ESPHome" +var_disk="4" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /usr/local/bin/esphome ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Stopping ESPHome" +systemctl stop esphomeDashboard +msg_ok "Stopped ESPHome" + +msg_info "Updating ESPHome" +pip3 install esphome --upgrade &>/dev/null +msg_ok "Updated ESPHome" + +msg_info "Starting ESPHome" +systemctl start esphomeDashboard +msg_ok "Started ESPHome" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:6052${CL} \n" diff --git a/ct/go2rtc-v5.sh b/ct/go2rtc-v5.sh deleted file mode 100644 index cf95a685..00000000 --- a/ct/go2rtc-v5.sh +++ /dev/null @@ -1,421 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - ___ __ - ____ _____ |__ \ _____/ /__v5__ - / __ `/ __ \__/ // ___/ __/ ___/ - / /_/ / /_/ / __// / / /_/ /__ - \__, /\____/____/_/ \__/\___/ -/____/ - -EOF -} -header_info -echo -e "Loading..." -APP="go2rtc" -var_disk="4" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating $APP LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated $APP LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:1984${CL} \n" diff --git a/ct/go2rtc.sh b/ct/go2rtc.sh new file mode 100644 index 00000000..ebd1fade --- /dev/null +++ b/ct/go2rtc.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ___ __ + ____ _____ |__ \ _____/ /______ + / __ `/ __ \__/ // ___/ __/ ___/ + / /_/ / /_/ / __// / / /_/ /__ + \__, /\____/____/_/ \__/\___/ +/____/ + +EOF +} +header_info +echo -e "Loading..." +APP="go2rtc" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:1984${CL} \n" diff --git a/ct/grafana-v5.sh b/ct/grafana-v5.sh deleted file mode 100644 index 2984483f..00000000 --- a/ct/grafana-v5.sh +++ /dev/null @@ -1,427 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ______ ____ - / ____/________ _/ __/___ _____v5____ _ - / / __/ ___/ __ / /_/ __ / __ \/ __ / -/ /_/ / / / /_/ / __/ /_/ / / / / /_/ / -\____/_/ \__,_/_/ \__,_/_/ /_/\__,_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Grafana" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/apt/sources.list.d/grafana.list ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:3000${CL} \n" diff --git a/ct/grafana.sh b/ct/grafana.sh new file mode 100644 index 00000000..f908c465 --- /dev/null +++ b/ct/grafana.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ______ ____ + / ____/________ _/ __/___ _____ ____ _ + / / __/ ___/ __ / /_/ __ / __ \/ __ / +/ /_/ / / / /_/ / __/ /_/ / / / / /_/ / +\____/_/ \__,_/_/ \__,_/_/ /_/\__,_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Grafana" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:3000${CL} \n" diff --git a/ct/grocy-v5.sh b/ct/grocy-v5.sh deleted file mode 100644 index ca85cf3f..00000000 --- a/ct/grocy-v5.sh +++ /dev/null @@ -1,426 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __________ _______ __ - / __ / ___/ __ \/ ___/ / / / - / /_/ / / / /_/ / /__/ /_/ / - \__, /_/ v5\____/\___/\__, / -/____/ /____/ - -EOF -} -header_info -echo -e "Loading..." -APP="grocy" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP}" -bash /var/www/html/update.sh -msg_ok "Updated ${APP}" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/apache2/sites-available/grocy.conf ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}${CL} \n" diff --git a/ct/grocy.sh b/ct/grocy.sh new file mode 100644 index 00000000..bf7a05b8 --- /dev/null +++ b/ct/grocy.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ____ __________ _______ __ + / __ / ___/ __ \/ ___/ / / / + / /_/ / / / /_/ / /__/ /_/ / + \__, /_/ \____/\___/\__, / +/____/ /____/ + +EOF +} +header_info +echo -e "Loading..." +APP="grocy" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/apache2/sites-available/grocy.conf ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP}" +bash /var/www/html/update.sh +msg_ok "Updated ${APP}" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}${CL} \n" diff --git a/ct/heimdalldashboard-v5.sh b/ct/heimdalldashboard-v5.sh deleted file mode 100644 index 8853bb2b..00000000 --- a/ct/heimdalldashboard-v5.sh +++ /dev/null @@ -1,506 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _ _ _ _ ___ _ _ _ - /\ /\___(_)_ __ ___ __| | __ _| | | / \__ _ ___| |__ | |__ ___ __ _ _ __ __| | - / /_/ / _ \ | '_ ` _ \ / _` |/ _` | | | / /\ / _` / __| '_ \| '_ \ / _ \ / _` | '__/ _` | -/ __ / __/ | | | | | | (_| | (_| | | |v5/ /_// (_| \__ \ | | | |_) | (_) | (_| | | | (_| | -\/ /_/ \___|_|_| |_| |_|\__,_|\__,_|_|_| /___,' \__,_|___/_| |_|_.__/ \___/ \__,_|_| \__,_| - -EOF -} -header_info -echo -e "Loading..." -APP="Heimdall Dashboard" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Stopping ${APP}" -systemctl disable heimdall.service &>/dev/null -systemctl stop heimdall -sleep 1 -msg_ok "Stopped ${APP}" - -msg_info "Backing up Data" -if [ -d "/opt/Heimdall-2.4.6" ]; then - cp -R /opt/Heimdall-2.4.6/database database-backup - cp -R /opt/Heimdall-2.4.6/public public-backup -elif [[ -d "/opt/Heimdall-2.4.7b" ]]; then - cp -R /opt/Heimdall-2.4.7b/database database-backup - cp -R /opt/Heimdall-2.4.7b/public public-backup -elif [[ -d "/opt/Heimdall-2.4.8" ]]; then - cp -R /opt/Heimdall-2.4.8/database database-backup - cp -R /opt/Heimdall-2.4.8/public public-backup -else - cp -R /opt/Heimdall/database database-backup - cp -R /opt/Heimdall/public public-backup -fi -sleep 1 -msg_ok "Backed up Data" - -RELEASE=$(curl -sX GET "https://api.github.com/repos/linuxserver/Heimdall/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]') -msg_info "Updating Heimdall Dashboard to ${RELEASE}" -curl --silent -o ${RELEASE}.tar.gz -L "https://github.com/linuxserver/Heimdall/archive/${RELEASE}.tar.gz" &>/dev/null -tar xvzf ${RELEASE}.tar.gz &>/dev/null -VER=$(curl -s https://api.github.com/repos/linuxserver/Heimdall/releases/latest | - grep "tag_name" | - awk '{print substr($2, 3, length($2)-4) }') - -if [ ! -d "/opt/Heimdall" ]; then - mv Heimdall-${VER} /opt/Heimdall -else - cp -R Heimdall-${VER}/* /opt/Heimdall -fi - -service_path="/etc/systemd/system/heimdall.service" -echo "[Unit] -Description=Heimdall -After=network.target -[Service] -Restart=always -RestartSec=5 -Type=simple -User=root -WorkingDirectory=/opt/Heimdall -ExecStart="/usr/bin/php" artisan serve --port 7990 --host 0.0.0.0 -TimeoutStopSec=30 -[Install] -WantedBy=multi-user.target" >$service_path -msg_ok "Updated Heimdall Dashboard to ${RELEASE}" - -msg_info "Restoring Data" -cp -R database-backup/* /opt/Heimdall/database -cp -R public-backup/* /opt/Heimdall/public -sleep 1 -msg_ok "Restored Data" - -msg_info "Cleanup" -if [ -d "/opt/Heimdall-2.4.6" ]; then - rm -rf /opt/Heimdall-2.4.6 - rm -rf /opt/v2.4.6.tar.gz -elif [[ -d "/opt/Heimdall-2.4.7b" ]]; then - rm -rf /opt/Heimdall-2.4.7b - rm -rf /opt/v2.4.7b.tar.gz -elif [[ -d "/opt/Heimdall-2.4.8" ]]; then - rm -rf /opt/Heimdall-2.4.8 - rm -rf /opt/v2.4.8.tar.gz -fi - -rm -rf ${RELEASE}.tar.gz -rm -rf Heimdall-${VER} -rm -rf public-backup -rm -rf database-backup -rm -rf Heimdall -sleep 1 -msg_ok "Cleaned" - -msg_info "Starting ${APP}" -systemctl enable --now heimdall.service &>/dev/null -sleep 2 -msg_ok "Started ${APP}" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/Heimdall ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:7990${CL} \n" diff --git a/ct/heimdalldashboard.sh b/ct/heimdalldashboard.sh new file mode 100644 index 00000000..3a631eeb --- /dev/null +++ b/ct/heimdalldashboard.sh @@ -0,0 +1,149 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + _ _ _ _ ___ _ _ _ + /\ /\___(_)_ __ ___ __| | __ _| | | / \__ _ ___| |__ | |__ ___ __ _ _ __ __| | + / /_/ / _ \ | '_ ` _ \ / _` |/ _` | | | / /\ / _` / __| '_ \| '_ \ / _ \ / _` | '__/ _` | +/ __ / __/ | | | | | | (_| | (_| | | | / /_// (_| \__ \ | | | |_) | (_) | (_| | | | (_| | +\/ /_/ \___|_|_| |_| |_|\__,_|\__,_|_|_| /___,' \__,_|___/_| |_|_.__/ \___/ \__,_|_| \__,_| + +EOF +} +header_info +echo -e "Loading..." +APP="Heimdall Dashboard" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/Heimdall ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Stopping ${APP}" +systemctl disable heimdall.service &>/dev/null +systemctl stop heimdall +sleep 1 +msg_ok "Stopped ${APP}" + +msg_info "Backing up Data" +if [ -d "/opt/Heimdall-2.4.6" ]; then + cp -R /opt/Heimdall-2.4.6/database database-backup + cp -R /opt/Heimdall-2.4.6/public public-backup +elif [[ -d "/opt/Heimdall-2.4.7b" ]]; then + cp -R /opt/Heimdall-2.4.7b/database database-backup + cp -R /opt/Heimdall-2.4.7b/public public-backup +elif [[ -d "/opt/Heimdall-2.4.8" ]]; then + cp -R /opt/Heimdall-2.4.8/database database-backup + cp -R /opt/Heimdall-2.4.8/public public-backup +else + cp -R /opt/Heimdall/database database-backup + cp -R /opt/Heimdall/public public-backup +fi +sleep 1 +msg_ok "Backed up Data" + +RELEASE=$(curl -sX GET "https://api.github.com/repos/linuxserver/Heimdall/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]') +msg_info "Updating Heimdall Dashboard to ${RELEASE}" +curl --silent -o ${RELEASE}.tar.gz -L "https://github.com/linuxserver/Heimdall/archive/${RELEASE}.tar.gz" &>/dev/null +tar xvzf ${RELEASE}.tar.gz &>/dev/null +VER=$(curl -s https://api.github.com/repos/linuxserver/Heimdall/releases/latest | + grep "tag_name" | + awk '{print substr($2, 3, length($2)-4) }') + +if [ ! -d "/opt/Heimdall" ]; then + mv Heimdall-${VER} /opt/Heimdall +else + cp -R Heimdall-${VER}/* /opt/Heimdall +fi + +service_path="/etc/systemd/system/heimdall.service" +echo "[Unit] +Description=Heimdall +After=network.target +[Service] +Restart=always +RestartSec=5 +Type=simple +User=root +WorkingDirectory=/opt/Heimdall +ExecStart="/usr/bin/php" artisan serve --port 7990 --host 0.0.0.0 +TimeoutStopSec=30 +[Install] +WantedBy=multi-user.target" >$service_path +msg_ok "Updated Heimdall Dashboard to ${RELEASE}" + +msg_info "Restoring Data" +cp -R database-backup/* /opt/Heimdall/database +cp -R public-backup/* /opt/Heimdall/public +sleep 1 +msg_ok "Restored Data" + +msg_info "Cleanup" +if [ -d "/opt/Heimdall-2.4.6" ]; then + rm -rf /opt/Heimdall-2.4.6 + rm -rf /opt/v2.4.6.tar.gz +elif [[ -d "/opt/Heimdall-2.4.7b" ]]; then + rm -rf /opt/Heimdall-2.4.7b + rm -rf /opt/v2.4.7b.tar.gz +elif [[ -d "/opt/Heimdall-2.4.8" ]]; then + rm -rf /opt/Heimdall-2.4.8 + rm -rf /opt/v2.4.8.tar.gz +fi + +rm -rf ${RELEASE}.tar.gz +rm -rf Heimdall-${VER} +rm -rf public-backup +rm -rf database-backup +rm -rf Heimdall +sleep 1 +msg_ok "Cleaned" + +msg_info "Starting ${APP}" +systemctl enable --now heimdall.service &>/dev/null +sleep 2 +msg_ok "Started ${APP}" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:7990${CL} \n" diff --git a/ct/homeassistant-core-v5.sh b/ct/homeassistant-core-v5.sh deleted file mode 100644 index cbb5aea1..00000000 --- a/ct/homeassistant-core-v5.sh +++ /dev/null @@ -1,586 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _ _ _ _ ___ - /\ /\___ _ __ ___ ___ /_\ ___ ___(_)___| |_ __ _ _ __ | |_ / __\___v5_ __ ___ - / /_/ / _ \| '_ ` _ \ / _ \ //_\\/ __/ __| / __| __/ _` | '_ \| __| / / / _ \| '__/ _ \ -/ __ / (_) | | | | | | __/ / _ \__ \__ \ \__ \ || (_| | | | | |_ / /__| (_) | | | __/ -\/ /_/ \___/|_| |_| |_|\___| \_/ \_/___/___/_|___/\__\__,_|_| |_|\__| \____/\___/|_| \___| - -EOF -} -header_info -echo -e "Loading..." -APP="Home Assistant-Core" -var_disk="8" -var_cpu="2" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -STABLE=$(curl -s https://raw.githubusercontent.com/home-assistant/version/master/stable.json | grep "default" | awk '{print substr($2, 2, length($2)-3) }') -BETA=$(curl -s https://raw.githubusercontent.com/home-assistant/version/master/beta.json | grep "default" | awk '{print substr($2, 2, length($2)-3) }') -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { - PY=$(ls /srv/homeassistant/lib/) - IP=$(hostname -I | awk '{print $1}') - UPD=$(whiptail --title "UPDATE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 4 \ - "1" "Update Core" ON \ - "2" "Install HACS" OFF \ - "3" "Install FileBrowser" OFF \ - "4" "Install/Update AppDaemon" OFF \ - 3>&1 1>&2 2>&3) -header_info -if [ "$UPD" == "1" ]; then - if (whiptail --defaultno --title "SELECT BRANCH" --yesno "Use Beta Branch?" 10 58); then - clear - header_info - echo -e "${GN}Updating to Version ${BETA}${CL}" - BR="--pre " - else - clear - header_info - echo -e "${GN}Updating to Version ${STABLE}${CL}" - BR="" - fi - if [[ "$PY" == "python3.9" ]]; then echo -e "⚠️ Python 3.9 is deprecated and will be removed in Home Assistant 2023.2"; fi - -msg_info "Stopping Home Assistant" -systemctl stop homeassistant -msg_ok "Stopped Home Assistant" - -msg_info "Updating Home Assistant" -source /srv/homeassistant/bin/activate -pip install ${BR}--upgrade homeassistant &>/dev/null -msg_ok "Updated Home Assistant" - -msg_info "Starting Home Assistant" -systemctl start homeassistant -sleep 2 -msg_ok "Started Home Assistant" -msg_ok "Update Successful" -echo -e "\n Go to http://${IP}:8123 \n" -exit -fi -if [ "$UPD" == "2" ]; then -msg_info "Installing Home Assistant Comunity Store (HACS)" -apt update &>/dev/null -apt install unzip &>/dev/null -cd .homeassistant -bash <(curl -fsSL https://get.hacs.xyz) &>/dev/null -msg_ok "Installed Home Assistant Comunity Store (HACS)" -echo -e "\n Reboot Home Assistant and clear browser cache then Add HACS integration.\n" -exit -fi -if [ "$UPD" == "3" ]; then -msg_info "Installing FileBrowser" -curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash &>/dev/null -filebrowser config init -a '0.0.0.0' &>/dev/null -filebrowser config set -a '0.0.0.0' &>/dev/null -filebrowser users add admin changeme --perm.admin &>/dev/null -msg_ok "Installed FileBrowser" - -msg_info "Creating Service" -service_path="/etc/systemd/system/filebrowser.service" -echo "[Unit] -Description=Filebrowser -After=network-online.target -[Service] -User=root -WorkingDirectory=/root/ -ExecStart=/usr/local/bin/filebrowser -r /root/.homeassistant -[Install] -WantedBy=default.target" >$service_path - -systemctl enable --now filebrowser.service &>/dev/null -msg_ok "Created Service" - -msg_ok "Completed Successfully!\n" -echo -e "FileBrowser should be reachable by going to the following URL. - ${BL}http://$IP:8080${CL} admin|changeme\n" -exit -fi -if [ "$UPD" == "4" ]; then - clear - header_info - if [[ ! -d /srv/appdaemon ]]; then - msg_info "Installing AppDaemon" - mkdir /srv/appdaemon - cd /srv/appdaemon - python3 -m venv . - source bin/activate - pip install appdaemon &>/dev/null - mkdir -p /root/.homeassistant/appdaemon/apps - cat > /root/.homeassistant/appdaemon/appdaemon.yaml << EOF -# Sample appdaemon.yml file -# For configuration, please visit: https://appdaemon.readthedocs.io/en/latest/CONFIGURE.html -appdaemon: - time_zone: CET - latitude: 51.725 - longitude: 14.3434 - elevation: 0 - plugins: - HASS: - type: hass - ha_url: - token: -http: - url: http://127.0.0.1:5050 -admin: -api: -EOF - msg_ok "Installed AppDaemon" - - msg_info "Creating Service" - cat > /etc/systemd/system/appdaemon.service << EOF -[Unit] -Description=AppDaemon -After=homeassistant.service -Requires=homeassistant.service -[Service] -Type=simple -WorkingDirectory=/root/.homeassistant/appdaemon -ExecStart=/srv/appdaemon/bin/appdaemon -c "/root/.homeassistant/appdaemon" -RestartForceExitStatus=100 -[Install] -WantedBy=multi-user.target -EOF - systemctl enable --now appdaemon &>/dev/null - msg_ok "Created Service" - - msg_ok "Completed Successfully!\n" - echo -e "AppDaemon should be reachable by going to the following URL. - ${BL}http://$IP:5050${CL}\n" - exit - else - msg_info "Upgrading AppDaemon" - msg_info "Stopping AppDaemon" - systemctl stop appdaemon - msg_ok "Stopped AppDaemon" - - msg_info "Updating AppDaemon" - source /srv/appdaemon/bin/activate - pip install --upgrade appdaemon &>/dev/null - msg_ok "Updated AppDaemon" - - msg_info "Starting AppDaemon" - systemctl start appdaemon - sleep 2 - msg_ok "Started AppDaemon" - msg_ok "Update Successful" - echo -e "\n Go to http://${IP}:5050 \n" - exit - fi -fi -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /srv/homeassistant ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -if [ "$CT_TYPE" == "0" ]; then - LXC_CONFIG=/etc/pve/lxc/${CTID}.conf - cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -lxc.cgroup2.devices.allow: c 188:* rwm -lxc.cgroup2.devices.allow: c 189:* rwm -lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir -lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file -EOF -fi -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8123${CL}" diff --git a/ct/homeassistant-core.sh b/ct/homeassistant-core.sh new file mode 100644 index 00000000..68cbf783 --- /dev/null +++ b/ct/homeassistant-core.sh @@ -0,0 +1,216 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + _ _ _ _ ___ + /\ /\___ _ __ ___ ___ /_\ ___ ___(_)___| |_ __ _ _ __ | |_ / __\___ _ __ ___ + / /_/ / _ \| '_ ` _ \ / _ \ //_\\/ __/ __| / __| __/ _` | '_ \| __| / / / _ \| '__/ _ \ +/ __ / (_) | | | | | | __/ / _ \__ \__ \ \__ \ || (_| | | | | |_ / /__| (_) | | | __/ +\/ /_/ \___/|_| |_| |_|\___| \_/ \_/___/___/_|___/\__\__,_|_| |_|\__| \____/\___/|_| \___| + +EOF +} +header_info +echo -e "Loading..." +APP="Home Assistant-Core" +var_disk="8" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + if [[ ! -d /srv/homeassistant ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + PY=$(ls /srv/homeassistant/lib/) + IP=$(hostname -I | awk '{print $1}') + UPD=$(whiptail --title "UPDATE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 4 \ + "1" "Update Core" ON \ + "2" "Install HACS" OFF \ + "3" "Install FileBrowser" OFF \ + "4" "Install/Update AppDaemon" OFF \ + 3>&1 1>&2 2>&3) + header_info + if [ "$UPD" == "1" ]; then + if (whiptail --defaultno --title "SELECT BRANCH" --yesno "Use Beta Branch?" 10 58); then + clear + header_info + echo -e "${GN}Updating to Version ${BETA}${CL}" + BR="--pre " + else + clear + header_info + echo -e "${GN}Updating to Version ${STABLE}${CL}" + BR="" + fi + if [[ "$PY" == "python3.9" ]]; then echo -e "⚠️ Python 3.9 is deprecated and will be removed in Home Assistant 2023.2"; fi + + msg_info "Stopping Home Assistant" + systemctl stop homeassistant + msg_ok "Stopped Home Assistant" + + msg_info "Updating Home Assistant" + source /srv/homeassistant/bin/activate + pip install ${BR}--upgrade homeassistant &>/dev/null + msg_ok "Updated Home Assistant" + + msg_info "Starting Home Assistant" + systemctl start homeassistant + sleep 2 + msg_ok "Started Home Assistant" + msg_ok "Update Successful" + echo -e "\n Go to http://${IP}:8123 \n" + exit + fi + if [ "$UPD" == "2" ]; then + msg_info "Installing Home Assistant Comunity Store (HACS)" + apt update &>/dev/null + apt install unzip &>/dev/null + cd .homeassistant + bash <(curl -fsSL https://get.hacs.xyz) &>/dev/null + msg_ok "Installed Home Assistant Comunity Store (HACS)" + echo -e "\n Reboot Home Assistant and clear browser cache then Add HACS integration.\n" + exit + fi + if [ "$UPD" == "3" ]; then + msg_info "Installing FileBrowser" + curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash &>/dev/null + filebrowser config init -a '0.0.0.0' &>/dev/null + filebrowser config set -a '0.0.0.0' &>/dev/null + filebrowser users add admin changeme --perm.admin &>/dev/null + msg_ok "Installed FileBrowser" + + msg_info "Creating Service" + service_path="/etc/systemd/system/filebrowser.service" + echo "[Unit] +Description=Filebrowser +After=network-online.target +[Service] +User=root +WorkingDirectory=/root/ +ExecStart=/usr/local/bin/filebrowser -r /root/.homeassistant +[Install] +WantedBy=default.target" >$service_path + + systemctl enable --now filebrowser.service &>/dev/null + msg_ok "Created Service" + + msg_ok "Completed Successfully!\n" + echo -e "FileBrowser should be reachable by going to the following URL. + ${BL}http://$IP:8080${CL} admin|changeme\n" + exit + fi + if [ "$UPD" == "4" ]; then + clear + header_info + if [[ ! -d /srv/appdaemon ]]; then + msg_info "Installing AppDaemon" + mkdir /srv/appdaemon + cd /srv/appdaemon + python3 -m venv . + source bin/activate + pip install appdaemon &>/dev/null + mkdir -p /root/.homeassistant/appdaemon/apps + cat >/root/.homeassistant/appdaemon/appdaemon.yaml < + token: +http: + url: http://127.0.0.1:5050 +admin: +api: +EOF + msg_ok "Installed AppDaemon" + + msg_info "Creating Service" + cat >/etc/systemd/system/appdaemon.service </dev/null + msg_ok "Created Service" + + msg_ok "Completed Successfully!\n" + echo -e "AppDaemon should be reachable by going to the following URL. + ${BL}http://$IP:5050${CL}\n" + exit + else + msg_info "Upgrading AppDaemon" + msg_info "Stopping AppDaemon" + systemctl stop appdaemon + msg_ok "Stopped AppDaemon" + + msg_info "Updating AppDaemon" + source /srv/appdaemon/bin/activate + pip install --upgrade appdaemon &>/dev/null + msg_ok "Updated AppDaemon" + + msg_info "Starting AppDaemon" + systemctl start appdaemon + sleep 2 + msg_ok "Started AppDaemon" + msg_ok "Update Successful" + echo -e "\n Go to http://${IP}:5050 \n" + exit + fi + fi +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8123${CL}" diff --git a/ct/homeassistant-v5.sh b/ct/homeassistant-v5.sh deleted file mode 100644 index 391f8080..00000000 --- a/ct/homeassistant-v5.sh +++ /dev/null @@ -1,520 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ __ ___ _ __ __ - / / / /___v5____ ___ ___ / | __________(_)____/ /_____ _____ / /_ - / /_/ / __ \/ __ __ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ / __ \/ __/ - / __ / /_/ / / / / / / __/ / ___ |(__ |__ ) (__ ) /_/ /_/ / / / / /_ -/_/ /_/\____/_/ /_/ /_/\___/ /_/ |_/____/____/_/____/\__/\__,_/_/ /_/\__/ - -EOF -} -header_info -echo -e "Loading..." -APP="Home Assistant" -var_disk="16" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Fuse Overlayfs (ZFS): ${BGN}No${CL}" - FUSE="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "FUSE OVERLAYFS" --yesno "(ZFS) Enable Fuse Overlayfs?" 10 58); then - FUSE="yes" -else - FUSE="no" -fi - echo -e "${DGN}Enable Fuse Overlayfs (ZFS): ${BGN}$FUSE${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { - UPD=$(whiptail --title "UPDATE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 4 \ - "1" "Update ALL Containers" ON \ - "2" "Remove ALL Unused Images" OFF \ - "3" "Install HACS" OFF \ - "4" "Install FileBrowser" OFF \ - 3>&1 1>&2 2>&3) -header_info -if [ "$UPD" == "1" ]; then -msg_info "Updating All Containers" -CONTAINER_LIST="${1:-$(docker ps -q)}" -for container in ${CONTAINER_LIST}; do - CONTAINER_IMAGE="$(docker inspect --format "{{.Config.Image}}" --type container ${container})" - RUNNING_IMAGE="$(docker inspect --format "{{.Image}}" --type container "${container}")" - docker pull "${CONTAINER_IMAGE}" - LATEST_IMAGE="$(docker inspect --format "{{.Id}}" --type image "${CONTAINER_IMAGE}")" - if [[ "${RUNNING_IMAGE}" != "${LATEST_IMAGE}" ]]; then - echo "Updating ${container} image ${CONTAINER_IMAGE}" - DOCKER_COMMAND="$(runlike "${container}")" - docker rm --force "${container}" - eval ${DOCKER_COMMAND} - fi -done -msg_ok "Updated All Containers" -exit -fi -if [ "$UPD" == "2" ]; then -msg_info "Removing ALL Unused Images" -docker image prune -af -msg_ok "Removed ALL Unused Images" -exit -fi -if [ "$UPD" == "3" ]; then -msg_info "Installing Home Assistant Comunity Store (HACS)" -apt update &>/dev/null -apt install unzip &>/dev/null -cd /var/lib/docker/volumes/hass_config/_data -bash <(curl -fsSL https://get.hacs.xyz) &>/dev/null -msg_ok "Installed Home Assistant Comunity Store (HACS)" -echo -e "\n Reboot Home Assistant and clear browser cache then Add HACS integration.\n" -exit -fi -if [ "$UPD" == "4" ]; then -IP=$(hostname -I | awk '{print $1}') -msg_info "Installing FileBrowser" -curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash &>/dev/null -filebrowser config init -a '0.0.0.0' &>/dev/null -filebrowser config set -a '0.0.0.0' &>/dev/null -filebrowser users add admin changeme --perm.admin &>/dev/null -msg_ok "Installed FileBrowser" - -msg_info "Creating Service" -service_path="/etc/systemd/system/filebrowser.service" -echo "[Unit] -Description=Filebrowser -After=network-online.target -[Service] -User=root -WorkingDirectory=/root/ -ExecStart=/usr/local/bin/filebrowser -r / -[Install] -WantedBy=default.target" >$service_path - -systemctl enable --now filebrowser.service &>/dev/null -msg_ok "Created Service" - -msg_ok "Completed Successfully!\n" -echo -e "FileBrowser should be reachable by going to the following URL. - ${BL}http://$IP:8080${CL} admin|changeme\n" -exit -fi -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /var/lib/docker/volumes/hass_config/_data - ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$FUSE" == "yes" ]; then -FEATURES="fuse=1,keyctl=1,nesting=1" -else -FEATURES="keyctl=1,nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export ST=$FUSE -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$CT_TYPE" == "0" ]; then -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: c 188:* rwm -lxc.cgroup2.devices.allow: c 189:* rwm -lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir -lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file -EOF -fi -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8123${CL} -Portainer should be reachable by going to the following URL. - ${BL}http://${IP}:9000${CL}\n" diff --git a/ct/homeassistant.sh b/ct/homeassistant.sh new file mode 100644 index 00000000..1bb58440 --- /dev/null +++ b/ct/homeassistant.sh @@ -0,0 +1,138 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + __ __ ___ _ __ __ + / / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____ / /_ + / /_/ / __ \/ __ __ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ / __ \/ __/ + / __ / /_/ / / / / / / __/ / ___ |(__ |__ ) (__ ) /_/ /_/ / / / / /_ +/_/ /_/\____/_/ /_/ /_/\___/ /_/ |_/____/____/_/____/\__/\__,_/_/ /_/\__/ + +EOF +} +header_info +echo -e "Loading..." +APP="Home Assistant" +var_disk="16" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + if [[ ! -d /var/lib/docker/volumes/hass_config/_data ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + UPD=$(whiptail --title "UPDATE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 4 \ + "1" "Update ALL Containers" ON \ + "2" "Remove ALL Unused Images" OFF \ + "3" "Install HACS" OFF \ + "4" "Install FileBrowser" OFF \ + 3>&1 1>&2 2>&3) + header_info + if [ "$UPD" == "1" ]; then + msg_info "Updating All Containers" + CONTAINER_LIST="${1:-$(docker ps -q)}" + for container in ${CONTAINER_LIST}; do + CONTAINER_IMAGE="$(docker inspect --format "{{.Config.Image}}" --type container ${container})" + RUNNING_IMAGE="$(docker inspect --format "{{.Image}}" --type container "${container}")" + docker pull "${CONTAINER_IMAGE}" + LATEST_IMAGE="$(docker inspect --format "{{.Id}}" --type image "${CONTAINER_IMAGE}")" + if [[ "${RUNNING_IMAGE}" != "${LATEST_IMAGE}" ]]; then + echo "Updating ${container} image ${CONTAINER_IMAGE}" + DOCKER_COMMAND="$(runlike "${container}")" + docker rm --force "${container}" + eval ${DOCKER_COMMAND} + fi + done + msg_ok "Updated All Containers" + exit + fi + if [ "$UPD" == "2" ]; then + msg_info "Removing ALL Unused Images" + docker image prune -af + msg_ok "Removed ALL Unused Images" + exit + fi + if [ "$UPD" == "3" ]; then + msg_info "Installing Home Assistant Comunity Store (HACS)" + apt update &>/dev/null + apt install unzip &>/dev/null + cd /var/lib/docker/volumes/hass_config/_data + bash <(curl -fsSL https://get.hacs.xyz) &>/dev/null + msg_ok "Installed Home Assistant Comunity Store (HACS)" + echo -e "\n Reboot Home Assistant and clear browser cache then Add HACS integration.\n" + exit + fi + if [ "$UPD" == "4" ]; then + IP=$(hostname -I | awk '{print $1}') + msg_info "Installing FileBrowser" + curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash &>/dev/null + filebrowser config init -a '0.0.0.0' &>/dev/null + filebrowser config set -a '0.0.0.0' &>/dev/null + filebrowser users add admin changeme --perm.admin &>/dev/null + msg_ok "Installed FileBrowser" + + msg_info "Creating Service" + service_path="/etc/systemd/system/filebrowser.service" + echo "[Unit] +Description=Filebrowser +After=network-online.target +[Service] +User=root +WorkingDirectory=/root/ +ExecStart=/usr/local/bin/filebrowser -r / +[Install] +WantedBy=default.target" >$service_path + + systemctl enable --now filebrowser.service &>/dev/null + msg_ok "Created Service" + + msg_ok "Completed Successfully!\n" + echo -e "FileBrowser should be reachable by going to the following URL. + ${BL}http://$IP:8080${CL} admin|changeme\n" + exit + fi +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8123${CL} +Portainer should be reachable by going to the following URL. + ${BL}http://${IP}:9000${CL}\n" diff --git a/ct/homebridge-v5.sh b/ct/homebridge-v5.sh deleted file mode 100644 index 955813c7..00000000 --- a/ct/homebridge-v5.sh +++ /dev/null @@ -1,427 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ ______ __ _____________ ____ ________ ____________ - / / / / __ \/ |/ / ____/ __ )/ __ \/ _/ __ \/ ____/ ____/ - / /_/ / / / / /|_/ / __/ / __ / /_/ // // / / / / __/ __/ - / __ / /_/ / / / / /___/ /_/ / _, _// // /_/ / /_/ / /___ -/_/ /_/\____/_/v5/_/_____/_____/_/ |_/___/_____/\____/_____/ - -EOF -} -header_info -echo -e "Loading..." -APP="Homebridge" -var_disk="4" -var_cpu="1" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/systemd/system/homebridge.service ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8581${CL} \n" diff --git a/ct/homebridge.sh b/ct/homebridge.sh new file mode 100644 index 00000000..ebc25192 --- /dev/null +++ b/ct/homebridge.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ ______ __ _____________ ____ ________ ____________ + / / / / __ \/ |/ / ____/ __ )/ __ \/ _/ __ \/ ____/ ____/ + / /_/ / / / / /|_/ / __/ / __ / /_/ // // / / / / __/ __/ + / __ / /_/ / / / / /___/ /_/ / _, _// // /_/ / /_/ / /___ +/_/ /_/\____/_/ /_/_____/_____/_/ |_/___/_____/\____/_____/ + +EOF +} +header_info +echo -e "Loading..." +APP="Homebridge" +var_disk="4" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8581${CL} \n" diff --git a/ct/homepage-v5.sh b/ct/homepage-v5.sh deleted file mode 100644 index cc799cb4..00000000 --- a/ct/homepage-v5.sh +++ /dev/null @@ -1,433 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ __ - / / / /___ ____ ___ ___ ____ ____ _____ ____ - / /_/ / __ \/ __ `__ \/ _ \/ __ \/ __ `/ __ `/ _ \ - / __ / /_/ / / / / / / __/ /_/ / /_/ / /_/ / __/ -/_/ /_/\____/_/ /_/ /_/\___/ .___/\__,_/\__, /\___/ - /_/ v5 /____/ -EOF -} -header_info -echo -e "Loading..." -APP="Homepage" -var_disk="3" -var_cpu="2" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP}" -if ! command -v pnpm >/dev/null 2>&1; then - npm install -g pnpm &>/dev/null -fi -cd /opt/homepage -systemctl stop homepage -git pull --force &>/dev/null -pnpm install &>/dev/null -pnpm build &>/dev/null -systemctl start homepage -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/systemd/system/homepage.service ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} Setup should be reachable by going to the following URL. - ${BL}http://${IP}:3000${CL} \n" diff --git a/ct/homepage.sh b/ct/homepage.sh new file mode 100644 index 00000000..90538100 --- /dev/null +++ b/ct/homepage.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ __ + / / / /___ ____ ___ ___ ____ ____ _____ ____ + / /_/ / __ \/ __ `__ \/ _ \/ __ \/ __ `/ __ `/ _ \ + / __ / /_/ / / / / / / __/ /_/ / /_/ / /_/ / __/ +/_/ /_/\____/_/ /_/ /_/\___/ .___/\__,_/\__, /\___/ + /_/ /____/ +EOF +} +header_info +echo -e "Loading..." +APP="Homepage" +var_disk="3" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/homepage ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP}" +if ! command -v pnpm >/dev/null 2>&1; then + npm install -g pnpm &>/dev/null +fi +cd /opt/homepage +systemctl stop homepage +git pull --force &>/dev/null +pnpm install &>/dev/null +pnpm build &>/dev/null +systemctl start homepage +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} Setup should be reachable by going to the following URL. + ${BL}http://${IP}:3000${CL} \n" diff --git a/ct/homer-v5.sh b/ct/homer-v5.sh deleted file mode 100644 index c99f3a70..00000000 --- a/ct/homer-v5.sh +++ /dev/null @@ -1,450 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ __ - / / / /___ ____ ___v5___ _____ - / /_/ / __ \/ __ `__ \/ _ \/ ___/ - / __ / /_/ / / / / / / __/ / -/_/ /_/\____/_/ /_/ /_/\___/_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Homer" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Stopping ${APP}" -systemctl stop homer -msg_ok "Stopped ${APP}" - -msg_info "Backing up config.yml" -cd ~ -cp -R /opt/homer/assets/config.yml config.yml -msg_ok "Backed up config.yml" - -msg_info "Updating ${APP}" -rm -rf /opt/homer/* -cd /opt/homer -wget -q https://github.com/bastienwirtz/homer/releases/latest/download/homer.zip -unzip homer.zip &>/dev/null -msg_ok "Updated ${APP}" -msg_info "Restoring conf.yml" -cd ~ -cp -R config.yml /opt/homer/assets -msg_ok "Restored conf.yml" - -msg_info "Cleaning" -rm -rf config.yml /opt/homer/homer.zip -msg_ok "Cleaned" - -msg_info "Starting ${APP}" -systemctl start homer -msg_ok "Started ${APP}" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/homer ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8010${CL} \n" diff --git a/ct/homer.sh b/ct/homer.sh new file mode 100644 index 00000000..13d2b64b --- /dev/null +++ b/ct/homer.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ __ + / / / /___ ____ ___ ___ _____ + / /_/ / __ \/ __ `__ \/ _ \/ ___/ + / __ / /_/ / / / / / / __/ / +/_/ /_/\____/_/ /_/ /_/\___/_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Homer" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/homer ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Stopping ${APP}" +systemctl stop homer +msg_ok "Stopped ${APP}" + +msg_info "Backing up config.yml" +cd ~ +cp -R /opt/homer/assets/config.yml config.yml +msg_ok "Backed up config.yml" + +msg_info "Updating ${APP}" +rm -rf /opt/homer/* +cd /opt/homer +wget -q https://github.com/bastienwirtz/homer/releases/latest/download/homer.zip +unzip homer.zip &>/dev/null +msg_ok "Updated ${APP}" +msg_info "Restoring conf.yml" +cd ~ +cp -R config.yml /opt/homer/assets +msg_ok "Restored conf.yml" + +msg_info "Cleaning" +rm -rf config.yml /opt/homer/homer.zip +msg_ok "Cleaned" + +msg_info "Starting ${APP}" +systemctl start homer +msg_ok "Started ${APP}" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8010${CL} \n" diff --git a/ct/hyperion-v5.sh b/ct/hyperion-v5.sh deleted file mode 100644 index 13e1168c..00000000 --- a/ct/hyperion-v5.sh +++ /dev/null @@ -1,441 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - __ __ _ - / / / /_ ______v5___ _____(_)___ ____ - / /_/ / / / / __ \/ _ \/ ___/ / __ \/ __ \ - / __ / /_/ / /_/ / __/ / / / /_/ / / / / -/_/ /_/\__, / .___/\___/_/ /_/\____/_/ /_/ - /____/_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Hyperion" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" - CT_TYPE="0" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get install -y hyperion &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/apt/sources.list.d/hyperion.list ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -if [ "$CT_TYPE" == "0" ]; then - LXC_CONFIG=/etc/pve/lxc/${CTID}.conf - cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -lxc.cgroup2.devices.allow: c 188:* rwm -lxc.cgroup2.devices.allow: c 189:* rwm -lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir -lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file -EOF -fi -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8090${CL} \n" diff --git a/ct/hyperion.sh b/ct/hyperion.sh new file mode 100644 index 00000000..64b0fa33 --- /dev/null +++ b/ct/hyperion.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ __ _ + / / / /_ ______ ___ _____(_)___ ____ + / /_/ / / / / __ \/ _ \/ ___/ / __ \/ __ \ + / __ / /_/ / /_/ / __/ / / / /_/ / / / / +/_/ /_/\__, / .___/\___/_/ /_/\____/_/ /_/ + /____/_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Hyperion" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/apt/sources.list.d/hyperion.list ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get install -y hyperion &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8090${CL} \n" diff --git a/ct/influxdb-v5.sh b/ct/influxdb-v5.sh deleted file mode 100644 index 3f1e42ed..00000000 --- a/ct/influxdb-v5.sh +++ /dev/null @@ -1,425 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ ______ ____ ____ - / _/_v5 / __/ /_ ___ __/ __ \/ __ ) - / // __ \/ /_/ / / / / |/_/ / / / __ | - _/ // / / / __/ / /_/ /> &1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/apt/sources.list.d/influxdb.list ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" diff --git a/ct/influxdb.sh b/ct/influxdb.sh new file mode 100644 index 00000000..44b3eddb --- /dev/null +++ b/ct/influxdb.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ____ ______ ____ ____ + / _/___ / __/ /_ ___ __/ __ \/ __ ) + / // __ \/ /_/ / / / / |/_/ / / / __ | + _/ // / / / __/ / /_/ /> /dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/iobroker-v5.sh b/ct/iobroker-v5.sh deleted file mode 100644 index 7e74a9f4..00000000 --- a/ct/iobroker-v5.sh +++ /dev/null @@ -1,427 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _ ____ __ - (_)___ / __ )_________ / /_____ _____ - / / __ \/ __ / ___/ __ \/ //_/ _ \/ ___/ - / / /_/ / /_/ / / / /_/ / ,< / __/ / -/_/\____/_____/_/ v5\____/_/|_|\___/_/ - -EOF -} -header_info -echo -e "Loading..." -APP="ioBroker" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/iobroker ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8081${CL} \n" diff --git a/ct/iobroker.sh b/ct/iobroker.sh new file mode 100644 index 00000000..31b5a552 --- /dev/null +++ b/ct/iobroker.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + _ ____ __ + (_)___ / __ )_________ / /_____ _____ + / / __ \/ __ / ___/ __ \/ //_/ _ \/ ___/ + / / /_/ / /_/ / / / /_/ / ,< / __/ / +/_/\____/_____/_/ \____/_/|_|\___/_/ + +EOF +} +header_info +echo -e "Loading..." +APP="ioBroker" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/iobroker ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8081${CL} \n" diff --git a/ct/jackett-v5.sh b/ct/jackett-v5.sh deleted file mode 100644 index 72a6a925..00000000 --- a/ct/jackett-v5.sh +++ /dev/null @@ -1,425 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - __ __ __ __ - / /___ ______/ /_____v5/ /_/ /_ - __ / / __ `/ ___/ //_/ _ \/ __/ __/ -/ /_/ / /_/ / /__/ ,< / __/ /_/ /_ -\____/\__,_/\___/_/|_|\___/\__/\__/ - -EOF -} -header_info -echo -e "Loading..." -APP="Jackett" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/systemd/system/jackett.service ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:9117${CL}\n" diff --git a/ct/jackett.sh b/ct/jackett.sh new file mode 100644 index 00000000..ec991c7d --- /dev/null +++ b/ct/jackett.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ __ __ __ + / /___ ______/ /_____ / /_/ /_ + __ / / __ `/ ___/ //_/ _ \/ __/ __/ +/ /_/ / /_/ / /__/ ,< / __/ /_/ /_ +\____/\__,_/\___/_/|_|\___/\__/\__/ + +EOF +} +header_info +echo -e "Loading..." +APP="Jackett" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/systemd/system/jackett.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:9117${CL}\n" diff --git a/ct/jellyfin-v5.sh b/ct/jellyfin-v5.sh deleted file mode 100644 index b043cf38..00000000 --- a/ct/jellyfin-v5.sh +++ /dev/null @@ -1,450 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ ____ _____ - / /__ / / /_v5__/ __(_)___ - __ / / _ \/ / / / / / /_/ / __ \ -/ /_/ / __/ / / /_/ / __/ / / / / -\____/\___/_/_/\__, /_/ /_/_/ /_/ - /____/ - -EOF -} -header_info -echo -e "Loading..." -APP="Jellyfin" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="ubuntu" -var_version="20.04" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}" - echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" - CT_TYPE="0" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if var_version=$(whiptail --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 4 \ - "18.04" "Bionic" OFF \ - "20.04" "Focal" ON \ - "22.04" "Jammy" OFF \ - "22.10" "Kinetic" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Ubuntu Version: ${BGN}$var_version${CL}" -else - exit-script -fi -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" OFF \ - "0" "Privileged" ON \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /usr/lib/jellyfin ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -if [ "$CT_TYPE" == "0" ]; then - LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: c 226:0 rwm -lxc.cgroup2.devices.allow: c 226:128 rwm -lxc.cgroup2.devices.allow: c 29:0 rwm -lxc.mount.entry: /dev/fb0 dev/fb0 none bind,optional,create=file -lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir -lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file -EOF -fi -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8096${CL}\n" diff --git a/ct/jellyfin.sh b/ct/jellyfin.sh new file mode 100644 index 00000000..c4bdef50 --- /dev/null +++ b/ct/jellyfin.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/ubuntu.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ ____ _____ + / /__ / / /_ __/ __(_)___ + __ / / _ \/ / / / / / /_/ / __ \ +/ /_/ / __/ / / /_/ / __/ / / / / +\____/\___/_/_/\__, /_/ /_/_/ /_/ + /____/ + +EOF +} +header_info +echo -e "Loading..." +APP="Jellyfin" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="ubuntu" +var_version="20.04" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="0" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /usr/lib/jellyfin ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8096${CL}\n" diff --git a/ct/k0s-v5.sh b/ct/k0s-v5.sh deleted file mode 100644 index cdf959f6..00000000 --- a/ct/k0s-v5.sh +++ /dev/null @@ -1,425 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ ____ __ __ __ __ - / /__/ __ \_____ / //_/_ __/ /_ ___v5_________ ___ / /____ _____ - / //_/ / / / ___/ / ,< / / / / __ \/ _ \/ ___/ __ \/ _ \/ __/ _ \/ ___/ - / ,< / /_/ (__ ) / /| / /_/ / /_/ / __/ / / / / / __/ /_/ __(__ ) -/_/|_|\____/____/ /_/ |_\__,_/_.___/\___/_/ /_/ /_/\___/\__/\___/____/ - -EOF -} -header_info -echo -e "Loading..." -APP="k0s" -var_disk="4" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/k0s/k0s.yaml ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" diff --git a/ct/k0s.sh b/ct/k0s.sh new file mode 100644 index 00000000..710dd461 --- /dev/null +++ b/ct/k0s.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ ____ __ __ __ __ + / /__/ __ \_____ / //_/_ __/ /_ ___ _________ ___ / /____ _____ + / //_/ / / / ___/ / ,< / / / / __ \/ _ \/ ___/ __ \/ _ \/ __/ _ \/ ___/ + / ,< / /_/ (__ ) / /| / /_/ / /_/ / __/ / / / / / __/ /_/ __(__ ) +/_/|_|\____/____/ /_/ |_\__,_/_.___/\___/_/ /_/ /_/\___/\__/\___/____/ + +EOF +} +header_info +echo -e "Loading..." +APP="k0s" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/k0s/k0s.yaml ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/kavita-v5.sh b/ct/kavita-v5.sh deleted file mode 100644 index 32c7b540..00000000 --- a/ct/kavita-v5.sh +++ /dev/null @@ -1,426 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ __ _ __ - / //_/___ __ v5__(_) /_____ _ - / ,< / __ `/ | / / / __/ __ `/ - / /| / /_/ /| |/ / / /_/ /_/ / -/_/ |_\__,_/ |___/_/\__/\__,_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Kavita" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating $APP LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated $APP LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/Kavita ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:5000${CL} \n" diff --git a/ct/kavita.sh b/ct/kavita.sh new file mode 100644 index 00000000..b80d4728 --- /dev/null +++ b/ct/kavita.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ __ _ __ + / //_/___ __ __(_) /_____ _ + / ,< / __ `/ | / / / __/ __ `/ + / /| / /_/ /| |/ / / /_/ /_/ / +/_/ |_\__,_/ |___/_/\__/\__,_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Kavita" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/Kavita ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:5000${CL} \n" diff --git a/ct/keycloak-v5.sh b/ct/keycloak-v5.sh deleted file mode 100644 index 7c2d8149..00000000 --- a/ct/keycloak-v5.sh +++ /dev/null @@ -1,428 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ __ __ __ - / //_/__v5__ _______/ /___ ____ _/ /__ - / ,< / _ \/ / / / ___/ / __ \/ __ / //_/ - / /| / __/ /_/ / /__/ / /_/ / /_/ / ,< -/_/ |_\___/\__, /\___/_/\____/\__,_/_/|_| - /____/ - -EOF -} -header_info -echo -e "Loading..." -APP="Keycloak" -var_disk="4" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/systemd/system/keycloak.service ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8080${CL} \n" diff --git a/ct/keycloak.sh b/ct/keycloak.sh new file mode 100644 index 00000000..98ae1938 --- /dev/null +++ b/ct/keycloak.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ __ __ __ + / //_/__ __ _______/ /___ ____ _/ /__ + / ,< / _ \/ / / / ___/ / __ \/ __ / //_/ + / /| / __/ /_/ / /__/ / /_/ / /_/ / ,< +/_/ |_\___/\__, /\___/_/\____/\__,_/_/|_| + /____/ + +EOF +} +header_info +echo -e "Loading..." +APP="Keycloak" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/systemd/system/keycloak.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8080${CL} \n" diff --git a/ct/lidarr-v5.sh b/ct/lidarr-v5.sh deleted file mode 100644 index 2fa8eab1..00000000 --- a/ct/lidarr-v5.sh +++ /dev/null @@ -1,426 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ _ __ - / / (_)___/ /___v5__________ - / / / / __ / __ `/ ___/ ___/ - / /___/ / /_/ / /_/ / / / / -/_____/_/\__,_/\__,_/_/ /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Lidarr" -var_disk="4" -var_cpu="2" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating $APP LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated $APP LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /var/lib/lidarr/ ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8686${CL} \n" diff --git a/ct/lidarr.sh b/ct/lidarr.sh new file mode 100644 index 00000000..c8cf9b26 --- /dev/null +++ b/ct/lidarr.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ _ __ + / / (_)___/ /___ __________ + / / / / __ / __ `/ ___/ ___/ + / /___/ / /_/ / /_/ / / / / +/_____/_/\__,_/\__,_/_/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Lidarr" +var_disk="4" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var/lib/lidarr/ ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8686${CL} \n" diff --git a/ct/magicmirror-v5.sh b/ct/magicmirror-v5.sh deleted file mode 100644 index 87f20b9a..00000000 --- a/ct/magicmirror-v5.sh +++ /dev/null @@ -1,429 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ ___ _ __ ____ - / |/ /___ _____ _(_)____/ |/ (_)_____________ _____ - / /|_/ / __ / __ / / ___/ /|_/ / / ___/ ___/ __ \/ ___/ - / / / / /_/ / /_/ / / /__/ / / / / / / / / /_/ / / -/_/ /_/\__,_/\__, /_/\___/_/ /_/_/_/ /_/ \____/_/ - /____/ v5 - -EOF -} -header_info -echo -e "Loading..." -APP="MagicMirror" -var_disk="3" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -cd /opt/magicmirror -git pull &>/dev/null -npm install --only=prod --omit=dev &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/magicmirror ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8080${CL} \n" diff --git a/ct/magicmirror.sh b/ct/magicmirror.sh new file mode 100644 index 00000000..408e1107 --- /dev/null +++ b/ct/magicmirror.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ ___ _ __ ____ + / |/ /___ _____ _(_)____/ |/ (_)_____________ _____ + / /|_/ / __ / __ / / ___/ /|_/ / / ___/ ___/ __ \/ ___/ + / / / / /_/ / /_/ / / /__/ / / / / / / / / /_/ / / +/_/ /_/\__,_/\__, /_/\___/_/ /_/_/_/ /_/ \____/_/ + /____/ + +EOF +} +header_info +echo -e "Loading..." +APP="MagicMirror" +var_disk="3" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/magicmirror ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +cd /opt/magicmirror +git pull &>/dev/null +npm install --only=prod --omit=dev &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8080${CL} \n" diff --git a/ct/mariadb-v5.sh b/ct/mariadb-v5.sh deleted file mode 100644 index 2bee684d..00000000 --- a/ct/mariadb-v5.sh +++ /dev/null @@ -1,425 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ ___ _ ____ ____ - / |/ /___ ______(_)___ _/ __ \/ __ ) - / /|_/ / __ / ___/ / __ / / / / __ | - / / / / /_/ / / / / /_/ / /_/ / /_/ / -/_/ /_/\__,_/_/v5/_/\__,_/_____/_____/ - -EOF -} -header_info -echo -e "Loading..." -APP="MariaDB" -var_disk="4" -var_cpu="1" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/apt/sources.list.d/mariadb.list ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" diff --git a/ct/mariadb.sh b/ct/mariadb.sh new file mode 100644 index 00000000..04b0ba93 --- /dev/null +++ b/ct/mariadb.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ ___ _ ____ ____ + / |/ /___ ______(_)___ _/ __ \/ __ ) + / /|_/ / __ / ___/ / __ / / / / __ | + / / / / /_/ / / / / /_/ / /_/ / /_/ / +/_/ /_/\__,_/_/ /_/\__,_/_____/_____/ + +EOF +} +header_info +echo -e "Loading..." +APP="MariaDB" +var_disk="4" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/apt/sources.list.d/mariadb.list ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/meshcentral-v5.sh b/ct/meshcentral-v5.sh deleted file mode 100644 index 0899b146..00000000 --- a/ct/meshcentral-v5.sh +++ /dev/null @@ -1,427 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ ___ __ ______ __ __ - / |/ /__ _____/ /_ / ____/__ ____ / /__________ _/ / - / /|_/ / _ \/ ___/ __ \/ / / _ \/ __ \/ __/ ___/ __ / / - / / / / __(__ ) / / / /___/ __/ / / / /_/ / / /_/ / / -/_/ /_/\___/____/_/ /_/\____/\___/_/ /_/\__/_/ v5\__,_/_/ - -EOF -} -header_info -echo -e "Loading..." -APP="MeshCentral" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/meshcentral ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}${CL} \n" diff --git a/ct/meshcentral.sh b/ct/meshcentral.sh new file mode 100644 index 00000000..7d544d0b --- /dev/null +++ b/ct/meshcentral.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ ___ __ ______ __ __ + / |/ /__ _____/ /_ / ____/__ ____ / /__________ _/ / + / /|_/ / _ \/ ___/ __ \/ / / _ \/ __ \/ __/ ___/ __ / / + / / / / __(__ ) / / / /___/ __/ / / / /_/ / / /_/ / / +/_/ /_/\___/____/_/ /_/\____/\___/_/ /_/\__/_/ \__,_/_/ + +EOF +} +header_info +echo -e "Loading..." +APP="MeshCentral" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/meshcentral ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}${CL} \n" diff --git a/ct/motioneye-v5.sh b/ct/motioneye-v5.sh deleted file mode 100644 index 245f2439..00000000 --- a/ct/motioneye-v5.sh +++ /dev/null @@ -1,426 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ ___ __ _ - / |/ /___ / /_(_)___ ____v5___ __ _____ - / /|_/ / __ \/ __/ / __ \/ __ \/ _ \/ / / / _ \ - / / / / /_/ / /_/ / /_/ / / / / __/ /_/ / __/ -/_/ /_/\____/\__/_/\____/_/ /_/\___/\__, /\___/ - /____/ -EOF -} -header_info -echo -e "Loading..." -APP="Motioneye" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -pip install motioneye --upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/systemd/system/motioneye.service ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8765${CL} \n" diff --git a/ct/motioneye.sh b/ct/motioneye.sh new file mode 100644 index 00000000..6dc03205 --- /dev/null +++ b/ct/motioneye.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ ___ __ _ + / |/ /___ / /_(_)___ ____ ___ __ _____ + / /|_/ / __ \/ __/ / __ \/ __ \/ _ \/ / / / _ \ + / / / / /_/ / /_/ / /_/ / / / / __/ /_/ / __/ +/_/ /_/\____/\__/_/\____/_/ /_/\___/\__, /\___/ + /____/ +EOF +} +header_info +echo -e "Loading..." +APP="Motioneye" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/systemd/system/motioneye.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +pip install motioneye --upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8765${CL} \n" diff --git a/ct/mqtt-v5.sh b/ct/mqtt-v5.sh deleted file mode 100644 index 46cfed5f..00000000 --- a/ct/mqtt-v5.sh +++ /dev/null @@ -1,424 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - __ ___ ____ _ ____________ - / |/ /___v5_____/ __ \__ __(_)_ __/_ __/___ - / /|_/ / __ \/ ___/ / / / / / / / / / / / / __ \ - / / / / /_/ (__ ) /_/ / /_/ / / / / / / / /_/ / -/_/ /_/\____/____/\___\_\__,_/_/ /_/ /_/ \____/ - -EOF -} -header_info -echo -e "Loading..." -APP="MQTT" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/apt/sources.list.d/mosquitto-bullseye.list ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" diff --git a/ct/mqtt.sh b/ct/mqtt.sh new file mode 100644 index 00000000..d0ccf349 --- /dev/null +++ b/ct/mqtt.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ ___ ____ _ ____________ + / |/ /___ _____/ __ \__ __(_)_ __/_ __/___ + / /|_/ / __ \/ ___/ / / / / / / / / / / / / __ \ + / / / / /_/ (__ ) /_/ / /_/ / / / / / / / /_/ / +/_/ /_/\____/____/\___\_\__,_/_/ /_/ /_/ \____/ + +EOF +} +header_info +echo -e "Loading..." +APP="MQTT" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/apt/sources.list.d/mosquitto-bullseye.list ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/n8n-v5.sh b/ct/n8n-v5.sh deleted file mode 100644 index 13184630..00000000 --- a/ct/n8n-v5.sh +++ /dev/null @@ -1,427 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ___ - / _ \ - _ __ | (_) |_v5_ - | _ \ > _ <| _ \ - | | | | (_) | | | | - |_| |_|\___/|_| |_| - -EOF -} -header_info -echo -e "Loading..." -APP="n8n" -var_disk="3" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -npm update -g n8n &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/systemd/system/n8n.service ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:5678${CL} \n" diff --git a/ct/n8n.sh b/ct/n8n.sh new file mode 100644 index 00000000..944d0fe3 --- /dev/null +++ b/ct/n8n.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ___ + / _ \ + _ __ | (_) |____ + | _ \ > _ <| _ \ + | | | | (_) | | | | + |_| |_|\___/|_| |_| + +EOF +} +header_info +echo -e "Loading..." +APP="n8n" +var_disk="3" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/systemd/system/n8n.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +npm update -g n8n &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:5678${CL} \n" diff --git a/ct/navidrome-v5.sh b/ct/navidrome-v5.sh deleted file mode 100644 index c5d4eeb2..00000000 --- a/ct/navidrome-v5.sh +++ /dev/null @@ -1,437 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _ __ _ __ - / | / /___ __ v5__(_)___/ /________ ____ ___ ___ - / |/ / __ / | / / / __ / ___/ __ \/ __ __ \/ _ \ - / /| / /_/ /| |/ / / /_/ / / / /_/ / / / / / / __/ -/_/ |_/\__,_/ |___/_/\__,_/_/ \____/_/ /_/ /_/\___/ - -EOF -} -header_info -echo -e "Loading..." -APP="Navidrome" -var_disk="4" -var_cpu="2" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -RELEASE=$(curl -s https://api.github.com/repos/navidrome/navidrome/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') -msg_info "Stopping ${APP}" -systemctl stop navidrome.service -msg_ok "Stopped Navidrome" - -msg_info "Updating to v${RELEASE}" -wget https://github.com/navidrome/navidrome/releases/download/v${RELEASE}/navidrome_${RELEASE}_Linux_x86_64.tar.gz -O Navidrome.tar.gz &>/dev/null -tar -xvzf Navidrome.tar.gz -C /opt/navidrome/ &>/dev/null -msg_ok "Updated ${APP}" -rm Navidrome.tar.gz - -msg_info "${GN} Starting ${APP}" -systemctl start navidrome.service -msg_ok "Started ${APP}" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/navidrome ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:4533${CL} \n" diff --git a/ct/navidrome.sh b/ct/navidrome.sh new file mode 100644 index 00000000..2aef956b --- /dev/null +++ b/ct/navidrome.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + _ __ _ __ + / | / /___ __ __(_)___/ /________ ____ ___ ___ + / |/ / __ / | / / / __ / ___/ __ \/ __ __ \/ _ \ + / /| / /_/ /| |/ / / /_/ / / / /_/ / / / / / / __/ +/_/ |_/\__,_/ |___/_/\__,_/_/ \____/_/ /_/ /_/\___/ + +EOF +} +header_info +echo -e "Loading..." +APP="Navidrome" +var_disk="4" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/navidrome ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +RELEASE=$(curl -s https://api.github.com/repos/navidrome/navidrome/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +msg_info "Stopping ${APP}" +systemctl stop navidrome.service +msg_ok "Stopped Navidrome" + +msg_info "Updating to v${RELEASE}" +wget https://github.com/navidrome/navidrome/releases/download/v${RELEASE}/navidrome_${RELEASE}_Linux_x86_64.tar.gz -O Navidrome.tar.gz &>/dev/null +tar -xvzf Navidrome.tar.gz -C /opt/navidrome/ &>/dev/null +msg_ok "Updated ${APP}" +rm Navidrome.tar.gz + +msg_info "${GN} Starting ${APP}" +systemctl start navidrome.service +msg_ok "Started ${APP}" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:4533${CL} \n" diff --git a/ct/nextcloudpi-v5.sh b/ct/nextcloudpi-v5.sh deleted file mode 100644 index 79ad1cff..00000000 --- a/ct/nextcloudpi-v5.sh +++ /dev/null @@ -1,427 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _ __ __ ________ ______ _ - / | / /__ _ __/ /_/ ____/ /___ __v5______/ / __ \(_) - / |/ / _ \| |/_/ __/ / / / __ \/ / / / __ / /_/ / / - / /| / __/> &1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /lib/systemd/system/nextcloud-domain.service ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} Setup should be reachable by going to the following URL. - ${BL}https://${IP}/${CL} \n" diff --git a/ct/nextcloudpi.sh b/ct/nextcloudpi.sh new file mode 100644 index 00000000..6f887d8c --- /dev/null +++ b/ct/nextcloudpi.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + _ __ __ ________ ______ _ + / | / /__ _ __/ /_/ ____/ /___ __ ______/ / __ \(_) + / |/ / _ \| |/_/ __/ / / / __ \/ / / / __ / /_/ / / + / /| / __/> /dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} Setup should be reachable by going to the following URL. + ${BL}https://${IP}/${CL} \n" diff --git a/ct/nginxproxymanager-v5.sh b/ct/nginxproxymanager-v5.sh deleted file mode 100644 index a12eb9dd..00000000 --- a/ct/nginxproxymanager-v5.sh +++ /dev/null @@ -1,535 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _ __ _ ____ __ ___ - / | / /___ _(_)___ _ __ / __ \_________v5_ ____ __ / |/ /___ _____ ____ _____ ____ _____ - / |/ / __ / / __ \| |/_/ / /_/ / ___/ __ \| |/_/ / / / / /|_/ / __ / __ \/ __ / __ / _ \/ ___/ - / /| / /_/ / / / / /> < / ____/ / / /_/ /> &1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -RELEASE=$(curl -s https://api.github.com/repos/NginxProxyManager/nginx-proxy-manager/releases/latest | - grep "tag_name" | - awk '{print substr($2, 3, length($2)-4) }') -msg_info "Stopping Services" -systemctl stop openresty -systemctl stop npm -msg_ok "Stopped Services" - -msg_info "Cleaning Old Files" - rm -rf /app \ - /var/www/html \ - /etc/nginx \ - /var/log/nginx \ - /var/lib/nginx \ - /var/cache/nginx &>/dev/null -msg_ok "Cleaned Old Files" - -msg_info "Downloading NPM v${RELEASE}" -wget -q https://codeload.github.com/NginxProxyManager/nginx-proxy-manager/tar.gz/v${RELEASE} -O - | tar -xz &>/dev/null -cd nginx-proxy-manager-${RELEASE} -msg_ok "Downloaded NPM v${RELEASE}" - -msg_info "Setting up Enviroment" -ln -sf /usr/bin/python3 /usr/bin/python -ln -sf /usr/bin/certbot /opt/certbot/bin/certbot -ln -sf /usr/local/openresty/nginx/sbin/nginx /usr/sbin/nginx -ln -sf /usr/local/openresty/nginx/ /etc/nginx -sed -i "s+0.0.0+${RELEASE}+g" backend/package.json -sed -i "s+0.0.0+${RELEASE}+g" frontend/package.json -sed -i 's+^daemon+#daemon+g' docker/rootfs/etc/nginx/nginx.conf -NGINX_CONFS=$(find "$(pwd)" -type f -name "*.conf") -for NGINX_CONF in $NGINX_CONFS; do - sed -i 's+include conf.d+include /etc/nginx/conf.d+g' "$NGINX_CONF" -done -mkdir -p /var/www/html /etc/nginx/logs -cp -r docker/rootfs/var/www/html/* /var/www/html/ -cp -r docker/rootfs/etc/nginx/* /etc/nginx/ -cp docker/rootfs/etc/letsencrypt.ini /etc/letsencrypt.ini -cp docker/rootfs/etc/logrotate.d/nginx-proxy-manager /etc/logrotate.d/nginx-proxy-manager -ln -sf /etc/nginx/nginx.conf /etc/nginx/conf/nginx.conf -rm -f /etc/nginx/conf.d/dev.conf -mkdir -p /tmp/nginx/body \ - /run/nginx \ - /data/nginx \ - /data/custom_ssl \ - /data/logs \ - /data/access \ - /data/nginx/default_host \ - /data/nginx/default_www \ - /data/nginx/proxy_host \ - /data/nginx/redirection_host \ - /data/nginx/stream \ - /data/nginx/dead_host \ - /data/nginx/temp \ - /var/lib/nginx/cache/public \ - /var/lib/nginx/cache/private \ - /var/cache/nginx/proxy_temp -chmod -R 777 /var/cache/nginx -chown root /tmp/nginx -echo resolver "$(awk 'BEGIN{ORS=" "} $1=="nameserver" {print ($2 ~ ":")? "["$2"]": $2}' /etc/resolv.conf);" >/etc/nginx/conf.d/include/resolvers.conf -if [ ! -f /data/nginx/dummycert.pem ] || [ ! -f /data/nginx/dummykey.pem ]; then - echo -e "${CHECKMARK} \e[1;92m Generating dummy SSL Certificate... \e[0m" - openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 -subj "/O=Nginx Proxy Manager/OU=Dummy Certificate/CN=localhost" -keyout /data/nginx/dummykey.pem -out /data/nginx/dummycert.pem &>/dev/null -fi -mkdir -p /app/global /app/frontend/images -cp -r backend/* /app -cp -r global/* /app/global -msg_ok "Setup Enviroment" - -msg_info "Building Frontend" -cd ./frontend -export NODE_ENV=development -yarn install --network-timeout=30000 &>/dev/null -yarn build &>/dev/null -cp -r dist/* /app/frontend -cp -r app-images/* /app/frontend/images -msg_ok "Built Frontend" - - -msg_info "Initializing Backend" -rm -rf /app/config/default.json &>/dev/null -if [ ! -f /app/config/production.json ]; then - cat <<'EOF' >/app/config/production.json -{ - "database": { - "engine": "knex-native", - "knex": { - "client": "sqlite3", - "connection": { - "filename": "/data/database.sqlite" - } - } - } -} -EOF -fi -cd /app -export NODE_ENV=development -yarn install --network-timeout=30000 &>/dev/null -msg_ok "Initialized Backend" - -msg_info "Starting Services" -systemctl enable npm &>/dev/null -systemctl start openresty -systemctl start npm -msg_ok "Started Services" - -msg_info "Cleaning up" -rm -rf ~/nginx-proxy-manager-* -msg_ok "Cleaned" - -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /lib/systemd/system/npm.service ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:81${CL} \n" diff --git a/ct/nginxproxymanager.sh b/ct/nginxproxymanager.sh new file mode 100644 index 00000000..215e8e24 --- /dev/null +++ b/ct/nginxproxymanager.sh @@ -0,0 +1,180 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + _ __ _ ____ __ ___ + / | / /___ _(_)___ _ __ / __ \_________ __ ____ __ / |/ /___ _____ ____ _____ ____ _____ + / |/ / __ / / __ \| |/_/ / /_/ / ___/ __ \| |/_/ / / / / /|_/ / __ / __ \/ __ / __ / _ \/ ___/ + / /| / /_/ / / / / /> < / ____/ / / /_/ /> /dev/null + msg_ok "Cleaned Old Files" + + msg_info "Downloading NPM v${RELEASE}" + wget -q https://codeload.github.com/NginxProxyManager/nginx-proxy-manager/tar.gz/v${RELEASE} -O - | tar -xz &>/dev/null + cd nginx-proxy-manager-${RELEASE} + msg_ok "Downloaded NPM v${RELEASE}" + + msg_info "Setting up Enviroment" + ln -sf /usr/bin/python3 /usr/bin/python + ln -sf /usr/bin/certbot /opt/certbot/bin/certbot + ln -sf /usr/local/openresty/nginx/sbin/nginx /usr/sbin/nginx + ln -sf /usr/local/openresty/nginx/ /etc/nginx + sed -i "s+0.0.0+${RELEASE}+g" backend/package.json + sed -i "s+0.0.0+${RELEASE}+g" frontend/package.json + sed -i 's+^daemon+#daemon+g' docker/rootfs/etc/nginx/nginx.conf + NGINX_CONFS=$(find "$(pwd)" -type f -name "*.conf") + for NGINX_CONF in $NGINX_CONFS; do + sed -i 's+include conf.d+include /etc/nginx/conf.d+g' "$NGINX_CONF" + done + mkdir -p /var/www/html /etc/nginx/logs + cp -r docker/rootfs/var/www/html/* /var/www/html/ + cp -r docker/rootfs/etc/nginx/* /etc/nginx/ + cp docker/rootfs/etc/letsencrypt.ini /etc/letsencrypt.ini + cp docker/rootfs/etc/logrotate.d/nginx-proxy-manager /etc/logrotate.d/nginx-proxy-manager + ln -sf /etc/nginx/nginx.conf /etc/nginx/conf/nginx.conf + rm -f /etc/nginx/conf.d/dev.conf + mkdir -p /tmp/nginx/body \ + /run/nginx \ + /data/nginx \ + /data/custom_ssl \ + /data/logs \ + /data/access \ + /data/nginx/default_host \ + /data/nginx/default_www \ + /data/nginx/proxy_host \ + /data/nginx/redirection_host \ + /data/nginx/stream \ + /data/nginx/dead_host \ + /data/nginx/temp \ + /var/lib/nginx/cache/public \ + /var/lib/nginx/cache/private \ + /var/cache/nginx/proxy_temp + chmod -R 777 /var/cache/nginx + chown root /tmp/nginx + echo resolver "$(awk 'BEGIN{ORS=" "} $1=="nameserver" {print ($2 ~ ":")? "["$2"]": $2}' /etc/resolv.conf);" >/etc/nginx/conf.d/include/resolvers.conf + if [ ! -f /data/nginx/dummycert.pem ] || [ ! -f /data/nginx/dummykey.pem ]; then + echo -e "${CHECKMARK} \e[1;92m Generating dummy SSL Certificate... \e[0m" + openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 -subj "/O=Nginx Proxy Manager/OU=Dummy Certificate/CN=localhost" -keyout /data/nginx/dummykey.pem -out /data/nginx/dummycert.pem &>/dev/null + fi + mkdir -p /app/global /app/frontend/images + cp -r backend/* /app + cp -r global/* /app/global + msg_ok "Setup Enviroment" + + msg_info "Building Frontend" + cd ./frontend + export NODE_ENV=development + yarn install --network-timeout=30000 &>/dev/null + yarn build &>/dev/null + cp -r dist/* /app/frontend + cp -r app-images/* /app/frontend/images + msg_ok "Built Frontend" + + msg_info "Initializing Backend" + rm -rf /app/config/default.json &>/dev/null + if [ ! -f /app/config/production.json ]; then + cat <<'EOF' >/app/config/production.json +{ + "database": { + "engine": "knex-native", + "knex": { + "client": "sqlite3", + "connection": { + "filename": "/data/database.sqlite" + } + } + } +} +EOF + fi + cd /app + export NODE_ENV=development + yarn install --network-timeout=30000 &>/dev/null + msg_ok "Initialized Backend" + + msg_info "Starting Services" + systemctl enable npm &>/dev/null + systemctl start openresty + systemctl start npm + msg_ok "Started Services" + + msg_info "Cleaning up" + rm -rf ~/nginx-proxy-manager-* + msg_ok "Cleaned" + + msg_ok "Update Successfull" + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:81${CL} \n" diff --git a/ct/nocodb-v5.sh b/ct/nocodb-v5.sh deleted file mode 100644 index 50b929cb..00000000 --- a/ct/nocodb-v5.sh +++ /dev/null @@ -1,429 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _ __ ____ ____ - / | / /___ ____v5___ / __ \/ __ ) - / |/ / __ \/ ___/ __ \/ / / / __ | - / /| / /_/ / /__/ /_/ / /_/ / /_/ / -/_/ |_/\____/\___/\____/_____/_____/ - -EOF -} -header_info -echo -e "Loading..." -APP="NocoDB" -var_disk="4" -var_cpu="1" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP}" -cd /opt/nocodb -npm uninstall -s --save nocodb &>/dev/null -npm install -s --save nocodb &>/dev/null -systemctl restart nocodb.service -msg_ok "Updated ${APP}" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/systemd/system/nocodb.service ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8080/dashboard${CL} \n" diff --git a/ct/nocodb.sh b/ct/nocodb.sh new file mode 100644 index 00000000..50677ceb --- /dev/null +++ b/ct/nocodb.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + _ __ ____ ____ + / | / /___ ____ ___ / __ \/ __ ) + / |/ / __ \/ ___/ __ \/ / / / __ | + / /| / /_/ / /__/ /_/ / /_/ / /_/ / +/_/ |_/\____/\___/\____/_____/_____/ + +EOF +} +header_info +echo -e "Loading..." +APP="NocoDB" +var_disk="4" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/systemd/system/nocodb.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP}" +cd /opt/nocodb +npm uninstall -s --save nocodb &>/dev/null +npm install -s --save nocodb &>/dev/null +systemctl restart nocodb.service +msg_ok "Updated ${APP}" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8080/dashboard${CL} \n" diff --git a/ct/node-red-v5.sh b/ct/node-red-v5.sh deleted file mode 100644 index e0a5fbf4..00000000 --- a/ct/node-red-v5.sh +++ /dev/null @@ -1,462 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _ __ __ ____ __ - / | / /___ ____/ /__ v5 / __ \___ ____/ / - / |/ / __ \/ __ / _ \ / /_/ / _ \/ __ / - / /| / /_/ / /_/ / __/ / _, _/ __/ /_/ / -/_/ |_/\____/\__,_/\___/ /_/ |_|\___/\__,_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Node-Red" -var_disk="4" -var_cpu="1" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -UPD=$(whiptail --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 2 \ - "1" "Update ${APP}" ON \ - "2" "Install Themes" OFF \ - 3>&1 1>&2 2>&3) -header_info -if [ "$UPD" == "1" ]; then -msg_info "Stopping ${APP}" -systemctl stop nodered -msg_ok "Stopped ${APP}" - -msg_info "Updating ${APP}" -npm install -g --unsafe-perm node-red &>/dev/null -msg_ok "Updated ${APP}" - -msg_info "Starting ${APP}" -systemctl start nodered -msg_ok "Started ${APP}" -msg_ok "Update Successful" -exit -fi -if [ "$UPD" == "2" ]; then -THEME=$(whiptail --title "NODE-RED THEMES" --radiolist --cancel-button Exit-Script "Choose Theme" 15 58 6 \ - "dark" "" OFF \ - "dracula" "" OFF \ - "midnight-red" "" ON \ - "oled" "" OFF \ - "solarized-dark" "" OFF \ - "solarized-light" "" OFF \ - 3>&1 1>&2 2>&3) -header_info -msg_info "Installing ${THEME} Theme" -cd /root/.node-red -sed -i 's|//theme: "",|theme: "",|g' /root/.node-red/settings.js -npm install @node-red-contrib-themes/${THEME} &>/dev/null -sed -i "{s/theme: ".*"/theme: '${THEME}',/g}" /root/.node-red/settings.js -msg_ok "Installed ${THEME} Theme" - -msg_info "Restarting ${APP}" -systemctl restart nodered -msg_ok "Restarted ${APP}" -exit -fi -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /root/.node-red ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:1880${CL} \n" diff --git a/ct/node-red.sh b/ct/node-red.sh new file mode 100644 index 00000000..b625d323 --- /dev/null +++ b/ct/node-red.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + _ __ __ ____ __ + / | / /___ ____/ /__ / __ \___ ____/ / + / |/ / __ \/ __ / _ \ / /_/ / _ \/ __ / + / /| / /_/ / /_/ / __/ / _, _/ __/ /_/ / +/_/ |_/\____/\__,_/\___/ /_/ |_|\___/\__,_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Node-Red" +var_disk="4" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +if [[ ! -d /root/.node-red ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +UPD=$(whiptail --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 2 \ + "1" "Update ${APP}" ON \ + "2" "Install Themes" OFF \ + 3>&1 1>&2 2>&3) +header_info +if [ "$UPD" == "1" ]; then +msg_info "Stopping ${APP}" +systemctl stop nodered +msg_ok "Stopped ${APP}" + +msg_info "Updating ${APP}" +npm install -g --unsafe-perm node-red &>/dev/null +msg_ok "Updated ${APP}" + +msg_info "Starting ${APP}" +systemctl start nodered +msg_ok "Started ${APP}" +msg_ok "Update Successful" +exit +fi +if [ "$UPD" == "2" ]; then +THEME=$(whiptail --title "NODE-RED THEMES" --radiolist --cancel-button Exit-Script "Choose Theme" 15 58 6 \ + "dark" "" OFF \ + "dracula" "" OFF \ + "midnight-red" "" ON \ + "oled" "" OFF \ + "solarized-dark" "" OFF \ + "solarized-light" "" OFF \ + 3>&1 1>&2 2>&3) +header_info +msg_info "Installing ${THEME} Theme" +cd /root/.node-red +sed -i 's|//theme: "",|theme: "",|g' /root/.node-red/settings.js +npm install @node-red-contrib-themes/${THEME} &>/dev/null +sed -i "{s/theme: ".*"/theme: '${THEME}',/g}" /root/.node-red/settings.js +msg_ok "Installed ${THEME} Theme" + +msg_info "Restarting ${APP}" +systemctl restart nodered +msg_ok "Restarted ${APP}" +exit +fi +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:1880${CL} \n" diff --git a/ct/omada-v5.sh b/ct/omada-v5.sh deleted file mode 100644 index c9b9defc..00000000 --- a/ct/omada-v5.sh +++ /dev/null @@ -1,439 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __ - / __ \____ ___v5____ _____/ /___ _ - / / / / __ __ \/ __ / __ / __ / -/ /_/ / / / / / / /_/ / /_/ / /_/ / -\____/_/ /_/ /_/\__,_/\__,_/\__,_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Omada" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="ubuntu" -var_version="20.04" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}" - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if var_version=$(whiptail --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 4 \ - "18.04" "Bionic" OFF \ - "20.04" "Focal" ON \ - "22.04" "Jammy" OFF \ - "22.10" "Kinetic" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Ubuntu Version: ${BGN}$var_version${CL}" -else - exit-script -fi - -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/tplink ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}https://${IP}:8043${CL} \n" diff --git a/ct/omada.sh b/ct/omada.sh new file mode 100644 index 00000000..40eea690 --- /dev/null +++ b/ct/omada.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/ubuntu.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ____ __ + / __ \____ ___ ____ _____/ /___ _ + / / / / __ __ \/ __ / __ / __ / +/ /_/ / / / / / / /_/ / /_/ / /_/ / +\____/_/ /_/ /_/\__,_/\__,_/\__,_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Omada" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="ubuntu" +var_version="20.04" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="0" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/tplink ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}https://${IP}:8043${CL} \n" diff --git a/ct/omv-v5.sh b/ct/omv-v5.sh deleted file mode 100644 index 692f323b..00000000 --- a/ct/omv-v5.sh +++ /dev/null @@ -1,438 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __ ___ ___ _ __ ____ - / __ \____v5___ ____ / |/ /__ ____/ (_)___ | | / /___ ___ __/ / /_ - / / / / __ \/ _ \/ __ \/ /|_/ / _ \/ __ / / __ `/ | / / __ `/ / / / / __/ -/ /_/ / /_/ / __/ / / / / / / __/ /_/ / / /_/ /| |/ / /_/ / /_/ / / /_ -\____/ .___/\___/_/ /_/_/ /_/\___/\__,_/_/\__,_/ |___/\__,_/\__,_/_/\__/ - /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="OMV" -var_disk="4" -var_cpu="2" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" - CT_TYPE="0" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/apt/sources.list.d/openmediavault.list ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -lxc.cgroup2.devices.allow: c 188:* rwm -lxc.cgroup2.devices.allow: c 189:* rwm -lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir -lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file -EOF -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}${CL} \n" diff --git a/ct/omv.sh b/ct/omv.sh new file mode 100644 index 00000000..f370db72 --- /dev/null +++ b/ct/omv.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ____ __ ___ ___ _ __ ____ + / __ \____ ___ ____ / |/ /__ ____/ (_)___ | | / /___ ___ __/ / /_ + / / / / __ \/ _ \/ __ \/ /|_/ / _ \/ __ / / __ `/ | / / __ `/ / / / / __/ +/ /_/ / /_/ / __/ / / / / / / __/ /_/ / / /_/ /| |/ / /_/ / /_/ / / /_ +\____/ .___/\___/_/ /_/_/ /_/\___/\__,_/_/\__,_/ |___/\__,_/\__,_/_/\__/ + /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="OMV" +var_disk="4" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/apt/sources.list.d/openmediavault.list ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}${CL} \n" diff --git a/ct/openhab-v5.sh b/ct/openhab-v5.sh deleted file mode 100644 index 45150c44..00000000 --- a/ct/openhab-v5.sh +++ /dev/null @@ -1,428 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ _____ ____ - ____v5____ ___ ____ / / / / | / __ ) - / __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __ | -/ /_/ / /_/ / __/ / / / __ / ___ |/ /_/ / -\____/ .___/\___/_/ /_/_/ /_/_/ |_/_____/ - /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="openHAB" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/apt/sources.list.d/openhab.list ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8080${CL} \n" diff --git a/ct/openhab.sh b/ct/openhab.sh new file mode 100644 index 00000000..6e3357a6 --- /dev/null +++ b/ct/openhab.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ _____ ____ + ____ ____ ___ ____ / / / / | / __ ) + / __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __ | +/ /_/ / /_/ / __/ / / / __ / ___ |/ /_/ / +\____/ .___/\___/_/ /_/_/ /_/_/ |_/_____/ + /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="openHAB" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/apt/sources.list.d/openhab.list ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8080${CL} \n" diff --git a/ct/paperless-ngx-v5.sh b/ct/paperless-ngx-v5.sh deleted file mode 100644 index 88b62649..00000000 --- a/ct/paperless-ngx-v5.sh +++ /dev/null @@ -1,495 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __ - / __ \____ _____ ___ _____/ /__v5__________ ____ ____ __ __ - / /_/ / __ `/ __ \/ _ \/ ___/ / _ \/ ___/ ___/___/ __ \/ __ `/ |/_/ - / ____/ /_/ / /_/ / __/ / / / __(__ |__ )___/ / / / /_/ /> < -/_/ \__,_/ .___/\___/_/ /_/\___/____/____/ /_/ /_/\__, /_/|_| - /_/ /____/ - -EOF -} -header_info -echo -e "Loading..." -APP="Paperless-ngx" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -RELEASE=$(curl -s https://api.github.com/repos/paperless-ngx/paperless-ngx/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -SER=/etc/systemd/system/paperless-task-queue.service - -UPD=$(whiptail --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 2 \ - "1" "Update Paperless-ngx to $RELEASE" ON \ - "2" "Paperless-ngx Credentials" OFF \ - 3>&1 1>&2 2>&3) -header_info -if [ "$UPD" == "1" ]; then -msg_info "Stopping Paperless-ngx" -systemctl stop paperless-consumer paperless-webserver paperless-scheduler - if [ -f "$SER" ]; then - systemctl stop paperless-task-queue.service - fi -sleep 1 -msg_ok "Stopped Paperless-ngx" - -msg_info "Updating to ${RELEASE}" - if [ "$(dpkg -l | awk '/libmariadb-dev-compat/ {print }'|wc -l)" != 1 ]; then apt-get install -y libmariadb-dev-compat; fi &>/dev/null - wget https://github.com/paperless-ngx/paperless-ngx/releases/download/$RELEASE/paperless-ngx-$RELEASE.tar.xz &>/dev/null - tar -xf paperless-ngx-$RELEASE.tar.xz &>/dev/null - cp -r /opt/paperless/paperless.conf paperless-ngx/ - cp -r paperless-ngx/* /opt/paperless/ - cd /opt/paperless - sed -i -e 's|-e git+https://github.com/paperless-ngx/django-q.git|git+https://github.com/paperless-ngx/django-q.git|' /opt/paperless/requirements.txt - pip install -r requirements.txt &>/dev/null - cd /opt/paperless/src - /usr/bin/python3 manage.py migrate &>/dev/null - if [ -f "$SER" ]; then - msg_ok "paperless-task-queue.service Exists." - else -cat </etc/systemd/system/paperless-task-queue.service -[Unit] -Description=Paperless Celery Workers -Requires=redis.service -[Service] -WorkingDirectory=/opt/paperless/src -ExecStart=celery --app paperless worker --loglevel INFO -[Install] -WantedBy=multi-user.target -EOF -systemctl enable paperless-task-queue &>/dev/null -msg_ok "paperless-task-queue.service Created." - fi -cat </etc/systemd/system/paperless-scheduler.service -[Unit] -Description=Paperless Celery beat -Requires=redis.service -[Service] -WorkingDirectory=/opt/paperless/src -ExecStart=celery --app paperless beat --loglevel INFO -[Install] -WantedBy=multi-user.target -EOF -msg_ok "Updated to ${RELEASE}" - -msg_info "Cleaning up" -cd ~ -rm paperless-ngx-$RELEASE.tar.xz -rm -rf paperless-ngx -msg_ok "Cleaned" - -msg_info "Starting Paperless-ngx" -systemctl daemon-reload -systemctl start paperless-consumer paperless-webserver paperless-scheduler paperless-task-queue.service -sleep 1 -msg_ok "Started Paperless-ngx" -msg_ok "Updated Successfully!\n" -exit -fi -if [ "$UPD" == "2" ]; then -cat paperless.creds -exit -fi -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/paperless ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8000${CL} \n" diff --git a/ct/paperless-ngx.sh b/ct/paperless-ngx.sh new file mode 100644 index 00000000..dadc2f51 --- /dev/null +++ b/ct/paperless-ngx.sh @@ -0,0 +1,142 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + + ____ __ + / __ \____ _____ ___ _____/ /__ __________ ____ ____ __ __ + / /_/ / __ `/ __ \/ _ \/ ___/ / _ \/ ___/ ___/___/ __ \/ __ `/ |/_/ + / ____/ /_/ / /_/ / __/ / / / __(__ |__ )___/ / / / /_/ /> < +/_/ \__,_/ .___/\___/_/ /_/\___/____/____/ /_/ /_/\__, /_/|_| + /_/ /____/ + +EOF +} +header_info +echo -e "Loading..." +APP="Paperless-ngx" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + if [[ ! -d /opt/paperless ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + RELEASE=$(curl -s https://api.github.com/repos/paperless-ngx/paperless-ngx/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') + SER=/etc/systemd/system/paperless-task-queue.service + + UPD=$(whiptail --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 2 \ + "1" "Update Paperless-ngx to $RELEASE" ON \ + "2" "Paperless-ngx Credentials" OFF \ + 3>&1 1>&2 2>&3) + header_info + if [ "$UPD" == "1" ]; then + msg_info "Stopping Paperless-ngx" + systemctl stop paperless-consumer paperless-webserver paperless-scheduler + if [ -f "$SER" ]; then + systemctl stop paperless-task-queue.service + fi + sleep 1 + msg_ok "Stopped Paperless-ngx" + + msg_info "Updating to ${RELEASE}" + if [ "$(dpkg -l | awk '/libmariadb-dev-compat/ {print }' | wc -l)" != 1 ]; then apt-get install -y libmariadb-dev-compat; fi &>/dev/null + wget https://github.com/paperless-ngx/paperless-ngx/releases/download/$RELEASE/paperless-ngx-$RELEASE.tar.xz &>/dev/null + tar -xf paperless-ngx-$RELEASE.tar.xz &>/dev/null + cp -r /opt/paperless/paperless.conf paperless-ngx/ + cp -r paperless-ngx/* /opt/paperless/ + cd /opt/paperless + sed -i -e 's|-e git+https://github.com/paperless-ngx/django-q.git|git+https://github.com/paperless-ngx/django-q.git|' /opt/paperless/requirements.txt + pip install -r requirements.txt &>/dev/null + cd /opt/paperless/src + /usr/bin/python3 manage.py migrate &>/dev/null + if [ -f "$SER" ]; then + msg_ok "paperless-task-queue.service Exists." + else + cat </etc/systemd/system/paperless-task-queue.service +[Unit] +Description=Paperless Celery Workers +Requires=redis.service +[Service] +WorkingDirectory=/opt/paperless/src +ExecStart=celery --app paperless worker --loglevel INFO +[Install] +WantedBy=multi-user.target +EOF + systemctl enable paperless-task-queue &>/dev/null + msg_ok "paperless-task-queue.service Created." + fi + cat </etc/systemd/system/paperless-scheduler.service +[Unit] +Description=Paperless Celery beat +Requires=redis.service +[Service] +WorkingDirectory=/opt/paperless/src +ExecStart=celery --app paperless beat --loglevel INFO +[Install] +WantedBy=multi-user.target +EOF + msg_ok "Updated to ${RELEASE}" + + msg_info "Cleaning up" + cd ~ + rm paperless-ngx-$RELEASE.tar.xz + rm -rf paperless-ngx + msg_ok "Cleaned" + + msg_info "Starting Paperless-ngx" + systemctl daemon-reload + systemctl start paperless-consumer paperless-webserver paperless-scheduler paperless-task-queue.service + sleep 1 + msg_ok "Started Paperless-ngx" + msg_ok "Updated Successfully!\n" + exit + fi + if [ "$UPD" == "2" ]; then + cat paperless.creds + exit + fi +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8000${CL} \n" diff --git a/ct/photoprism-v5.sh b/ct/photoprism-v5.sh deleted file mode 100644 index f128744e..00000000 --- a/ct/photoprism-v5.sh +++ /dev/null @@ -1,452 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __ ______ __________ ____ ____ _________ __ ___ - / __ \/ / / / __ \/_ __/ __ \/ __ \/ __ \/ _/ ___// |/ / - / /_/ / /_/ / / / / / / / / / / /_/ / /_/ // / \__ \/ /|_/ / - / ____/ __ / /_/ / / / / /_/ / ____/ _, _// / v5_/ / / / / -/_/ /_/ /_/\____/ /_/ \____/_/ /_/ |_/___//____/_/ /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="PhotoPrism" -var_disk="8" -var_cpu="4" -var_ram="4096" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -echo -e "\n ⚠️ Ensure you set 2vCPU & 3072MiB RAM MIMIMUM!!! \n" -msg_info "Stopping PhotoPrism" -sudo systemctl stop photoprism -msg_ok "Stopped PhotoPrism" - -msg_info "Cloning PhotoPrism" -git clone https://github.com/photoprism/photoprism.git &>/dev/null -cd photoprism -git checkout release &>/dev/null -msg_ok "Cloned PhotoPrism" - -msg_info "Building PhotoPrism" -sudo make all &>/dev/null -sudo ./scripts/build.sh prod /opt/photoprism/bin/photoprism &>/dev/null -sudo rm -rf /opt/photoprism/assets -sudo cp -r assets/ /opt/photoprism/ &>/dev/null -msg_ok "Built PhotoPrism" - -msg_info "Cleaning" -cd ~ -rm -rf photoprism -msg_ok "Cleaned" - -msg_info "Starting PhotoPrism" -sudo systemctl start photoprism -msg_ok "Started PhotoPrism" -msg_ok "Update Successful" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/photoprism ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_info "Setting Container to Normal Resources" -pct set $CTID -memory 2048 -msg_ok "Set Container to Normal Resources" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:2342${CL} \n" diff --git a/ct/photoprism.sh b/ct/photoprism.sh new file mode 100644 index 00000000..1e789870 --- /dev/null +++ b/ct/photoprism.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + + ____ __ ______ __________ ____ ____ _________ __ ___ + / __ \/ / / / __ \/_ __/ __ \/ __ \/ __ \/ _/ ___// |/ / + / /_/ / /_/ / / / / / / / / / / /_/ / /_/ // / \__ \/ /|_/ / + / ____/ __ / /_/ / / / / /_/ / ____/ _, _// / ___/ / / / / +/_/ /_/ /_/\____/ /_/ \____/_/ /_/ |_/___//____/_/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="PhotoPrism" +var_disk="8" +var_cpu="4" +var_ram="4096" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + header_info + if [[ ! -d /opt/photoprism ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + echo -e "\n ⚠️ Ensure you set 2vCPU & 3072MiB RAM MIMIMUM!!! \n" + msg_info "Stopping PhotoPrism" + sudo systemctl stop photoprism + msg_ok "Stopped PhotoPrism" + + msg_info "Cloning PhotoPrism" + git clone https://github.com/photoprism/photoprism.git &>/dev/null + cd photoprism + git checkout release &>/dev/null + msg_ok "Cloned PhotoPrism" + + msg_info "Building PhotoPrism" + sudo make all &>/dev/null + sudo ./scripts/build.sh prod /opt/photoprism/bin/photoprism &>/dev/null + sudo rm -rf /opt/photoprism/assets + sudo cp -r assets/ /opt/photoprism/ &>/dev/null + msg_ok "Built PhotoPrism" + + msg_info "Cleaning" + cd ~ + rm -rf photoprism + msg_ok "Cleaned" + + msg_info "Starting PhotoPrism" + sudo systemctl start photoprism + msg_ok "Started PhotoPrism" + msg_ok "Update Successful" + exit +} + +start +build_container +description + +msg_info "Setting Container to Normal Resources" +pct set $CTID -memory 2048 +msg_ok "Set Container to Normal Resources" +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:2342${CL} \n" diff --git a/ct/pihole-v5.sh b/ct/pihole-v5.sh deleted file mode 100644 index f4e541af..00000000 --- a/ct/pihole-v5.sh +++ /dev/null @@ -1,427 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ ____ __ ______ __ ______ - / __ \/ _/ / / / / __ \/ / / ____/ - / /_/ // /___/ /_/ / / / / / / __/ - / ____// /___/ __ / /_/ / /v5_/ /___ -/_/ /___/ /_/ /_/\____/_____/_____/ - -EOF -} -header_info -echo -e "Loading..." -APP="Pihole" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /etc/pihole ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}/admin${CL} \n" diff --git a/ct/pihole.sh b/ct/pihole.sh new file mode 100644 index 00000000..b5de9177 --- /dev/null +++ b/ct/pihole.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + ____ ____ __ ______ __ ______ + / __ \/ _/ / / / / __ \/ / / ____/ + / /_/ // /___/ /_/ / / / / / / __/ + / ____// /___/ __ / /_/ / /___/ /___ +/_/ /___/ /_/ /_/\____/_____/_____/ + +EOF +} +header_info +echo -e "Loading..." +APP="Pihole" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /etc/pihole ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}/admin${CL} \n" diff --git a/ct/plex-v5.sh b/ct/plex-v5.sh deleted file mode 100644 index a1d4b466..00000000 --- a/ct/plex-v5.sh +++ /dev/null @@ -1,460 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __ __ ___ ___ _____ - / __ \/ /__ _ __ / |/ /__v5____/ (_)___ _ / ___/___ ______ _____ _____ - / /_/ / / _ \| |/_/ / /|_/ / _ \/ __ / / __ `/ \__ \/ _ \/ ___/ | / / _ \/ ___/ - / ____/ / __/> < / / / / __/ /_/ / / /_/ / ___/ / __/ / | |/ / __/ / -/_/ /_/\___/_/|_| /_/ /_/\___/\__,_/_/\__,_/ /____/\___/_/ |___/\___/_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Plex" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="ubuntu" -var_version="20.04" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}" - echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" - CT_TYPE="0" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if var_version=$(whiptail --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 4 \ - "18.04" "Bionic" OFF \ - "20.04" "Focal" ON \ - "22.04" "Jammy" OFF \ - "22.10" "Kinetic" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Ubuntu Version: ${BGN}$var_version${CL}" -else - exit-script -fi -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" OFF \ - "0" "Privileged" ON \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -UPD=$(whiptail --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select \nplexupdate info >> https://github.com/mrworf/plexupdate" 10 59 2 \ - "1" "Update LXC" ON \ - "2" "Run plexupdate" OFF \ - 3>&1 1>&2 2>&3) - -header_info -if [ "$UPD" == "1" ]; then -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -exit -fi -if [ "$UPD" == "2" ]; then -bash -c "$(wget -qO - https://raw.githubusercontent.com/mrworf/plexupdate/master/extras/installer.sh)" -exit -fi -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/apt/sources.list.d/plexmediaserver.list ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -if [ "$CT_TYPE" == "0" ]; then - LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: c 226:0 rwm -lxc.cgroup2.devices.allow: c 226:128 rwm -lxc.cgroup2.devices.allow: c 29:0 rwm -lxc.mount.entry: /dev/fb0 dev/fb0 none bind,optional,create=file -lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir -lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file -EOF -fi -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:32400/web${CL}\n" diff --git a/ct/plex.sh b/ct/plex.sh new file mode 100644 index 00000000..a944d8b6 --- /dev/null +++ b/ct/plex.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/ubuntu.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + ____ __ __ ___ ___ _____ + / __ \/ /__ _ __ / |/ /__ ____/ (_)___ _ / ___/___ ______ _____ _____ + / /_/ / / _ \| |/_/ / /|_/ / _ \/ __ / / __ `/ \__ \/ _ \/ ___/ | / / _ \/ ___/ + / ____/ / __/> < / / / / __/ /_/ / / /_/ / ___/ / __/ / | |/ / __/ / +/_/ /_/\___/_/|_| /_/ /_/\___/\__,_/_/\__,_/ /____/\___/_/ |___/\___/_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Plex" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="ubuntu" +var_version="20.04" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="0" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +if [[ ! -f /etc/apt/sources.list.d/plexmediaserver.list ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +UPD=$(whiptail --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select \nplexupdate info >> https://github.com/mrworf/plexupdate" 10 59 2 \ + "1" "Update LXC" ON \ + "2" "Run plexupdate" OFF \ + 3>&1 1>&2 2>&3) + +header_info +if [ "$UPD" == "1" ]; then +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +exit +fi +if [ "$UPD" == "2" ]; then +bash -c "$(wget -qO - https://raw.githubusercontent.com/mrworf/plexupdate/master/extras/installer.sh)" +exit +fi +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:32400/web${CL}\n" diff --git a/ct/podman-homeassistant-v5.sh b/ct/podman-homeassistant-v5.sh deleted file mode 100644 index daba5aec..00000000 --- a/ct/podman-homeassistant-v5.sh +++ /dev/null @@ -1,497 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __ - / __ \____ ____/ /___ ___ ____ _____ - / /_/ / __ \/ __ / __ __ \/ __ / __ \ - / ____/ /_/ / /_/ / / / / / / /_/ / / / / - __ __ /_/ \____/\__,_/_/ /_/ /_/\__,_/_/ /_/__ __ - / / / /___ ____ ___ ___ v5 / | __________(_)____/ /_____ _____ / /_ - / /_/ / __ \/ __ __ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ / __ \/ __/ - / __ / /_/ / / / / / / __/ / ___ |(__ |__ ) (__ ) /_/ /_/ / / / / /_ -/_/ /_/\____/_/ /_/ /_/\___/ /_/ |_/____/____/_/____/\__/\__,_/_/ /_/\__/ - -EOF -} -header_info -echo -e "Loading..." -APP="Podman-Home Assistant" -var_disk="16" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { - UPD=$(whiptail --title "UPDATE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 4 \ - "1" "Update Podman" ON \ - "2" "Install HACS" OFF \ - "3" "Install FileBrowser" OFF \ - 3>&1 1>&2 2>&3) -header_info -if [ "$UPD" == "1" ]; then -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -fi -if [ "$UPD" == "2" ]; then -msg_info "Installing Home Assistant Comunity Store (HACS)" -apt update &>/dev/null -apt install unzip &>/dev/null -cd /var/lib/containers/storage/volumes/hass_config/_data -bash <(curl -fsSL https://get.hacs.xyz) &>/dev/null -msg_ok "Installed Home Assistant Comunity Store (HACS)" -echo -e "\n Reboot Home Assistant and clear browser cache then Add HACS integration.\n" -exit -fi -if [ "$UPD" == "3" ]; then -IP=$(hostname -I | awk '{print $1}') -msg_info "Installing FileBrowser" -curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash &>/dev/null -filebrowser config init -a '0.0.0.0' &>/dev/null -filebrowser config set -a '0.0.0.0' &>/dev/null -filebrowser users add admin changeme --perm.admin &>/dev/null -msg_ok "Installed FileBrowser" - -msg_info "Creating Service" -service_path="/etc/systemd/system/filebrowser.service" -echo "[Unit] -Description=Filebrowser -After=network-online.target -[Service] -User=root -WorkingDirectory=/root/ -ExecStart=/usr/local/bin/filebrowser -r / -[Install] -WantedBy=default.target" >$service_path - -systemctl enable --now filebrowser.service &>/dev/null -msg_ok "Created Service" - -msg_ok "Completed Successfully!\n" -echo -e "FileBrowser should be reachable by going to the following URL. - ${BL}http://$IP:8080${CL} admin|changeme\n" -exit -fi -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/systemd/system/homeassistant.service ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -if [ "$CT_TYPE" == "0" ]; then - cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -lxc.cgroup2.devices.allow: c 188:* rwm -lxc.cgroup2.devices.allow: c 189:* rwm -lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir -lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file -EOF -else - cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -fi -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8123${CL} \n" diff --git a/ct/podman-homeassistant.sh b/ct/podman-homeassistant.sh new file mode 100644 index 00000000..14947e9d --- /dev/null +++ b/ct/podman-homeassistant.sh @@ -0,0 +1,121 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + ____ __ + / __ \____ ____/ /___ ___ ____ _____ + / /_/ / __ \/ __ / __ __ \/ __ / __ \ + / ____/ /_/ / /_/ / / / / / / /_/ / / / / + __ __ /_/ \____/\__,_/_/ /_/ /_/\__,_/_/ /_/__ __ + / / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____ / /_ + / /_/ / __ \/ __ __ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ / __ \/ __/ + / __ / /_/ / / / / / / __/ / ___ |(__ |__ ) (__ ) /_/ /_/ / / / / /_ +/_/ /_/\____/_/ /_/ /_/\___/ /_/ |_/____/____/_/____/\__/\__,_/_/ /_/\__/ + +EOF +} +header_info +echo -e "Loading..." +APP="Podman-Home Assistant" +var_disk="16" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + [[ ! -f /etc/systemd/system/homeassistant.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi + UPD=$(whiptail --title "UPDATE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 4 \ + "1" "Update Podman" ON \ + "2" "Install HACS" OFF \ + "3" "Install FileBrowser" OFF \ + 3>&1 1>&2 2>&3) +header_info +if [ "$UPD" == "1" ]; then +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +fi +if [ "$UPD" == "2" ]; then +msg_info "Installing Home Assistant Comunity Store (HACS)" +apt update &>/dev/null +apt install unzip &>/dev/null +cd /var/lib/containers/storage/volumes/hass_config/_data +bash <(curl -fsSL https://get.hacs.xyz) &>/dev/null +msg_ok "Installed Home Assistant Comunity Store (HACS)" +echo -e "\n Reboot Home Assistant and clear browser cache then Add HACS integration.\n" +exit +fi +if [ "$UPD" == "3" ]; then +IP=$(hostname -I | awk '{print $1}') +msg_info "Installing FileBrowser" +curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash &>/dev/null +filebrowser config init -a '0.0.0.0' &>/dev/null +filebrowser config set -a '0.0.0.0' &>/dev/null +filebrowser users add admin changeme --perm.admin &>/dev/null +msg_ok "Installed FileBrowser" + +msg_info "Creating Service" +service_path="/etc/systemd/system/filebrowser.service" +echo "[Unit] +Description=Filebrowser +After=network-online.target +[Service] +User=root +WorkingDirectory=/root/ +ExecStart=/usr/local/bin/filebrowser -r / +[Install] +WantedBy=default.target" >$service_path + +systemctl enable --now filebrowser.service &>/dev/null +msg_ok "Created Service" + +msg_ok "Completed Successfully!\n" +echo -e "FileBrowser should be reachable by going to the following URL. + ${BL}http://$IP:8080${CL} admin|changeme\n" +exit +fi +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8123${CL} \n" diff --git a/ct/podman-v5.sh b/ct/podman-v5.sh deleted file mode 100644 index 582e0831..00000000 --- a/ct/podman-v5.sh +++ /dev/null @@ -1,425 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __ - / __ \____v5____/ /___ ___ ____ _____ - / /_/ / __ \/ __ / __ `__ \/ __ `/ __ \ - / ____/ /_/ / /_/ / / / / / / /_/ / / / / -/_/ \____/\__,_/_/ /_/ /_/\__,_/_/ /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Podman" -var_disk="4" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/containers/registries.conf ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" diff --git a/ct/podman.sh b/ct/podman.sh new file mode 100644 index 00000000..ef57de78 --- /dev/null +++ b/ct/podman.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + ____ __ + / __ \____ ____/ /___ ___ ____ _____ + / /_/ / __ \/ __ / __ `__ \/ __ `/ __ \ + / ____/ /_/ / /_/ / / / / / / /_/ / / / / +/_/ \____/\__,_/_/ /_/ /_/\__,_/_/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Podman" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/containers/registries.conf ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/postgresql-v5.sh b/ct/postgresql-v5.sh deleted file mode 100644 index 47a66cf8..00000000 --- a/ct/postgresql-v5.sh +++ /dev/null @@ -1,425 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __ _____ ____ __ - / __ \____ _____/ /_____ _________ / ___// __ \ / / - / /_/ / __ \/ ___/ __/ __ / ___/ _ \\__ \/ / / / / / - / ____/ /_/ (__ ) /_/ /_/ / / / __/__/ / /_/ / / /___ -/_/ \____/____/\__/\__, /_/v5 \___/____/\___\_\/_____/ - /____/ -EOF -} -header_info -echo -e "Loading..." -APP="PostgreSQL" -var_disk="4" -var_cpu="1" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/apt/sources.list.d/pgdg.list ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" diff --git a/ct/postgresql.sh b/ct/postgresql.sh new file mode 100644 index 00000000..1275649a --- /dev/null +++ b/ct/postgresql.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + ____ __ _____ ____ __ + / __ \____ _____/ /_____ _________ / ___// __ \ / / + / /_/ / __ \/ ___/ __/ __ / ___/ _ \\__ \/ / / / / / + / ____/ /_/ (__ ) /_/ /_/ / / / __/__/ / /_/ / / /___ +/_/ \____/____/\__/\__, /_/ \___/____/\___\_\/_____/ + /____/ +EOF +} +header_info +echo -e "Loading..." +APP="PostgreSQL" +var_disk="4" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/apt/sources.list.d/pgdg.list ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/prometheus-v5.sh b/ct/prometheus-v5.sh deleted file mode 100644 index 34856e1a..00000000 --- a/ct/prometheus-v5.sh +++ /dev/null @@ -1,427 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __ __ - / __ \_________ ____ ___ ___ / /_/ /_ ___ __ _______ - / /_/ / ___/ __ \/ __ __ \/ _ \/ __/ __ \/ _ \/ / / / ___/ - / ____/ / / /_/ / / / / / / __/ /_/ / / / __/ /_/ (__ ) -/_/ v5/_/ \____/_/ /_/ /_/\___/\__/_/ /_/\___/\__,_/____/ - -EOF -} -header_info -echo -e "Loading..." -APP="Prometheus" -var_disk="4" -var_cpu="1" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/systemd/system/prometheus.service ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:9090${CL} \n" diff --git a/ct/prometheus.sh b/ct/prometheus.sh new file mode 100644 index 00000000..c1514477 --- /dev/null +++ b/ct/prometheus.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + ____ __ __ + / __ \_________ ____ ___ ___ / /_/ /_ ___ __ _______ + / /_/ / ___/ __ \/ __ __ \/ _ \/ __/ __ \/ _ \/ / / / ___/ + / ____/ / / /_/ / / / / / / __/ /_/ / / / __/ /_/ (__ ) +/_/ /_/ \____/_/ /_/ /_/\___/\__/_/ /_/\___/\__,_/____/ + +EOF +} +header_info +echo -e "Loading..." +APP="Prometheus" +var_disk="4" +var_cpu="1" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/systemd/system/prometheus.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:9090${CL} \n" diff --git a/ct/prowlarr-v5.sh b/ct/prowlarr-v5.sh deleted file mode 100644 index 758bf5a3..00000000 --- a/ct/prowlarr-v5.sh +++ /dev/null @@ -1,426 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __ - / __ \_________ _ __/ /___v5__________ - / /_/ / ___/ __ \ | /| / / / __ `/ ___/ ___/ - / ____/ / / /_/ / |/ |/ / / /_/ / / / / -/_/ /_/ \____/|__/|__/_/\__,_/_/ /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Prowlarr" -var_disk="4" -var_cpu="2" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating $APP LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated $APP LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /var/lib/prowlarr/ ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:9696${CL} \n" diff --git a/ct/prowlarr.sh b/ct/prowlarr.sh new file mode 100644 index 00000000..a61d6144 --- /dev/null +++ b/ct/prowlarr.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + ____ __ + / __ \_________ _ __/ /___ __________ + / /_/ / ___/ __ \ | /| / / / __ `/ ___/ ___/ + / ____/ / / /_/ / |/ |/ / / /_/ / / / / +/_/ /_/ \____/|__/|__/_/\__,_/_/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Prowlarr" +var_disk="4" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var/lib/prowlarr/ ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:9696${CL} \n" diff --git a/ct/qbittorrent-v5.sh b/ct/qbittorrent-v5.sh deleted file mode 100644 index b52a8f49..00000000 --- a/ct/qbittorrent-v5.sh +++ /dev/null @@ -1,426 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - ____ _ __ __ __ - ____ _/ __ )(_) /_/ /_____ _____________v5____ / /_ - / __ `/ __ / / __/ __/ __ \/ ___/ ___/ _ \/ __ \/ __/ -/ /_/ / /_/ / / /_/ /_/ /_/ / / / / / __/ / / / /_ -\__, /_____/_/\__/\__/\____/_/ /_/ \___/_/ /_/\__/ - /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="qBittorrent" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/systemd/system/qbittorrent-nox.service ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8090${CL}\n" diff --git a/ct/qbittorrent.sh b/ct/qbittorrent.sh new file mode 100644 index 00000000..d5e20ddf --- /dev/null +++ b/ct/qbittorrent.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ____ _ __ __ __ + ____ _/ __ )(_) /_/ /_____ _____________ ____ / /_ + / __ `/ __ / / __/ __/ __ \/ ___/ ___/ _ \/ __ \/ __/ +/ /_/ / /_/ / / /_/ /_/ /_/ / / / / / __/ / / / /_ +\__, /_____/_/\__/\__/\____/_/ /_/ \___/_/ /_/\__/ + /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="qBittorrent" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/systemd/system/qbittorrent-nox.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8090${CL}\n" diff --git a/ct/radarr-v5.sh b/ct/radarr-v5.sh deleted file mode 100644 index e9eb9667..00000000 --- a/ct/radarr-v5.sh +++ /dev/null @@ -1,426 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __ - / __ \____ _____/ /___v5__________ - / /_/ / __ `/ __ / __ `/ ___/ ___/ - / _, _/ /_/ / /_/ / /_/ / / / / -/_/ |_|\__,_/\__,_/\__,_/_/ /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Radarr" -var_disk="4" -var_cpu="2" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating $APP LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated $APP LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /var/lib/radarr/ ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:7878${CL} \n" diff --git a/ct/radarr.sh b/ct/radarr.sh new file mode 100644 index 00000000..0664fc5d --- /dev/null +++ b/ct/radarr.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + ____ __ + / __ \____ _____/ /___ __________ + / /_/ / __ `/ __ / __ `/ ___/ ___/ + / _, _/ /_/ / /_/ / /_/ / / / / +/_/ |_|\__,_/\__,_/\__,_/_/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Radarr" +var_disk="4" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var/lib/radarr/ ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:7878${CL} \n" diff --git a/ct/readarr-v5.sh b/ct/readarr-v5.sh deleted file mode 100644 index 4d555119..00000000 --- a/ct/readarr-v5.sh +++ /dev/null @@ -1,426 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __ - / __ \___ ____ _____/ /___v5__________ - / /_/ / _ \/ __ `/ __ / __ `/ ___/ ___/ - / _, _/ __/ /_/ / /_/ / /_/ / / / / -/_/ |_|\___/\__,_/\__,_/\__,_/_/ /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Readarr" -var_disk="4" -var_cpu="2" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating $APP LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated $APP LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /var/lib/readarr/ ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8787${CL} \n" diff --git a/ct/readarr.sh b/ct/readarr.sh new file mode 100644 index 00000000..3ac5ee57 --- /dev/null +++ b/ct/readarr.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + ____ __ + / __ \___ ____ _____/ /___ __________ + / /_/ / _ \/ __ `/ __ / __ `/ ___/ ___/ + / _, _/ __/ /_/ / /_/ / /_/ / / / / +/_/ |_|\___/\__,_/\__,_/\__,_/_/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Readarr" +var_disk="4" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var/lib/readarr/ ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8787${CL} \n" diff --git a/ct/rockylinux-v5.sh b/ct/rockylinux-v5.sh deleted file mode 100644 index e13fcb60..00000000 --- a/ct/rockylinux-v5.sh +++ /dev/null @@ -1,400 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ____ __ __ _ - / __ \____ _____/ /____ __ / / (_)___v5__ ___ __ - / /_/ / __ \/ ___/ //_/ / / / / / / / __ \/ / / / |/_/ - / _, _/ /_/ / /__/ ,< / /_/ / / /___/ / / / / /_/ /> < -/_/ |_|\____/\___/_/|_|\__, / /_____/_/_/ /_/\__,_/_/|_| - /____/ - -EOF -} -header_info -echo -e "Loading..." -APP="Rocky Linux" -var_disk="1" -var_cpu="1" -var_ram="512" -var_os="rockylinux" -var_version="9" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}archlinux${CL}" - PW="-password rockylinux" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { - CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3) - exitstatus=$? - if [ $exitstatus = 0 ]; then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" - fi - PW1=$(whiptail --inputbox "Set Root Password (needed for root ssh access)" 8 58 --title "PASSWORD(leave blank for automatic login)" --cancel-button Exit-Script 3>&1 1>&2 2>&3) - exitstatus=$? - if [ $exitstatus = 0 ]; then - if [ -z $PW1 ]; then - PW1="rockylinux" PW="-password $PW1" - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" - else - PW="-password $PW1" - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" - fi - fi - CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) - exitstatus=$? - if [ -z $CT_ID ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - else - if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}"; fi - fi - CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) - exitstatus=$? - if [ -z $CT_NAME ]; then - HN="$NSAPP" - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" - else - if [ $exitstatus = 0 ]; then - HN=$(echo ${CT_NAME,,} | tr -d ' ') - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" - fi - fi - DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3) - exitstatus=$? - if [ -z $DISK_SIZE ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}"; fi - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE A INTEGER NUMBER!${CL}" - advanced_settings - fi - fi - CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3) - exitstatus=$? - if [ -z $CORE_COUNT ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"; fi - fi - RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3) - exitstatus=$? - if [ -z $RAM_SIZE ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"; fi - fi - BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3) - exitstatus=$? - if [ -z $BRG ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi - fi - NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) - exitstatus=$? - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - if [ $exitstatus = 0 ]; then echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}"; fi - fi - GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3) - exitstatus=$? - if [ $exitstatus = 0 ]; then - if [ -z $GATE1 ]; then - GATE1="Default" GATE="" - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" - fi - fi - if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - echo -e "${DGN}Disable IPv6: ${BGN}Yes${CL}" - DISABLEIP6="yes" - else - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - fi - MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3) - exitstatus=$? - if [ $exitstatus = 0 ]; then - if [ -z $MTU1 ]; then - MTU1="Default" MTU="" - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" - else - MTU=",mtu=$MTU1" - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" - fi - fi - SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" --cancel-button Exit-Script 3>&1 1>&2 2>&3) - exitstatus=$? - if [ $exitstatus = 0 ]; then - if [ -z $SD ]; then - SD="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - else - SX=$SD - SD="-searchdomain=$SD" - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" - fi - fi - NS=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" --cancel-button Exit-Script 3>&1 1>&2 2>&3) - exitstatus=$? - if [ $exitstatus = 0 ]; then - if [ -z $NS ]; then - NS="" - echo -e "${DGN}Using DNS Server IP Address: ${BGN}Host${CL}" - else - NX=$NS - NS="-nameserver=$NS" - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" - fi - fi - MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) - exitstatus=$? - if [ $exitstatus = 0 ]; then - if [ -z $MAC1 ]; then - MAC1="Default" MAC="" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi - fi - VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3) - exitstatus=$? - if [ $exitstatus = 0 ]; then - if [ -z $VLAN1 ]; then - VLAN1="Default" VLAN="" - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" - fi - fi - if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - echo -e "${DGN}Enable Root SSH Access: ${BGN}Yes${CL}" - SSH="yes" - else - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - fi - if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - echo -e "${DGN}Enable Verbose Mode: ${BGN}Yes${CL}" - VERB="yes" - else - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - fi - if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" - else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -dnf -y update -dnf -y upgrade -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /etc/pacman.d ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} ${var_version} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" diff --git a/ct/rockylinux.sh b/ct/rockylinux.sh new file mode 100644 index 00000000..eb955c9d --- /dev/null +++ b/ct/rockylinux.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + ____ __ __ _ + / __ \____ _____/ /____ __ / / (_)___ __ ___ __ + / /_/ / __ \/ ___/ //_/ / / / / / / / __ \/ / / / |/_/ + / _, _/ /_/ / /__/ ,< / /_/ / / /___/ / / / / /_/ /> < +/_/ |_|\____/\___/_/|_|\__, / /_____/_/_/ /_/\__,_/_/|_| + /____/ + +EOF +} +header_info +echo -e "Loading..." +APP="Rocky Linux" +var_disk="1" +var_cpu="1" +var_ram="512" +var_os="rockylinux" +var_version="9" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="-password rockylinux" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /etc/pacman.d ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +dnf -y update +dnf -y upgrade +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/rstptoweb-v5.sh b/ct/rstptoweb-v5.sh deleted file mode 100644 index 803d52c9..00000000 --- a/ct/rstptoweb-v5.sh +++ /dev/null @@ -1,420 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - ____ _______________ __ _ ____________ - / __ \/ ___/_ __/ __ \/ /_____| | v5 / / ____/ __ ) - / /_/ /\__ \ / / / /_/ / __/ __ \ | /| / / __/ / __ | - / _, _/___/ // / / ____/ /_/ /_/ / |/ |/ / /___/ /_/ / -/_/ |_|/____//_/ /_/ \__/\____/|__/|__/_____/_____/ - -EOF -} -header_info -echo -e "Loading..." -APP="RSTPtoWEB" -var_disk="4" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating $APP LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated $APP LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} Setup should be reachable by going to the following URL. - ${BL}http://${IP}:8083 ${CL} \n" diff --git a/ct/rstptoweb.sh b/ct/rstptoweb.sh new file mode 100644 index 00000000..b3e9dfb5 --- /dev/null +++ b/ct/rstptoweb.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ____ _______________ __ _ ____________ + / __ \/ ___/_ __/ __ \/ /_____| | / / ____/ __ ) + / /_/ /\__ \ / / / /_/ / __/ __ \ | /| / / __/ / __ | + / _, _/___/ // / / ____/ /_/ /_/ / |/ |/ / /___/ /_/ / +/_/ |_|/____//_/ /_/ \__/\____/|__/|__/_____/_____/ + +EOF +} +header_info +echo -e "Loading..." +APP="RSTPtoWEB" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} Setup should be reachable by going to the following URL. + ${BL}http://${IP}:8083 ${CL} \n" diff --git a/ct/sabnzbd-v5.sh b/ct/sabnzbd-v5.sh deleted file mode 100644 index 0f3aab85..00000000 --- a/ct/sabnzbd-v5.sh +++ /dev/null @@ -1,432 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _____ ___ ____ __ __ - / ___// | / __ )____v5____ / /_ ____/ / - \__ \/ /| | / __ / __ \/_ / / __ \/ __ / - ___/ / ___ |/ /_/ / / / / / /_/ /_/ / /_/ / -/____/_/ |_/_____/_/ /_/ /___/_.___/\__,_/ - -EOF -} -header_info -echo -e "Loading..." -APP="SABnzbd" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating $APP" -systemctl stop sabnzbd.service -RELEASE=$(curl -s https://api.github.com/repos/sabnzbd/sabnzbd/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -tar zxvf <(curl -fsSL https://github.com/sabnzbd/sabnzbd/releases/download/$RELEASE/SABnzbd-${RELEASE}-src.tar.gz) &>/dev/null -\cp -r SABnzbd-${RELEASE}/* /opt/sabnzbd &>/dev/null -rm -rf SABnzbd-${RELEASE} -cd /opt/sabnzbd -python3 -m pip install -r requirements.txt &>/dev/null -systemctl start sabnzbd.service -msg_ok "Updated $APP" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/sabnzbd ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP}. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:7777${CL} \n" diff --git a/ct/sabnzbd.sh b/ct/sabnzbd.sh new file mode 100644 index 00000000..2f1a8c1b --- /dev/null +++ b/ct/sabnzbd.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + _____ ___ ____ __ __ + / ___// | / __ )____ ____ / /_ ____/ / + \__ \/ /| | / __ / __ \/_ / / __ \/ __ / + ___/ / ___ |/ /_/ / / / / / /_/ /_/ / /_/ / +/____/_/ |_/_____/_/ /_/ /___/_.___/\__,_/ + +EOF +} +header_info +echo -e "Loading..." +APP="SABnzbd" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/sabnzbd ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP" +systemctl stop sabnzbd.service +RELEASE=$(curl -s https://api.github.com/repos/sabnzbd/sabnzbd/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +tar zxvf <(curl -fsSL https://github.com/sabnzbd/sabnzbd/releases/download/$RELEASE/SABnzbd-${RELEASE}-src.tar.gz) &>/dev/null +\cp -r SABnzbd-${RELEASE}/* /opt/sabnzbd &>/dev/null +rm -rf SABnzbd-${RELEASE} +cd /opt/sabnzbd +python3 -m pip install -r requirements.txt &>/dev/null +systemctl start sabnzbd.service +msg_ok "Updated $APP" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:7777${CL} \n" diff --git a/ct/scrypted-v5.sh b/ct/scrypted-v5.sh deleted file mode 100644 index 25867b90..00000000 --- a/ct/scrypted-v5.sh +++ /dev/null @@ -1,442 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _____ __ __ - / ___/____________v5______ / /____ ____/ / - \__ \/ ___/ ___/ / / / __ \/ __/ _ \/ __ / - ___/ / /__/ / / /_/ / /_/ / /_/ __/ /_/ / -/____/\___/_/ \__, / .___/\__/\___/\__,_/ - /____/_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Scrypted" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/systemd/system/scrypted.service ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -if [ "$CT_TYPE" == "0" ]; then - LXC_CONFIG=/etc/pve/lxc/${CTID}.conf - cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -lxc.cgroup2.devices.allow: c 188:* rwm -lxc.cgroup2.devices.allow: c 189:* rwm -lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir -lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file -EOF -fi -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}https://${IP}:10443${CL} \n" diff --git a/ct/scrypted.sh b/ct/scrypted.sh new file mode 100644 index 00000000..c10a33be --- /dev/null +++ b/ct/scrypted.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + _____ __ __ + / ___/____________ ______ / /____ ____/ / + \__ \/ ___/ ___/ / / / __ \/ __/ _ \/ __ / + ___/ / /__/ / / /_/ / /_/ / /_/ __/ /_/ / +/____/\___/_/ \__, / .___/\__/\___/\__,_/ + /____/_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Scrypted" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/systemd/system/scrypted.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}https://${IP}:10443${CL} \n" diff --git a/ct/shinobi-v5.sh b/ct/shinobi-v5.sh deleted file mode 100644 index c2c2a019..00000000 --- a/ct/shinobi-v5.sh +++ /dev/null @@ -1,441 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _____ __ _ __ _ - / ___// /_ (_)___v5____ / /_ (_) - \__ \/ __ \/ / __ \/ __ \/ __ \/ / - ___/ / / / / / / / / /_/ / /_/ / / -/____/_/ /_/_/_/ /_/\____/_.___/_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Shinobi" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="ubuntu" -var_version="22.04" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}" - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if var_version=$(whiptail --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 4 \ - "18.04" "Bionic" OFF \ - "20.04" "Focal" OFF \ - "22.04" "Jammy" ON \ - "22.10" "Kinetic" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Ubuntu Version: ${BGN}$var_version${CL}" -else - exit-script -fi - -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating Shinobi LXC" -cd /opt/Shinobi -sh UPDATE.sh -pm2 flush -pm2 restart camera -pm2 restart cron -msg_ok "Updated Shinobi LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/Shinobi ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} Setup should be reachable by going to the following URL. - ${BL}http://${IP}:8080/super${CL} \n" diff --git a/ct/shinobi.sh b/ct/shinobi.sh new file mode 100644 index 00000000..23020d04 --- /dev/null +++ b/ct/shinobi.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/ubuntu.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + _____ __ _ __ _ + / ___// /_ (_)___ ____ / /_ (_) + \__ \/ __ \/ / __ \/ __ \/ __ \/ / + ___/ / / / / / / / / /_/ / /_/ / / +/____/_/ /_/_/_/ /_/\____/_.___/_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Shinobi" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="ubuntu" +var_version="22.04" +var_version="20.04" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="0" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/Shinobi ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating Shinobi LXC" +cd /opt/Shinobi +sh UPDATE.sh +pm2 flush +pm2 restart camera +pm2 restart cron +msg_ok "Updated Shinobi LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} Setup should be reachable by going to the following URL. + ${BL}http://${IP}:8080/super${CL} \n" diff --git a/ct/sonarr-v5.sh b/ct/sonarr-v5.sh deleted file mode 100644 index 6018fcc2..00000000 --- a/ct/sonarr-v5.sh +++ /dev/null @@ -1,426 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _____ - / ___/____ ____ ____v5__________ - \__ \/ __ \/ __ \/ __ `/ ___/ ___/ - ___/ / /_/ / / / / /_/ / / / / -/____/\____/_/ /_/\__,_/_/ /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Sonarr" -var_disk="4" -var_cpu="2" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating $APP LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated $APP LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/apt/sources.list.d/sonarr.list ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8989${CL} \n" diff --git a/ct/sonarr.sh b/ct/sonarr.sh new file mode 100644 index 00000000..e8152274 --- /dev/null +++ b/ct/sonarr.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + _____ + / ___/____ ____ ____ __________ + \__ \/ __ \/ __ \/ __ `/ ___/ ___/ + ___/ / /_/ / / / / /_/ / / / / +/____/\____/_/ /_/\__,_/_/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Sonarr" +var_disk="4" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/apt/sources.list.d/sonarr.list ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8989${CL} \n" diff --git a/ct/syncthing-v5.sh b/ct/syncthing-v5.sh deleted file mode 100644 index 0f88a88d..00000000 --- a/ct/syncthing-v5.sh +++ /dev/null @@ -1,428 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _____ __ __ _ - / ___/__ ______v5_____/ /_/ /_ (_)___ ____ _ - \__ \/ / / / __ \/ ___/ __/ __ \/ / __ \/ __ `/ - ___/ / /_/ / / / / /__/ /_/ / / / / / / / /_/ / -/____/\__, /_/ /_/\___/\__/_/ /_/_/_/ /_/\__, / - /____/ /____/ - -EOF -} -header_info -echo -e "Loading..." -APP="Syncthing" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/apt/sources.list.d/syncthing.list ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8384 ${CL} \n" diff --git a/ct/syncthing.sh b/ct/syncthing.sh new file mode 100644 index 00000000..e26dbd56 --- /dev/null +++ b/ct/syncthing.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + _____ __ __ _ + / ___/__ ______ _____/ /_/ /_ (_)___ ____ _ + \__ \/ / / / __ \/ ___/ __/ __ \/ / __ \/ __ `/ + ___/ / /_/ / / / / /__/ /_/ / / / / / / / /_/ / +/____/\__, /_/ /_/\___/\__/_/ /_/_/_/ /_/\__, / + /____/ /____/ + +EOF +} +header_info +echo -e "Loading..." +APP="Syncthing" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/apt/sources.list.d/syncthing.list ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8384 ${CL} \n" diff --git a/ct/tdarr-v5.sh b/ct/tdarr-v5.sh deleted file mode 100644 index 4a879ece..00000000 --- a/ct/tdarr-v5.sh +++ /dev/null @@ -1,426 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ______ __ - /_ __/___/ /___v5__________ - / / / __ / __ `/ ___/ ___/ - / / / /_/ / /_/ / / / / -/_/ \__,_/\__,_/_/ /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Tdarr" -var_disk="4" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating $APP LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated $APP LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/tdarr ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8265${CL} \n" diff --git a/ct/tdarr.sh b/ct/tdarr.sh new file mode 100644 index 00000000..ba2f9149 --- /dev/null +++ b/ct/tdarr.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + ______ __ + /_ __/___/ /___ __________ + / / / __ / __ `/ ___/ ___/ + / / / /_/ / /_/ / / / / +/_/ \__,_/\__,_/_/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Tdarr" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/tdarr ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8265${CL} \n" diff --git a/ct/technitiumdns-v5.sh b/ct/technitiumdns-v5.sh deleted file mode 100644 index 44b424f3..00000000 --- a/ct/technitiumdns-v5.sh +++ /dev/null @@ -1,436 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ______ __ _ __ _ ____ _ _______ - /_ __/__ _____/ /_ ____ (_) /_(_)_ ______ ___ v5 / __ \/ | / / ___/ - / / / _ \/ ___/ __ \/ __ \/ / __/ / / / / __ __ \ / / / / |/ /\__ \ - / / / __/ /__/ / / / / / / / /_/ / /_/ / / / / / / / /_/ / /| /___/ / -/_/ \___/\___/_/ /_/_/ /_/_/\__/_/\__,_/_/ /_/ /_/ /_____/_/ |_//____/ - -EOF -} -header_info -echo -e "Loading..." -APP="Technitium DNS" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP}" - -if ! dpkg -s aspnetcore-runtime-7.0 > /dev/null 2>&1; then - wget -q https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb - dpkg -i packages-microsoft-prod.deb - apt-get update - apt-get install -y aspnetcore-runtime-7.0 - rm packages-microsoft-prod.deb -fi -wget -q https://download.technitium.com/dns/DnsServerPortable.tar.gz -tar -zxf DnsServerPortable.tar.gz -C /etc/dns/ &>/dev/null -rm -rf DnsServerPortable.tar.gz -systemctl restart dns.service -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /etc/dns ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:5380${CL} \n" diff --git a/ct/technitiumdns.sh b/ct/technitiumdns.sh new file mode 100644 index 00000000..fbe2c925 --- /dev/null +++ b/ct/technitiumdns.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + ______ __ _ __ _ ____ _ _______ + /_ __/__ _____/ /_ ____ (_) /_(_)_ ______ ___ / __ \/ | / / ___/ + / / / _ \/ ___/ __ \/ __ \/ / __/ / / / / __ __ \ / / / / |/ /\__ \ + / / / __/ /__/ / / / / / / / /_/ / /_/ / / / / / / / /_/ / /| /___/ / +/_/ \___/\___/_/ /_/_/ /_/_/\__/_/\__,_/_/ /_/ /_/ /_____/_/ |_//____/ + +EOF +} +header_info +echo -e "Loading..." +APP="Technitium DNS" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /etc/dns ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP}" + +if ! dpkg -s aspnetcore-runtime-7.0 > /dev/null 2>&1; then + wget -q https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb + dpkg -i packages-microsoft-prod.deb + apt-get update + apt-get install -y aspnetcore-runtime-7.0 + rm packages-microsoft-prod.deb +fi +wget -q https://download.technitium.com/dns/DnsServerPortable.tar.gz +tar -zxf DnsServerPortable.tar.gz -C /etc/dns/ &>/dev/null +rm -rf DnsServerPortable.tar.gz +systemctl restart dns.service +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:5380${CL} \n" diff --git a/ct/transmission-v5.sh b/ct/transmission-v5.sh deleted file mode 100644 index 5fb1e37d..00000000 --- a/ct/transmission-v5.sh +++ /dev/null @@ -1,426 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ______ _ _ - /_ __/________ _____v5_________ ___ (_)_________(_)___ ____ - / / / ___/ __ `/ __ \/ ___/ __ `__ \/ / ___/ ___/ / __ \/ __ \ - / / / / / /_/ / / / (__ ) / / / / / (__ |__ ) / /_/ / / / / -/_/ /_/ \__,_/_/ /_/____/_/ /_/ /_/_/____/____/_/\____/_/ /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Transmission" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/transmission-daemon/settings.json ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:9091/transmission${CL} \n" diff --git a/ct/transmission.sh b/ct/transmission.sh new file mode 100644 index 00000000..86d45292 --- /dev/null +++ b/ct/transmission.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + ______ _ _ + /_ __/________ _____ _________ ___ (_)_________(_)___ ____ + / / / ___/ __ `/ __ \/ ___/ __ `__ \/ / ___/ ___/ / __ \/ __ \ + / / / / / /_/ / / / (__ ) / / / / / (__ |__ ) / /_/ / / / / +/_/ /_/ \__,_/_/ /_/____/_/ /_/ /_/_/____/____/_/\____/_/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Transmission" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/transmission-daemon/settings.json ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:9091/transmission${CL} \n" diff --git a/ct/trilium-v5.sh b/ct/trilium-v5.sh deleted file mode 100644 index 3c447d88..00000000 --- a/ct/trilium-v5.sh +++ /dev/null @@ -1,446 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - ______ _ ___ - /_ __/_v5_(_) (_)_ ______ ___ - / / / ___/ / / / / / / __ `__ \ - / / / / / / / / /_/ / / / / / / -/_/ /_/ /_/_/_/\__,_/_/ /_/ /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Trilium" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -RELEASE=$(curl -s https://api.github.com/repos/zadam/trilium/releases/latest | - grep "tag_name" | - awk '{print substr($2, 3, length($2)-4) }') - -msg_info "Stopping ${APP}" -systemctl stop trilium.service -sleep 1 -msg_ok "Stopped ${APP}" - -msg_info "Updating to v${RELEASE}" -wget -q https://github.com/zadam/trilium/releases/download/v$RELEASE/trilium-linux-x64-server-$RELEASE.tar.xz -tar -xvf trilium-linux-x64-server-$RELEASE.tar.xz &>/dev/null -cp -r trilium-linux-x64-server/* /opt/trilium/ -msg_ok "Updated to v${RELEASE}" - -msg_info "Cleaning up" -rm -rf trilium-linux-x64-server-$RELEASE.tar.xz trilium-linux-x64-server -msg_ok "Cleaned" - -msg_info "Starting ${APP}" -systemctl start trilium.service -sleep 1 -msg_ok "Started ${APP}" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/trilium ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8080${CL} \n" diff --git a/ct/trilium.sh b/ct/trilium.sh new file mode 100644 index 00000000..dd2b2578 --- /dev/null +++ b/ct/trilium.sh @@ -0,0 +1,90 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + ______ _ ___ + /_ __/____(_) (_)_ ______ ___ + / / / ___/ / / / / / / __ `__ \ + / / / / / / / / /_/ / / / / / / +/_/ /_/ /_/_/_/\__,_/_/ /_/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Trilium" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/trilium ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +RELEASE=$(curl -s https://api.github.com/repos/zadam/trilium/releases/latest | + grep "tag_name" | + awk '{print substr($2, 3, length($2)-4) }') + +msg_info "Stopping ${APP}" +systemctl stop trilium.service +sleep 1 +msg_ok "Stopped ${APP}" + +msg_info "Updating to v${RELEASE}" +wget -q https://github.com/zadam/trilium/releases/download/v$RELEASE/trilium-linux-x64-server-$RELEASE.tar.xz +tar -xvf trilium-linux-x64-server-$RELEASE.tar.xz &>/dev/null +cp -r trilium-linux-x64-server/* /opt/trilium/ +msg_ok "Updated to v${RELEASE}" + +msg_info "Cleaning up" +rm -rf trilium-linux-x64-server-$RELEASE.tar.xz trilium-linux-x64-server +msg_ok "Cleaned" + +msg_info "Starting ${APP}" +systemctl start trilium.service +sleep 1 +msg_ok "Started ${APP}" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8080${CL} \n" diff --git a/ct/ubuntu-v5.sh b/ct/ubuntu-v5.sh deleted file mode 100644 index 79bcc700..00000000 --- a/ct/ubuntu-v5.sh +++ /dev/null @@ -1,431 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ ____ __ - / / / / /_v5__ ______ / /___ __ - / / / / __ \/ / / / __ \/ __/ / / / -/ /_/ / /_/ / /_/ / / / / /_/ /_/ / -\____/_.___/\__,_/_/ /_/\__/\__,_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Ubuntu" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="ubuntu" -var_version="22.04" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}" - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if var_version=$(whiptail --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 4 \ - "18.04" "Bionic" OFF \ - "20.04" "Focal" OFF \ - "22.04" "Jammy" ON \ - "22.10" "Kinetic" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Ubuntu Version: ${BGN}$var_version${CL}" -else - exit-script -fi - -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} ${var_version} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" diff --git a/ct/ubuntu.sh b/ct/ubuntu.sh new file mode 100644 index 00000000..9fce57ed --- /dev/null +++ b/ct/ubuntu.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/ubuntu.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + __ ____ __ + / / / / /_ __ ______ / /___ __ + / / / / __ \/ / / / __ \/ __/ / / / +/ /_/ / /_/ / /_/ / / / / /_/ /_/ / +\____/_.___/\__,_/_/ /_/\__/\__,_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Ubuntu" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="ubuntu" +var_version="22.04" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="0" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/umbrel-v5.sh b/ct/umbrel-v5.sh deleted file mode 100644 index ee339e2b..00000000 --- a/ct/umbrel-v5.sh +++ /dev/null @@ -1,452 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ __ __ __ - / / / /___ ___v5/ /_ ________ / / - / / / / __ `__ \/ __ \/ ___/ _ \/ / -/ /_/ / / / / / / /_/ / / / __/ / -\____/_/ /_/ /_/_.___/_/ \___/_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Umbrel" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Fuse Overlayfs (ZFS): ${BGN}No${CL}" - FUSE="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "FUSE OVERLAYFS" --yesno "(ZFS) Enable Fuse Overlayfs?" 10 58); then - FUSE="yes" -else - FUSE="no" -fi - echo -e "${DGN}Enable Fuse Overlayfs (ZFS): ${BGN}$FUSE${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /root/umbrel ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$FUSE" == "yes" ]; then -FEATURES="fuse=1,keyctl=1,nesting=1" -else -FEATURES="keyctl=1,nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export ST=$FUSE -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$CT_TYPE" == "0" ]; then -cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: c 188:* rwm -lxc.cgroup2.devices.allow: c 189:* rwm -lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir -lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file -EOF -fi -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL (reboot is required before app installs). - ${BL}http://${IP} ${CL} \n" diff --git a/ct/umbrel.sh b/ct/umbrel.sh new file mode 100644 index 00000000..796693ce --- /dev/null +++ b/ct/umbrel.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/docker.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + __ __ __ __ + / / / /___ ___ / /_ ________ / / + / / / / __ `__ \/ __ \/ ___/ _ \/ / +/ /_/ / / / / / / /_/ / / / __/ / +\____/_/ /_/ /_/_.___/_/ \___/_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Umbrel" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + FUSE="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL (reboot is required before apps install). + ${BL}http://${IP} ${CL} \n" diff --git a/ct/unifi-v5.sh b/ct/unifi-v5.sh deleted file mode 100644 index 571c30fb..00000000 --- a/ct/unifi-v5.sh +++ /dev/null @@ -1,427 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ __ _ _____ - / / / /_v5 (_) __(_) - / / / / __ \/ / /_/ / -/ /_/ / / / / / __/ / -\____/_/ /_/_/_/ /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Unifi" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP}" -wget -qL https://get.glennr.nl/unifi/update/unifi-update.sh -bash unifi-update.sh -msg_ok "Updated ${APP}" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /usr/lib/unifi ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP}${CL} should be reachable by going to the following URL. - ${BL}https://${IP}:8443${CL} \n" diff --git a/ct/unifi.sh b/ct/unifi.sh new file mode 100644 index 00000000..c5993242 --- /dev/null +++ b/ct/unifi.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + __ __ _ _____ + / / / /__ (_) __(_) + / / / / __ \/ / /_/ / +/ /_/ / / / / / __/ / +\____/_/ /_/_/_/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Unifi" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /usr/lib/unifi ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP}" +wget -qL https://get.glennr.nl/unifi/update/unifi-update.sh +bash unifi-update.sh +msg_ok "Updated ${APP}" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP}${CL} should be reachable by going to the following URL. + ${BL}https://${IP}:8443${CL} \n" diff --git a/ct/uptimekuma-v5.sh b/ct/uptimekuma-v5.sh deleted file mode 100644 index 09623497..00000000 --- a/ct/uptimekuma-v5.sh +++ /dev/null @@ -1,444 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - __ __ __ _ __ __ - / / / /___ / /_(_)___ ___ ___ v5 / //_/_ ______ ___ ____ _ - / / / / __ \/ __/ / __ __ \/ _ \ / ,< / / / / __ __ \/ __ / -/ /_/ / /_/ / /_/ / / / / / / __/ / /| / /_/ / / / / / / /_/ / -\____/ .___/\__/_/_/ /_/ /_/\___/ /_/ |_\__,_/_/ /_/ /_/\__,_/ - /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Uptime Kuma" -var_disk="4" -var_cpu="1" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -LATEST=$(curl -sL https://api.github.com/repos/louislam/uptime-kuma/releases/latest | grep '"tag_name":' | cut -d'"' -f4) -msg_info "Stopping ${APP}" -sudo systemctl stop uptime-kuma &>/dev/null -msg_ok "Stopped ${APP}" - -cd /opt/uptime-kuma - -msg_info "Pulling ${APP} ${LATEST}" -git fetch --all &>/dev/null -git checkout $LATEST --force &>/dev/null -msg_ok "Pulled ${APP} ${LATEST}" - -msg_info "Updating ${APP} to ${LATEST}" -npm install --production &>/dev/null -npm run download-dist &>/dev/null -msg_ok "Updated ${APP}" - -msg_info "Starting ${APP}" -sudo systemctl start uptime-kuma &>/dev/null -msg_ok "Started ${APP}" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/uptime-kuma ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:3001${CL} \n" diff --git a/ct/uptimekuma.sh b/ct/uptimekuma.sh new file mode 100644 index 00000000..86644bf9 --- /dev/null +++ b/ct/uptimekuma.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + __ __ __ _ __ __ + / / / /___ / /_(_)___ ___ ___ / //_/_ ______ ___ ____ _ + / / / / __ \/ __/ / __ __ \/ _ \ / ,< / / / / __ __ \/ __ / +/ /_/ / /_/ / /_/ / / / / / / __/ / /| / /_/ / / / / / / /_/ / +\____/ .___/\__/_/_/ /_/ /_/\___/ /_/ |_\__,_/_/ /_/ /_/\__,_/ + /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Uptime Kuma" +var_disk="4" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/uptime-kuma ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +LATEST=$(curl -sL https://api.github.com/repos/louislam/uptime-kuma/releases/latest | grep '"tag_name":' | cut -d'"' -f4) +msg_info "Stopping ${APP}" +sudo systemctl stop uptime-kuma &>/dev/null +msg_ok "Stopped ${APP}" + +cd /opt/uptime-kuma + +msg_info "Pulling ${APP} ${LATEST}" +git fetch --all &>/dev/null +git checkout $LATEST --force &>/dev/null +msg_ok "Pulled ${APP} ${LATEST}" + +msg_info "Updating ${APP} to ${LATEST}" +npm install --production &>/dev/null +npm run download-dist &>/dev/null +msg_ok "Updated ${APP}" + +msg_info "Starting ${APP}" +sudo systemctl start uptime-kuma &>/dev/null +msg_ok "Started ${APP}" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:3001${CL} \n" diff --git a/ct/vaultwarden-v5.sh b/ct/vaultwarden-v5.sh deleted file mode 100644 index 88de3398..00000000 --- a/ct/vaultwarden-v5.sh +++ /dev/null @@ -1,498 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _ __ ____ _ __ __ -| | / /___ ___v5__/ / /| | / /___ __________/ /__ ____ -| | / / __ `/ / / / / __/ | /| / / __ `/ ___/ __ / _ \/ __ \ -| |/ / /_/ / /_/ / / /_ | |/ |/ / /_/ / / / /_/ / __/ / / / -|___/\__,_/\__,_/_/\__/ |__/|__/\__,_/_/ \__,_/\___/_/ /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Vaultwarden" -var_disk="6" -var_cpu="4" -var_ram="4096" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -VAULT=$(curl -s https://api.github.com/repos/dani-garcia/vaultwarden/releases/latest | - grep "tag_name" | - awk '{print substr($2, 2, length($2)-3) }') -WVRELEASE=$(curl -s https://api.github.com/repos/dani-garcia/bw_web_builds/releases/latest | - grep "tag_name" | - awk '{print substr($2, 2, length($2)-3) }') - -UPD=$(whiptail --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 3 \ - "1" "VaultWarden $VAULT" ON \ - "2" "Web-Vault $WVRELEASE" OFF \ - "3" "Show Admin Token" OFF \ - 3>&1 1>&2 2>&3) - -header_info -if [ "$UPD" == "1" ]; then -echo -e "\n ⚠️ Ensure you set 4vCPU & 4096MiB RAM minimum!!! \n" -msg_info "Stopping Vaultwarden" -systemctl stop vaultwarden.service -msg_ok "Stopped Vaultwarden" - -msg_info "Updating VaultWarden to $VAULT (Patience)" -cd ~ && rm -rf vaultwarden -git clone https://github.com/dani-garcia/vaultwarden &>/dev/null -cd vaultwarden -cargo build --features "sqlite,mysql,postgresql" --release &>/dev/null -DIR=/usr/bin/vaultwarden - if [ -d "$DIR" ]; then - cp target/release/vaultwarden /usr/bin/ - else - cp target/release/vaultwarden /opt/vaultwarden/bin/ - fi -msg_ok "Updated VaultWarden" - -msg_info "Cleaning up" -cd ~ && rm -rf vaultwarden -msg_ok "Cleaned" - -msg_info "Starting Vaultwarden" -systemctl start vaultwarden.service -msg_ok "Started Vaultwarden" - -msg_ok "$VAULT Update Successful" -echo -e "\n ⚠️ Ensure you set resources back to normal settings \n" -exit; -fi -if [ "$UPD" == "2" ]; then -msg_info "Stopping Vaultwarden" -systemctl stop vaultwarden.service -msg_ok "Stopped Vaultwarden" - -msg_info "Updating Web-Vault to $WVRELEASE" -curl -fsSLO https://github.com/dani-garcia/bw_web_builds/releases/download/$WVRELEASE/bw_web_$WVRELEASE.tar.gz &>/dev/null -tar -zxf bw_web_$WVRELEASE.tar.gz -C /opt/vaultwarden/ &>/dev/null -msg_ok "Updated Web-Vault" - -msg_info "Cleaning up" -rm bw_web_$WVRELEASE.tar.gz -msg_ok "Cleaned" - -msg_info "Starting Vaultwarden" -systemctl start vaultwarden.service -msg_ok "Started Vaultwarden" -msg_ok "$WVRELEASE Update Successful" -exit; -fi -if [ "$UPD" == "3" ]; then -DIR=/usr/bin/vaultwarden - if [ -d "$DIR" ]; then - cat /etc/vaultwarden.env | grep "ADMIN_TOKEN" - else - cat /opt/vaultwarden/.env | grep "ADMIN_TOKEN" - fi -exit -fi -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/systemd/system/vaultwarden.service ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_info "Setting Container to Normal Resources" -pct set $CTID -memory 512 -pct set $CTID -cores 1 -msg_ok "Set Container to Normal Resources" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8000${CL} \n" diff --git a/ct/vaultwarden.sh b/ct/vaultwarden.sh new file mode 100644 index 00000000..3a9aed9a --- /dev/null +++ b/ct/vaultwarden.sh @@ -0,0 +1,145 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + + _ __ ____ _ __ __ +| | / /___ ___ __/ / /| | / /___ __________/ /__ ____ +| | / / __ `/ / / / / __/ | /| / / __ `/ ___/ __ / _ \/ __ \ +| |/ / /_/ / /_/ / / /_ | |/ |/ / /_/ / / / /_/ / __/ / / / +|___/\__,_/\__,_/_/\__/ |__/|__/\__,_/_/ \__,_/\___/_/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Vaultwarden" +var_disk="6" +var_cpu="4" +var_ram="4096" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + if [[ ! -f /etc/systemd/system/vaultwarden.service ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + VAULT=$(curl -s https://api.github.com/repos/dani-garcia/vaultwarden/releases/latest | + grep "tag_name" | + awk '{print substr($2, 2, length($2)-3) }') + WVRELEASE=$(curl -s https://api.github.com/repos/dani-garcia/bw_web_builds/releases/latest | + grep "tag_name" | + awk '{print substr($2, 2, length($2)-3) }') + + UPD=$(whiptail --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 3 \ + "1" "VaultWarden $VAULT" ON \ + "2" "Web-Vault $WVRELEASE" OFF \ + "3" "Show Admin Token" OFF \ + 3>&1 1>&2 2>&3) + + header_info + if [ "$UPD" == "1" ]; then + echo -e "\n ⚠️ Ensure you set 4vCPU & 4096MiB RAM minimum!!! \n" + msg_info "Stopping Vaultwarden" + systemctl stop vaultwarden.service + msg_ok "Stopped Vaultwarden" + + msg_info "Updating VaultWarden to $VAULT (Patience)" + cd ~ && rm -rf vaultwarden + git clone https://github.com/dani-garcia/vaultwarden &>/dev/null + cd vaultwarden + cargo build --features "sqlite,mysql,postgresql" --release &>/dev/null + DIR=/usr/bin/vaultwarden + if [ -d "$DIR" ]; then + cp target/release/vaultwarden /usr/bin/ + else + cp target/release/vaultwarden /opt/vaultwarden/bin/ + fi + msg_ok "Updated VaultWarden" + + msg_info "Cleaning up" + cd ~ && rm -rf vaultwarden + msg_ok "Cleaned" + + msg_info "Starting Vaultwarden" + systemctl start vaultwarden.service + msg_ok "Started Vaultwarden" + + msg_ok "$VAULT Update Successful" + echo -e "\n ⚠️ Ensure you set resources back to normal settings \n" + exit + fi + if [ "$UPD" == "2" ]; then + msg_info "Stopping Vaultwarden" + systemctl stop vaultwarden.service + msg_ok "Stopped Vaultwarden" + + msg_info "Updating Web-Vault to $WVRELEASE" + curl -fsSLO https://github.com/dani-garcia/bw_web_builds/releases/download/$WVRELEASE/bw_web_$WVRELEASE.tar.gz &>/dev/null + tar -zxf bw_web_$WVRELEASE.tar.gz -C /opt/vaultwarden/ &>/dev/null + msg_ok "Updated Web-Vault" + + msg_info "Cleaning up" + rm bw_web_$WVRELEASE.tar.gz + msg_ok "Cleaned" + + msg_info "Starting Vaultwarden" + systemctl start vaultwarden.service + msg_ok "Started Vaultwarden" + msg_ok "$WVRELEASE Update Successful" + exit + fi + if [ "$UPD" == "3" ]; then + DIR=/usr/bin/vaultwarden + if [ -d "$DIR" ]; then + cat /etc/vaultwarden.env | grep "ADMIN_TOKEN" + else + cat /opt/vaultwarden/.env | grep "ADMIN_TOKEN" + fi + exit + fi +} + +start +build_container +description + +msg_info "Setting Container to Normal Resources" +pct set $CTID -memory 512 +pct set $CTID -cores 1 +msg_ok "Set Container to Normal Resources" +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8000${CL} \n" diff --git a/ct/whisparr-v5.sh b/ct/whisparr-v5.sh deleted file mode 100644 index 21b45677..00000000 --- a/ct/whisparr-v5.sh +++ /dev/null @@ -1,427 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _ ____ _ -| | / / /_ (_)________ ____v5__________ -| | /| / / __ \/ / ___/ __ \/ __ `/ ___/ ___/ -| |/ |/ / / / / (__ ) /_/ / /_/ / / / / -|__/|__/_/ /_/_/____/ .___/\__,_/_/ /_/ - /_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Whisparr" -var_disk="4" -var_cpu="2" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating $APP LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated $APP LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /var/lib/whisparr ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:6969${CL} \n" diff --git a/ct/whisparr.sh b/ct/whisparr.sh new file mode 100644 index 00000000..7c3adbe4 --- /dev/null +++ b/ct/whisparr.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + _ ____ _ +| | / / /_ (_)________ ____ __________ +| | /| / / __ \/ / ___/ __ \/ __ `/ ___/ ___/ +| |/ |/ / / / / (__ ) /_/ / /_/ / / / / +|__/|__/_/ /_/_/____/ .___/\__,_/_/ /_/ + /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Whisparr" +var_disk="4" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var/lib/whisparr ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:6969${CL} \n" diff --git a/ct/whoogle-v5.sh b/ct/whoogle-v5.sh deleted file mode 100644 index ec26eadb..00000000 --- a/ct/whoogle-v5.sh +++ /dev/null @@ -1,426 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _ ____ ______ ____ ________ ______ -| | v5 / / / / / __ \/ __ \/ ____/ / / ____/ -| | /| / / /_/ / / / / / / / / __/ / / __/ -| |/ |/ / __ / /_/ / /_/ / /_/ / /___/ /___ -|__/|__/_/ /_/\____/\____/\____/_____/_____/ - -EOF -} -header_info -echo -e "Loading..." -APP="Whoogle" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating ${APP} LXC" -pip3 install whoogle-search --upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /usr/local/bin/whoogle-search ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:5000${CL} \n" diff --git a/ct/whoogle.sh b/ct/whoogle.sh new file mode 100644 index 00000000..e1bf927c --- /dev/null +++ b/ct/whoogle.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + _ ____ ______ ____ ________ ______ +| | / / / / / __ \/ __ \/ ____/ / / ____/ +| | /| / / /_/ / / / / / / / / __/ / / __/ +| |/ |/ / __ / /_/ / /_/ / /_/ / /___/ /___ +|__/|__/_/ /_/\____/\____/\____/_____/_____/ + +EOF +} +header_info +echo -e "Loading..." +APP="Whoogle" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /usr/local/bin/whoogle-search ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +pip3 install whoogle-search --upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:5000${CL} \n" diff --git a/ct/wikijs-v5.sh b/ct/wikijs-v5.sh deleted file mode 100644 index 3848eb4c..00000000 --- a/ct/wikijs-v5.sh +++ /dev/null @@ -1,449 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _ ___ __ _ _ -| | v5 / (_) /__(_) (_)____ -| | /| / / / //_/ / / / ___/ -| |/ |/ / / ,< / / / (__ ) -|__/|__/_/_/|_/_(_)_/ /____/ - /___/ - -EOF -} -header_info -echo -e "Loading..." -APP="Wikijs" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Stopping ${APP}" -systemctl stop wikijs -msg_ok "Stopped ${APP}" - -msg_info "Backing up Data" -mkdir -p data-backup -cp -R /opt/wikijs/{db.sqlite,config.yml,/data} ~/data-backup -msg_ok "Backed up Data" - -msg_info "Updating ${APP}" -rm -rf /opt/wikijs/* -cd /opt/wikijs -wget -q https://github.com/Requarks/wiki/releases/latest/download/wiki-js.tar.gz -tar xzf wiki-js.tar.gz -msg_ok "Updated ${APP}" - -msg_info "Restoring Data" -cp -R ~/data-backup/* /opt/wikijs -rm -rf ~/data-backup -npm rebuild sqlite3 &>/dev/null -msg_ok "Restored Data" - -msg_info "Starting ${APP}" -systemctl start wikijs -msg_ok "Started ${APP}" -msg_ok "Update Successfull" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/wikijs ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:3000${CL} \n" diff --git a/ct/wikijs.sh b/ct/wikijs.sh new file mode 100644 index 00000000..377eeba0 --- /dev/null +++ b/ct/wikijs.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + _ ___ __ _ _ +| | / (_) /__(_) (_)____ +| | /| / / / //_/ / / / ___/ +| |/ |/ / / ,< / / / (__ ) +|__/|__/_/_/|_/_(_)_/ /____/ + /___/ + +EOF +} +header_info +echo -e "Loading..." +APP="Wikijs" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/wikijs ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Stopping ${APP}" +systemctl stop wikijs +msg_ok "Stopped ${APP}" + +msg_info "Backing up Data" +mkdir -p data-backup +cp -R /opt/wikijs/{db.sqlite,config.yml,/data} ~/data-backup +msg_ok "Backed up Data" + +msg_info "Updating ${APP}" +rm -rf /opt/wikijs/* +cd /opt/wikijs +wget -q https://github.com/Requarks/wiki/releases/latest/download/wiki-js.tar.gz +tar xzf wiki-js.tar.gz +msg_ok "Updated ${APP}" + +msg_info "Restoring Data" +cp -R ~/data-backup/* /opt/wikijs +rm -rf ~/data-backup +npm rebuild sqlite3 &>/dev/null +msg_ok "Restored Data" + +msg_info "Starting ${APP}" +systemctl start wikijs +msg_ok "Started ${APP}" +msg_ok "Update Successfull" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:3000${CL} \n" diff --git a/ct/wireguard-v5.sh b/ct/wireguard-v5.sh deleted file mode 100644 index 8fce1701..00000000 --- a/ct/wireguard-v5.sh +++ /dev/null @@ -1,479 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _ ___ ______ __ -| | / (_)_______ / ____/_ ______ __________/ / -| | /| / / / ___/ _ \/ / __/ / / / __ `/ ___/ __ / -| |/ |/ / / / / __/ /_/ / /_/ / /_/ / / / /_/ / -|__/|__/_/_/ v5\___/\____/\__,_/\__,_/_/ \__,_/ - -EOF -} -header_info -echo -e "Loading..." -APP="Wireguard" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -UPD=$(whiptail --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 2 \ - "1" "Update ${APP} LXC" ON \ - "2" "Install WGDashboard" OFF \ - 3>&1 1>&2 2>&3) -header_info -if [ "$UPD" == "1" ]; then -msg_info "Updating ${APP} LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated ${APP} LXC" -msg_ok "Update Successfull" -exit -fi -if [ "$UPD" == "2" ]; then - if [[ -f /etc/systemd/system/wg-dashboard.service ]]; then - msg_error "Existing WGDashboard Installation Found!"; - exit - fi -IP=$(hostname -I | awk '{print $1}') -msg_info "Installing Python3-pip" -apt-get install -y python3-pip &>/dev/null -pip install flask &>/dev/null -pip install ifcfg &>/dev/null -pip install flask_qrcode &>/dev/null -pip install icmplib &>/dev/null -msg_ok "Installed Python3-pip" - -msg_info "Installing WGDashboard" -WGDREL=$(curl -s https://api.github.com/repos/donaldzou/WGDashboard/releases/latest | - grep "tag_name" | - awk '{print substr($2, 2, length($2)-3) }') - -git clone -b ${WGDREL} https://github.com/donaldzou/WGDashboard.git /etc/wgdashboard &>/dev/null -cd /etc/wgdashboard/src -sudo chmod u+x wgd.sh -sudo ./wgd.sh install &>/dev/null -sudo chmod -R 755 /etc/wireguard -msg_ok "Installed WGDashboard" - -msg_info "Creating Service" -service_path="/etc/systemd/system/wg-dashboard.service" -echo "[Unit] -After=systemd-networkd.service - -[Service] -WorkingDirectory=/etc/wgdashboard/src -ExecStart=/usr/bin/python3 /etc/wgdashboard/src/dashboard.py -Restart=always - - -[Install] -WantedBy=default.target" >$service_path -chmod 664 /etc/systemd/system/wg-dashboard.service -systemctl daemon-reload -systemctl enable wg-dashboard.service &>/dev/null -systemctl start wg-dashboard.service &>/dev/null -msg_ok "Created Service" -echo -e "WGDashboard should be reachable by going to the following URL. - ${BL}http://${IP}:10086${CL} admin|admin \n" -exit -fi -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /etc/pivpn/wireguard ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" diff --git a/ct/wireguard.sh b/ct/wireguard.sh new file mode 100644 index 00000000..cfd017be --- /dev/null +++ b/ct/wireguard.sh @@ -0,0 +1,123 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + + _ ___ ______ __ +| | / (_)_______ / ____/_ ______ __________/ / +| | /| / / / ___/ _ \/ / __/ / / / __ `/ ___/ __ / +| |/ |/ / / / / __/ /_/ / /_/ / /_/ / / / /_/ / +|__/|__/_/_/ \___/\____/\__,_/\__,_/_/ \__,_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Wireguard" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +if [[ ! -d /etc/pivpn/wireguard ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +UPD=$(whiptail --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 2 \ + "1" "Update ${APP} LXC" ON \ + "2" "Install WGDashboard" OFF \ + 3>&1 1>&2 2>&3) +header_info +if [ "$UPD" == "1" ]; then +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated ${APP} LXC" +msg_ok "Update Successfull" +exit +fi +if [ "$UPD" == "2" ]; then + if [[ -f /etc/systemd/system/wg-dashboard.service ]]; then + msg_error "Existing WGDashboard Installation Found!"; + exit + fi +IP=$(hostname -I | awk '{print $1}') +msg_info "Installing Python3-pip" +apt-get install -y python3-pip &>/dev/null +pip install flask &>/dev/null +pip install ifcfg &>/dev/null +pip install flask_qrcode &>/dev/null +pip install icmplib &>/dev/null +msg_ok "Installed Python3-pip" + +msg_info "Installing WGDashboard" +WGDREL=$(curl -s https://api.github.com/repos/donaldzou/WGDashboard/releases/latest | + grep "tag_name" | + awk '{print substr($2, 2, length($2)-3) }') + +git clone -b ${WGDREL} https://github.com/donaldzou/WGDashboard.git /etc/wgdashboard &>/dev/null +cd /etc/wgdashboard/src +sudo chmod u+x wgd.sh +sudo ./wgd.sh install &>/dev/null +sudo chmod -R 755 /etc/wireguard +msg_ok "Installed WGDashboard" + +msg_info "Creating Service" +service_path="/etc/systemd/system/wg-dashboard.service" +echo "[Unit] +After=systemd-networkd.service + +[Service] +WorkingDirectory=/etc/wgdashboard/src +ExecStart=/usr/bin/python3 /etc/wgdashboard/src/dashboard.py +Restart=always + + +[Install] +WantedBy=default.target" >$service_path +chmod 664 /etc/systemd/system/wg-dashboard.service +systemctl daemon-reload +systemctl enable wg-dashboard.service &>/dev/null +systemctl start wg-dashboard.service &>/dev/null +msg_ok "Created Service" +echo -e "WGDashboard should be reachable by going to the following URL. + ${BL}http://${IP}:10086${CL} admin|admin \n" +exit +fi +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/yunohost-v5.sh b/ct/yunohost-v5.sh deleted file mode 100644 index 6d324d78..00000000 --- a/ct/yunohost-v5.sh +++ /dev/null @@ -1,426 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - -__ __ __ __ __ -\ \/ /_ ______v5____ / / / /___ _____/ /_ - \ / / / / __ \/ __ \/ /_/ / __ \/ ___/ __/ - / / /_/ / / / / /_/ / __ / /_/ (__ ) /_ -/_/\__,_/_/ /_/\____/_/ /_/\____/____/\__/ - -EOF -} -header_info -echo -e "Loading..." -APP="YunoHost" -var_disk="20" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" ON \ - "0" "Privileged" OFF \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -msg_info "Updating $APP LXC" -apt-get update &>/dev/null -apt-get -y upgrade &>/dev/null -msg_ok "Updated $APP LXC" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -f /etc/apt/trusted.gpg.d/php.gpg ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}/ ${CL}" diff --git a/ct/yunohost.sh b/ct/yunohost.sh new file mode 100644 index 00000000..931ad446 --- /dev/null +++ b/ct/yunohost.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + +__ __ __ __ __ +\ \/ /_ ______ ____ / / / /___ _____/ /_ + \ / / / / __ \/ __ \/ /_/ / __ \/ ___/ __/ + / / /_/ / / / / /_/ / __ / /_/ (__ ) /_ +/_/\__,_/_/ /_/\____/_/ /_/\____/____/\__/ + +EOF +} +header_info +echo -e "Loading..." +APP="YunoHost" +var_disk="20" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/apt/trusted.gpg.d/php.gpg ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated $APP LXC" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}/ ${CL}" diff --git a/ct/zigbee2mqtt-v5.sh b/ct/zigbee2mqtt-v5.sh deleted file mode 100644 index f16cc025..00000000 --- a/ct/zigbee2mqtt-v5.sh +++ /dev/null @@ -1,486 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _____ _ __ ___ __ _______ ____________ -/__ / (_)___ _/ /_ ___ ___ |__ \ / |/ / __ \/_ __/_ __/ - / / / / __ / __ \/ _ \/ _ \__/ // /|_/ / / / / / / / / - / /__/ / /_/ / /_/ / __/ __/ __// / / / /_/ / / / / / -/____/_/\__, /_.___/\___/\___/____/_/ /_/\___\_\/_/ /_/ - v5 /____/ 🐝 - -EOF -} -header_info -echo -e "Loading..." -APP="Zigbee2MQTT" -var_disk="4" -var_cpu="2" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" - CT_TYPE="0" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" OFF \ - "0" "Privileged" ON \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -cd /opt/zigbee2mqtt - -stop_zigbee2mqtt() { - if which systemctl 2> /dev/null > /dev/null; then - echo "Shutting down Zigbee2MQTT..." - sudo systemctl stop zigbee2mqtt - else - echo "Skipped stopping Zigbee2MQTT, no systemctl found" - fi -} - -start_zigbee2mqtt() { - if which systemctl 2> /dev/null > /dev/null; then - echo "Starting Zigbee2MQTT..." - sudo systemctl start zigbee2mqtt - else - echo "Skipped starting Zigbee2MQTT, no systemctl found" - fi -} - -set -e - -if [ -d data-backup ]; then - echo "ERROR: Backup directory exists. May be previous restoring was failed?" - echo "1. Save 'data-backup' and 'data' dirs to safe location to make possibility to restore config later." - echo "2. Manually delete 'data-backup' dir and try again." - exit 1 -fi - -stop_zigbee2mqtt - -echo "Generating a backup of the configuration..." -cp -R data data-backup || { echo "Failed to create backup."; exit 1; } - -echo "Initiating update" -if ! git pull; then - echo "Update failed, temporarily storing changes and trying again." - git stash && git pull || (echo "Update failed even after storing changes. Aborting."; exit 1) -fi - -echo "Acquiring necessary components..." -npm ci || { echo "Failed to install necessary components."; exit 1; } - -echo "Restoring configuration..." -cp -R data-backup/* data || { echo "Failed to restore configuration."; exit 1; } - -rm -rf data-backup || { echo "Failed to remove backup directory."; exit 1; } - -start_zigbee2mqtt - -echo "Done!" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/zigbee2mqtt ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -if [ "$CT_TYPE" == "0" ]; then - LXC_CONFIG=/etc/pve/lxc/${CTID}.conf - cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -lxc.cgroup2.devices.allow: c 188:* rwm -lxc.cgroup2.devices.allow: c 189:* rwm -lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir -lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file -EOF -fi -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" diff --git a/ct/zigbee2mqtt.sh b/ct/zigbee2mqtt.sh new file mode 100644 index 00000000..2030a5dd --- /dev/null +++ b/ct/zigbee2mqtt.sh @@ -0,0 +1,134 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + + _____ _ __ ___ __ _______ ____________ +/__ / (_)___ _/ /_ ___ ___ |__ \ / |/ / __ \/_ __/_ __/ + / / / / __ / __ \/ _ \/ _ \__/ // /|_/ / / / / / / / / + / /__/ / /_/ / /_/ / __/ __/ __// / / / /_/ / / / / / +/____/_/\__, /_.___/\___/\___/____/_/ /_/\___\_\/_/ /_/ + /____/ 🐝 + +EOF +} +header_info +echo -e "Loading..." +APP="Zigbee2MQTT" +var_disk="4" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + header_info + if [[ ! -d /opt/zigbee2mqtt ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + cd /opt/zigbee2mqtt + + stop_zigbee2mqtt() { + if which systemctl 2>/dev/null >/dev/null; then + echo "Shutting down Zigbee2MQTT..." + sudo systemctl stop zigbee2mqtt + else + echo "Skipped stopping Zigbee2MQTT, no systemctl found" + fi + } + + start_zigbee2mqtt() { + if which systemctl 2>/dev/null >/dev/null; then + echo "Starting Zigbee2MQTT..." + sudo systemctl start zigbee2mqtt + else + echo "Skipped starting Zigbee2MQTT, no systemctl found" + fi + } + + set -e + + if [ -d data-backup ]; then + echo "ERROR: Backup directory exists. May be previous restoring was failed?" + echo "1. Save 'data-backup' and 'data' dirs to safe location to make possibility to restore config later." + echo "2. Manually delete 'data-backup' dir and try again." + exit 1 + fi + + stop_zigbee2mqtt + + echo "Generating a backup of the configuration..." + cp -R data data-backup || { + echo "Failed to create backup." + exit 1 + } + + echo "Initiating update" + if ! git pull; then + echo "Update failed, temporarily storing changes and trying again." + git stash && git pull || ( + echo "Update failed even after storing changes. Aborting." + exit 1 + ) + fi + + echo "Acquiring necessary components..." + npm ci || { + echo "Failed to install necessary components." + exit 1 + } + + echo "Restoring configuration..." + cp -R data-backup/* data || { + echo "Failed to restore configuration." + exit 1 + } + + rm -rf data-backup || { + echo "Failed to remove backup directory." + exit 1 + } + + start_zigbee2mqtt + + echo "Done!" + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/zwave-js-ui-v5.sh b/ct/zwave-js-ui-v5.sh deleted file mode 100644 index c4f360a6..00000000 --- a/ct/zwave-js-ui-v5.sh +++ /dev/null @@ -1,455 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -function header_info { -clear -cat <<"EOF" - - _____ _______ __ ______ -/__ /_ ______ __v5 _____ / / ___/ / / / / _/ - / /| | /| / / __ `/ | / / _ \ __ / /\__ \ / / / // / - / /_| |/ |/ / /_/ /| |/ / __/ / /_/ /___/ / / /_/ // / -/____/__/|__/\__,_/ |___/\___/ \____//____/ \____/___/ - -EOF -} -header_info -echo -e "Loading..." -APP="Zwave-JS-UI" -var_disk="4" -var_cpu="2" -var_ram="1024" -var_os="debian" -var_version="11" -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-v5-install" -timezone=$(cat /etc/timezone) -INTEGER='^[0-9]+([.][0-9]+)?$' -YW=$(echo "\033[33m") -BL=$(echo "\033[36m") -RD=$(echo "\033[01;31m") -BGN=$(echo "\033[4;92m") -GN=$(echo "\033[1;92m") -DGN=$(echo "\033[32m") -CL=$(echo "\033[m") -BFR="\\r\\033[K" -HOLD="-" -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.0 or higher" - echo -e "Exiting..." - sleep 2 -exit -fi -} -function ARCH_CHECK() { -if [ "$(dpkg --print-architecture)" != "amd64" ]; then - echo -e "\n ${CROSS} This script will not work with PiMox! \n" - echo -e "Exiting..." - sleep 2 -exit -fi -} - -function default_settings() { - echo -e "${DGN}Using Container Type: ${BGN}Privileged${CL}" - CT_TYPE="0" - echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" - PW="" - echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" - DISK_SIZE="$var_disk" - echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" - RAM_SIZE="$var_ram" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" - NET=dhcp - echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" - GATE="" - echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" - DISABLEIP6="no" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" - SD="" - echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" - NS="" - echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" - MAC="" - echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" - SSH="no" - echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" - VERB="no" - echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" -} - -function exit-script() { - clear - echo -e "⚠ User exited script \n" - exit -} - -function advanced_settings() { -if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ - "1" "Unprivileged" OFF \ - "0" "Privileged" ON \ - 3>&1 1>&2 2>&3); then - echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" -else - exit-script -fi - -if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW=" " - else - PW="-password $PW1" - fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" -else - exit-script -fi - -if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then - if [ -z "$CT_ID" ]; then - CT_ID="$NEXTID" - echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" - else - echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" - fi -else - exit -fi - -if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then - if [ -z "$CT_NAME" ]; then - HN="$NSAPP" - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else - exit-script -fi - -if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then - if [ -z "$DISK_SIZE" ]; then - DISK_SIZE="$var_disk" - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - else - if ! [[ $DISK_SIZE =~ $INTEGER ]]; then - echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" - advanced_settings - fi - echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" - fi -else - exit-script -fi - -if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then - if [ -z "$CORE_COUNT" ]; then - CORE_COUNT="$var_cpu" - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - else - echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" - fi -else - exit-script -fi - -if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then - if [ -z "$RAM_SIZE" ]; then - RAM_SIZE="$var_ram" - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - else - echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" - fi -else - exit-script -fi - -if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then - if [ -z "$BRG" ]; then - BRG="vmbr0" - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - else - echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" - fi -else - exit-script -fi - -if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $NET ]; then - NET="dhcp" - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - else - echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" - fi -else - exit-script -fi -if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then - if [ -z $GATE1 ]; then - GATE1="Default" - GATE="" - else - GATE=",gw=$GATE1" - fi - echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then - DISABLEIP6="yes" -else - DISABLEIP6="no" -fi - echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" - -if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then - if [ -z $MTU1 ]; then - MTU1="Default" - MTU="" - else - MTU=",mtu=$MTU1" - fi - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" -else - exit-script -fi - -if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then - if [ -z $SD ]; then - SX=Host - SD="" - else - SX=$SD - SD="-searchdomain=$SD" - fi - echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" -else - exit-script -fi - -if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then - if [ -z $NX ]; then - NX=Host - NS="" - else - NS="-nameserver=$NX" - fi - echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" -else - exit-script -fi - -if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then - if [ -z $MAC1 ]; then - MAC1="Default" - MAC="" - else - MAC=",hwaddr=$MAC1" - echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" - fi -else - exit-script -fi - -if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then - if [ -z $VLAN1 ]; then - VLAN1="Default" - VLAN="" - else - VLAN=",tag=$VLAN1" - fi - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - exit-script -fi - -if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then - SSH="yes" -else - SSH="no" -fi - echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" - -if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then - VERB="yes" -else - VERB="no" -fi - echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" - -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then - echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi -} - -function install_script() { -ARCH_CHECK -PVE_CHECK -NEXTID=$(pvesh get /cluster/nextid) -header_info - if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings - else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings - fi -} - -function update_script() { -header_info -RELEASE=$(curl -s https://api.github.com/repos/zwave-js/zwave-js-ui/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -msg_info "Stopping Z-wave JS UI" -systemctl stop zwave-js-ui.service -msg_ok "Stopped Z-wave JS UI" - -msg_info "Updating Z-wave JS UI" -wget https://github.com/zwave-js/zwave-js-ui/releases/download/${RELEASE}/zwave-js-ui-${RELEASE}-linux.zip &>/dev/null -unzip zwave-js-ui-${RELEASE}-linux.zip &>/dev/null -\cp -R zwave-js-ui-linux /opt/zwave-js-ui -msg_ok "Updated Z-wave JS UI" - -msg_info "Starting Z-wave JS UI" -systemctl enable --now zwave-js-ui.service -msg_ok "Started Z-wave JS UI" - -msg_info "Cleanup" -rm -rf zwave-js-ui-${RELEASE}-linux.zip zwave-js-ui-linux store -msg_ok "Cleaned" -msg_ok "Updated Successfully!\n" -exit -} - -if command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - install_script -fi - -if ! command -v pveversion >/dev/null 2>&1 && [[ ! -d /opt/zwave-js-ui ]]; then - msg_error "No ${APP} Installation Found!" - exit -fi - -if ! command -v pveversion >/dev/null 2>&1; then - if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then - clear - echo -e "⚠ User exited script \n" - exit - fi - update_script -fi - -if [ "$VERB" == "yes" ]; then set -x; fi -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" -else - FEATURES="nesting=1" -fi -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null -export tz=$timezone -export DISABLEIPV6=$DISABLEIP6 -export APPLICATION=$APP -export VERBOSE=$VERB -export SSH_ROOT=${SSH} -export CTID=$CT_ID -export PCT_OSTYPE=$var_os -export PCT_OSVERSION=$var_version -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - $SD - $NS - -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit -if [ "$CT_TYPE" == "0" ]; then - LXC_CONFIG=/etc/pve/lxc/${CTID}.conf - cat <>$LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -lxc.cgroup2.devices.allow: c 188:* rwm -lxc.cgroup2.devices.allow: c 189:* rwm -lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir -lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file -lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file -EOF -fi -msg_info "Starting LXC Container" -pct start $CTID -msg_ok "Started LXC Container" -lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit -IP=$(pct exec $CTID ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) -pct set $CTID -description "# ${APP} LXC -### https://tteck.github.io/Proxmox/ -" -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8091${CL} \n" diff --git a/ct/zwave-js-ui.sh b/ct/zwave-js-ui.sh new file mode 100644 index 00000000..7dc9ec31 --- /dev/null +++ b/ct/zwave-js-ui.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/debian.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + + _____ _______ __ ______ +/__ /_ ______ __ _____ / / ___/ / / / / _/ + / /| | /| / / __ `/ | / / _ \ __ / /\__ \ / / / // / + / /_| |/ |/ / /_/ /| |/ / __/ / /_/ /___/ / / /_/ // / +/____/__/|__/\__,_/ |___/\___/ \____//____/ \____/___/ + +EOF +} +header_info +echo -e "Loading..." +APP="Zwave-JS-UI" +var_disk="4" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="11" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET=dhcp + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + header_info + if [[ ! -d /opt/zwave-js-ui ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + RELEASE=$(curl -s https://api.github.com/repos/zwave-js/zwave-js-ui/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') + msg_info "Stopping Z-wave JS UI" + systemctl stop zwave-js-ui.service + msg_ok "Stopped Z-wave JS UI" + + msg_info "Updating Z-wave JS UI" + wget https://github.com/zwave-js/zwave-js-ui/releases/download/${RELEASE}/zwave-js-ui-${RELEASE}-linux.zip &>/dev/null + unzip zwave-js-ui-${RELEASE}-linux.zip &>/dev/null + \cp -R zwave-js-ui-linux /opt/zwave-js-ui + msg_ok "Updated Z-wave JS UI" + + msg_info "Starting Z-wave JS UI" + systemctl enable --now zwave-js-ui.service + msg_ok "Started Z-wave JS UI" + + msg_info "Cleanup" + rm -rf zwave-js-ui-${RELEASE}-linux.zip zwave-js-ui-linux store + msg_ok "Cleaned" + msg_ok "Updated Successfully!\n" + exit +} + +start +build_container +description + +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:8091${CL} \n" diff --git a/install/adguard-install.sh b/install/adguard-install.sh new file mode 100644 index 00000000..fb490e06 --- /dev/null +++ b/install/adguard-install.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing AdGuard Home" +systemctl stop systemd-resolved +echo "DNSStubListener=no" >>/etc/systemd/resolved.conf +ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf +wget -qL https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh +$STD bash install.sh +rm install.sh +msg_ok "Installed AdGuard Home" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/adguard-v5-install.sh b/install/adguard-v5-install.sh deleted file mode 100644 index 4f8ae86e..00000000 --- a/install/adguard-v5-install.sh +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing AdGuard Home" -systemctl stop systemd-resolved -echo "DNSStubListener=no" >>/etc/systemd/resolved.conf -ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf -wget -qL https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh -$STD bash install.sh -rm install.sh -msg_ok "Installed AdGuard Home" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/alpine-adguard-install.sh b/install/alpine-adguard-install.sh new file mode 100644 index 00000000..4dd81790 --- /dev/null +++ b/install/alpine-adguard-install.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" + +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apk add newt +$STD apk add curl +$STD apk add nano +$STD apk add mc +$STD apk add openssh +msg_ok "Installed Dependencies" + +msg_info "Installing Alpine-AdGuard" +VER=$(curl --silent -qI https://github.com/AdguardTeam/AdGuardHome/releases/latest | awk -F '/' '/^location/ {print substr($NF, 1, length($NF)-1)}'); +$STD wget -q "https://github.com/AdguardTeam/AdGuardHome/releases/download/$VER/AdGuardHome_linux_amd64.tar.gz" +$STD tar -xvf AdGuardHome_linux_amd64.tar.gz >/dev/null 2>&1 +$STD mv AdGuardHome /opt +$STD rm AdGuardHome_linux_amd64.tar.gz +$STD chmod +x /opt/AdGuardHome/AdGuardHome +$STD /opt/AdGuardHome/AdGuardHome -s install +$STD /opt/AdGuardHome/AdGuardHome -s start +$STD msg_ok "Installed Alpine-AdGuard" + +motd_ssh diff --git a/install/alpine-adguard-v5-install.sh b/install/alpine-adguard-v5-install.sh deleted file mode 100644 index a5c73b3f..00000000 --- a/install/alpine-adguard-v5-install.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then -$STD sysctl net.ipv6.conf.all.disable_ipv6=1 -$STD sysctl net.ipv6.conf.default.disable_ipv6=1 -echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.d/99-sysctl.conf -echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.d/99-sysctl.conf -$STD sysctl -p /etc/sysctl.d/99-sysctl.conf -fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -i=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -while [ $i -gt 0 ]; do - if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - i=$((i-1)) -done - -if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -cat </etc/apk/repositories -https://dl-cdn.alpinelinux.org/alpine/latest-stable/main -https://dl-cdn.alpinelinux.org/alpine/latest-stable/community -EOF -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(ip addr show | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1 | tail -n1)${CL}" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if echo "$prompt" | grep -Ei "^(y|yes)$" > /dev/null; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi - -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apk update -$STD apk upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apk add wget -$STD apk add bash -$STD apk add curl -$STD apk add nano -$STD apk add mc -$STD apk add openssh -msg_ok "Installed Dependencies" - -msg_info "Installing $APPLICATION" -VER=$(curl --silent -qI https://github.com/AdguardTeam/AdGuardHome/releases/latest | awk -F '/' '/^location/ {print substr($NF, 1, length($NF)-1)}'); -$STD wget -q "https://github.com/AdguardTeam/AdGuardHome/releases/download/$VER/AdGuardHome_linux_amd64.tar.gz" -$STD tar -xvf AdGuardHome_linux_amd64.tar.gz >/dev/null 2>&1 -$STD mv AdGuardHome /opt -$STD rm AdGuardHome_linux_amd64.tar.gz -$STD chmod +x /opt/AdGuardHome/AdGuardHome -$STD /opt/AdGuardHome/AdGuardHome -s install -$STD /opt/AdGuardHome/AdGuardHome -s start -$STD msg_ok "Installed $APPLICATION" - -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -if [[ "${SSH_ROOT}" == "yes" ]]; then - $STD rc-update add sshd - $STD /etc/init.d/sshd start -fi diff --git a/install/alpine-docker-install.sh b/install/alpine-docker-install.sh new file mode 100644 index 00000000..ac7dce79 --- /dev/null +++ b/install/alpine-docker-install.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" + +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apk add newt +$STD apk add curl +$STD apk add openssh +$STD apk add nano +$STD apk add mc +msg_ok "Installed Dependencies" + +msg_info "Installing Docker" +$STD apk add docker +$STD rc-service docker start +$STD rc-update add docker default +msg_ok "Installed Docker" + +get_latest_release() { + curl -sL https://api.github.com/repos/$1/releases/latest | grep '"tag_name":' | cut -d'"' -f4 +} +PORTAINER_LATEST_VERSION=$(get_latest_release "portainer/portainer") +DOCKER_COMPOSE_LATEST_VERSION=$(get_latest_release "docker/compose") + +read -r -p "Would you like to add Portainer? " prompt +if echo "$prompt" | grep -Eq "^(y|yes)$"; then + msg_info "Installing Portainer $PORTAINER_LATEST_VERSION" + docker volume create portainer_data >/dev/null + $STD docker run -d \ + -p 8000:8000 \ + -p 9000:9000 \ + --name=portainer \ + --restart=always \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v portainer_data:/data \ + portainer/portainer-ce:latest + msg_ok "Installed Portainer $PORTAINER_LATEST_VERSION" +fi + +read -r -p "Would you like to add Docker Compose? " prompt +if echo "$prompt" | grep -Eq "^(y|yes)$"; then + msg_info "Installing Docker Compose $DOCKER_COMPOSE_LATEST_VERSION" + DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} + mkdir -p $DOCKER_CONFIG/cli-plugins + curl -sSL https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_LATEST_VERSION/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose + chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose + msg_ok "Installed Docker Compose $DOCKER_COMPOSE_LATEST_VERSION" +fi + +motd_ssh diff --git a/install/alpine-docker-v5-install.sh b/install/alpine-docker-v5-install.sh deleted file mode 100644 index 8a36fa0e..00000000 --- a/install/alpine-docker-v5-install.sh +++ /dev/null @@ -1,150 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then -$STD sysctl net.ipv6.conf.all.disable_ipv6=1 -$STD sysctl net.ipv6.conf.default.disable_ipv6=1 -echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.d/99-sysctl.conf -echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.d/99-sysctl.conf -$STD sysctl -p /etc/sysctl.d/99-sysctl.conf -fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -i=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -while [ $i -gt 0 ]; do - if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - i=$((i-1)) -done - -if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -cat </etc/apk/repositories -https://dl-cdn.alpinelinux.org/alpine/latest-stable/main -https://dl-cdn.alpinelinux.org/alpine/latest-stable/community -https://dl-cdn.alpinelinux.org/alpine/edge/testing -EOF -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(ip addr show | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1 | tail -n1)${CL}" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if echo "$prompt" | grep -Ei "^(y|yes)$" > /dev/null; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi - -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apk update -$STD apk upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apk add bash -$STD apk add curl -$STD apk add openssl -$STD apk add openssh -$STD apk add nano -$STD apk add mc -msg_ok "Installed Dependencies" - -msg_info "Installing $APPLICATION" -$STD apk add docker -$STD rc-service docker start -$STD rc-update add docker default -msg_ok "Installed $APPLICATION" - -get_latest_release() { - curl -sL https://api.github.com/repos/$1/releases/latest | grep '"tag_name":' | cut -d'"' -f4 -} -PORTAINER_LATEST_VERSION=$(get_latest_release "portainer/portainer") -DOCKER_COMPOSE_LATEST_VERSION=$(get_latest_release "docker/compose") - -read -r -p "Would you like to add Portainer? " prompt -if echo "$prompt" | grep -Eq "^(y|yes)$"; then - msg_info "Installing Portainer $PORTAINER_LATEST_VERSION" - docker volume create portainer_data >/dev/null - $STD docker run -d \ - -p 8000:8000 \ - -p 9000:9000 \ - --name=portainer \ - --restart=always \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -v portainer_data:/data \ - portainer/portainer-ce:latest - msg_ok "Installed Portainer $PORTAINER_LATEST_VERSION" -fi - -read -r -p "Would you like to add Docker Compose? " prompt -if echo "$prompt" | grep -Eq "^(y|yes)$"; then - msg_info "Installing Docker Compose $DOCKER_COMPOSE_LATEST_VERSION" - DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} - mkdir -p $DOCKER_CONFIG/cli-plugins - curl -sSL https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_LATEST_VERSION/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose - chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose - msg_ok "Installed Docker Compose $DOCKER_COMPOSE_LATEST_VERSION" -fi - -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -if [[ "${SSH_ROOT}" == "yes" ]]; then - $STD rc-update add sshd - $STD /etc/init.d/sshd start -fi diff --git a/install/alpine-grafana-install.sh b/install/alpine-grafana-install.sh new file mode 100644 index 00000000..86f1e97d --- /dev/null +++ b/install/alpine-grafana-install.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" + +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apk add newt +$STD apk add curl +$STD apk add openssh +$STD apk add nano +$STD apk add mc +msg_ok "Installed Dependencies" + +msg_info "Installing Grafana" +$STD apk add grafana +$STD sed -i '/http_addr/s/127.0.0.1/0.0.0.0/g' /etc/conf.d/grafana +$STD rc-service grafana start +$STD rc-update add grafana default +msg_ok "Installed Grafana" + +motd_ssh diff --git a/install/alpine-grafana-v5-install.sh b/install/alpine-grafana-v5-install.sh deleted file mode 100644 index efd75bef..00000000 --- a/install/alpine-grafana-v5-install.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then -$STD sysctl net.ipv6.conf.all.disable_ipv6=1 -$STD sysctl net.ipv6.conf.default.disable_ipv6=1 -echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.d/99-sysctl.conf -echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.d/99-sysctl.conf -$STD sysctl -p /etc/sysctl.d/99-sysctl.conf -fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -i=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -while [ $i -gt 0 ]; do - if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - i=$((i-1)) -done - -if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -cat </etc/apk/repositories -https://dl-cdn.alpinelinux.org/alpine/latest-stable/main -https://dl-cdn.alpinelinux.org/alpine/latest-stable/community -EOF -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(ip addr show | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1 | tail -n1)${CL}" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if echo "$prompt" | grep -Ei "^(y|yes)$" > /dev/null; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi - -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apk update -$STD apk upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apk add bash -$STD apk add curl -$STD apk add openssh -$STD apk add nano -$STD apk add mc -msg_ok "Installed Dependencies" - -msg_info "Installing $APPLICATION" -$STD apk add grafana -$STD sed -i '/http_addr/s/127.0.0.1/0.0.0.0/g' /etc/conf.d/grafana -$STD rc-service grafana start -$STD rc-update add grafana default -msg_ok "Installed $APPLICATION" - -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -if [[ "${SSH_ROOT}" == "yes" ]]; then - $STD rc-update add sshd - $STD /etc/init.d/sshd start -fi diff --git a/install/alpine-vaultwarden-install.sh b/install/alpine-vaultwarden-install.sh new file mode 100644 index 00000000..952922e7 --- /dev/null +++ b/install/alpine-vaultwarden-install.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" + +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apk add newt +$STD apk add curl +$STD apk add openssl +$STD apk add openssh +$STD apk add nano +$STD apk add mc +msg_ok "Installed Dependencies" + +msg_info "Installing Alpine-Vaultwarden" +$STD apk add vaultwarden +cat </etc/conf.d/vaultwarden +export DATA_FOLDER=/var/lib/vaultwarden +export WEB_VAULT_FOLDER=/var/lib/vaultwarden/web-vault +export WEB_VAULT_ENABLED=true +export ADMIN_TOKEN=$(openssl rand -base64 48) +export ROCKET_ADDRESS=0.0.0.0 +EOF +$STD rc-service vaultwarden start +$STD rc-update add vaultwarden default +msg_ok "Installed Alpine-Vaultwarden" + +motd_ssh diff --git a/install/alpine-vaultwarden-v5-install.sh b/install/alpine-vaultwarden-v5-install.sh deleted file mode 100644 index 02edeb1a..00000000 --- a/install/alpine-vaultwarden-v5-install.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then -$STD sysctl net.ipv6.conf.all.disable_ipv6=1 -$STD sysctl net.ipv6.conf.default.disable_ipv6=1 -echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.d/99-sysctl.conf -echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.d/99-sysctl.conf -$STD sysctl -p /etc/sysctl.d/99-sysctl.conf -fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -i=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -while [ $i -gt 0 ]; do - if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - i=$((i-1)) -done - -if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -cat </etc/apk/repositories -https://dl-cdn.alpinelinux.org/alpine/edge/main -https://dl-cdn.alpinelinux.org/alpine/edge/community -https://dl-cdn.alpinelinux.org/alpine/edge/testing -EOF -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(ip addr show | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1 | tail -n1)${CL}" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if echo "$prompt" | grep -Ei "^(y|yes)$" > /dev/null; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi - -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apk update -$STD apk upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apk add bash -$STD apk add curl -$STD apk add openssl -$STD apk add openssh -$STD apk add nano -$STD apk add mc -msg_ok "Installed Dependencies" - -msg_info "Installing $APPLICATION" -$STD apk add vaultwarden -cat </etc/conf.d/vaultwarden -export DATA_FOLDER=/var/lib/vaultwarden -export WEB_VAULT_FOLDER=/var/lib/vaultwarden/web-vault -export WEB_VAULT_ENABLED=true -export ADMIN_TOKEN=$(openssl rand -base64 48) -export ROCKET_ADDRESS=0.0.0.0 -EOF -$STD rc-service vaultwarden start -$STD rc-update add vaultwarden default -msg_ok "Installed $APPLICATION" - -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -if [[ "${SSH_ROOT}" == "yes" ]]; then - $STD rc-update add sshd - $STD /etc/init.d/sshd start -fi diff --git a/install/alpine-zigbee2mqtt-install.sh b/install/alpine-zigbee2mqtt-install.sh new file mode 100644 index 00000000..f3698db9 --- /dev/null +++ b/install/alpine-zigbee2mqtt-install.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" + +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apk add newt +$STD apk add curl +$STD apk add openssh +$STD apk add nano +$STD apk add mc +msg_ok "Installed Dependencies" + +msg_info "Installing Alpine-Zigbee2MQTT" +$STD apk add zigbee2mqtt +msg_ok "Installed Alpine-Zigbee2MQTT" + +motd_ssh diff --git a/install/alpine-zigbee2mqtt-v5-install.sh b/install/alpine-zigbee2mqtt-v5-install.sh deleted file mode 100644 index 26c35768..00000000 --- a/install/alpine-zigbee2mqtt-v5-install.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then -$STD sysctl net.ipv6.conf.all.disable_ipv6=1 -$STD sysctl net.ipv6.conf.default.disable_ipv6=1 -echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.d/99-sysctl.conf -echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.d/99-sysctl.conf -$STD sysctl -p /etc/sysctl.d/99-sysctl.conf -fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -i=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -while [ $i -gt 0 ]; do - if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - i=$((i-1)) -done - -if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -cat </etc/apk/repositories -https://dl-cdn.alpinelinux.org/alpine/latest-stable/main -https://dl-cdn.alpinelinux.org/alpine/latest-stable/community -https://dl-cdn.alpinelinux.org/alpine/edge/testing -EOF -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(ip addr show | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1 | tail -n1)${CL}" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if echo "$prompt" | grep -Ei "^(y|yes)$" > /dev/null; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi - -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apk update -$STD apk upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apk add bash -$STD apk add curl -$STD apk add openssl -$STD apk add openssh -$STD apk add nano -$STD apk add mc -msg_ok "Installed Dependencies" - -msg_info "Installing $APPLICATION" -$STD apk add zigbee2mqtt -msg_ok "Installed $APPLICATION" - -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -if [[ "${SSH_ROOT}" == "yes" ]]; then - $STD rc-update add sshd - $STD /etc/init.d/sshd start -fi diff --git a/install/audiobookshelf-install.sh b/install/audiobookshelf-install.sh new file mode 100644 index 00000000..5586918e --- /dev/null +++ b/install/audiobookshelf-install.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y gnupg +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing audiobookshelf" +$STD apt-key add <(curl -s --compressed "https://advplyr.github.io/audiobookshelf-ppa/KEY.gpg") +sh -c 'echo "deb https://advplyr.github.io/audiobookshelf-ppa ./" > /etc/apt/sources.list.d/audiobookshelf.list' +$STD apt-get update +$STD apt install audiobookshelf +msg_ok "Installed audiobookshelf" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/audiobookshelf-v5-install.sh b/install/audiobookshelf-v5-install.sh deleted file mode 100644 index f32761b2..00000000 --- a/install/audiobookshelf-v5-install.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y gnupg -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing audiobookshelf" -$STD apt-key add <(curl -s --compressed "https://advplyr.github.io/audiobookshelf-ppa/KEY.gpg") -sh -c 'echo "deb https://advplyr.github.io/audiobookshelf-ppa ./" > /etc/apt/sources.list.d/audiobookshelf.list' -$STD apt-get update -$STD apt install audiobookshelf -msg_ok "Installed audiobookshelf" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/autobrr-install.sh b/install/autobrr-install.sh new file mode 100644 index 00000000..dbf1cea3 --- /dev/null +++ b/install/autobrr-install.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing Autobrr" +wget -q $(curl -s https://api.github.com/repos/autobrr/autobrr/releases/latest | grep download | grep linux_x86_64 | cut -d\" -f4) +tar -C /usr/local/bin -xzf autobrr*.tar.gz +rm -rf autobrr*.tar.gz +mkdir -p /root/.config/autobrr +cat <>/root/.config/autobrr/config.toml +# https://autobrr.com/configuration/autobrr +host = "0.0.0.0" +port = 7474 +logLevel = "DEBUG" +sessionSecret = "$(openssl rand -base64 24)" +EOF +msg_ok "Installed Autobrr" + +msg_info "Creating Service" +service_path="/etc/systemd/system/autobrr.service" +echo "[Unit] +Description=autobrr service +After=syslog.target network-online.target +[Service] +Type=simple +User=root +Group=root +ExecStart=/usr/local/bin/autobrr --config=/root/.config/autobrr/ +[Install] +WantedBy=multi-user.target" >$service_path +systemctl enable --now -q autobrr.service +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/autobrr-v5-install.sh b/install/autobrr-v5-install.sh deleted file mode 100644 index 61a9c8c2..00000000 --- a/install/autobrr-v5-install.sh +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing Autobrr" -wget -q $(curl -s https://api.github.com/repos/autobrr/autobrr/releases/latest | grep download | grep linux_x86_64 | cut -d\" -f4) -tar -C /usr/local/bin -xzf autobrr*.tar.gz -rm -rf autobrr*.tar.gz -mkdir -p /root/.config/autobrr -cat <>/root/.config/autobrr/config.toml -# https://autobrr.com/configuration/autobrr -host = "0.0.0.0" -port = 7474 -logLevel = "DEBUG" -sessionSecret = "$(openssl rand -base64 24)" -EOF -msg_ok "Installed Autobrr" - -msg_info "Creating Service" -service_path="/etc/systemd/system/autobrr.service" -echo "[Unit] -Description=autobrr service -After=syslog.target network-online.target -[Service] -Type=simple -User=root -Group=root -ExecStart=/usr/local/bin/autobrr --config=/root/.config/autobrr/ -[Install] -WantedBy=multi-user.target" >$service_path -systemctl enable --now -q autobrr.service -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/blocky-v5-install.sh b/install/blocky-install.sh similarity index 79% rename from install/blocky-v5-install.sh rename to install/blocky-install.sh index aa1722b0..e4656a13 100644 --- a/install/blocky-v5-install.sh +++ b/install/blocky-install.sh @@ -5,85 +5,13 @@ # License: MIT # https://github.com/tteck/Proxmox/raw/main/LICENSE -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os msg_info "Installing Dependencies" $STD apt-get install -y curl @@ -353,23 +281,8 @@ EOF $STD systemctl enable --now blocky msg_ok "Created Service" -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi +motd_ssh +root msg_info "Cleaning up" $STD apt-get autoremove diff --git a/install/casaos-install.sh b/install/casaos-install.sh new file mode 100644 index 00000000..cf4ee609 --- /dev/null +++ b/install/casaos-install.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y unzip +msg_ok "Installed Dependencies" + +msg_info "Installing CasaOS (Patience)" +DOCKER_CONFIG_PATH='/etc/docker/daemon.json' +mkdir -p $(dirname $DOCKER_CONFIG_PATH) +if [ "$ST" == "yes" ]; then +VER=$(curl -s https://api.github.com/repos/containers/fuse-overlayfs/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +cd /usr/local/bin +curl -sSL -o fuse-overlayfs https://github.com/containers/fuse-overlayfs/releases/download/$VER/fuse-overlayfs-x86_64 +chmod 755 /usr/local/bin/fuse-overlayfs +cd ~ +echo -e '{\n "storage-driver": "fuse-overlayfs",\n "log-driver": "journald"\n}' > /etc/docker/daemon.json +else +echo -e '{\n "log-driver": "journald"\n}' > /etc/docker/daemon.json +fi +$STD bash <(curl -fsSL https://get.casaos.io) +msg_ok "Installed CasaOS" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/casaos-v5-install.sh b/install/casaos-v5-install.sh deleted file mode 100644 index 22f05ba7..00000000 --- a/install/casaos-v5-install.sh +++ /dev/null @@ -1,133 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y unzip -msg_ok "Installed Dependencies" - -msg_info "Installing CasaOS (Patience)" -DOCKER_CONFIG_PATH='/etc/docker/daemon.json' -mkdir -p $(dirname $DOCKER_CONFIG_PATH) -if [ "$ST" == "yes" ]; then -VER=$(curl -s https://api.github.com/repos/containers/fuse-overlayfs/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -cd /usr/local/bin -curl -sSL -o fuse-overlayfs https://github.com/containers/fuse-overlayfs/releases/download/$VER/fuse-overlayfs-x86_64 -chmod 755 /usr/local/bin/fuse-overlayfs -cd ~ -echo -e '{\n "storage-driver": "fuse-overlayfs",\n "log-driver": "journald"\n}' > /etc/docker/daemon.json -else -echo -e '{\n "log-driver": "journald"\n}' > /etc/docker/daemon.json -fi -$STD bash <(curl -fsSL https://get.casaos.io) -msg_ok "Installed CasaOS" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/changedetection-install.sh b/install/changedetection-install.sh new file mode 100644 index 00000000..fc9832c7 --- /dev/null +++ b/install/changedetection-install.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y pip +msg_ok "Installed Dependencies" + +msg_info "Installing Change Detection" +mkdir /opt/changedetection +$STD pip3 install changedetection.io +$STD python3 -m pip install dnspython==2.2.1 +msg_ok "Installed Change Detection" + +msg_info "Creating Service" +cat </etc/systemd/system/changedetection.service +[Unit] +Description=Change Detection +After=network-online.target +[Service] +Type=simple +WorkingDirectory=/opt/changedetection +ExecStart=changedetection.io -d /opt/changedetection -p 5000 +[Install] +WantedBy=multi-user.target +EOF +$STD systemctl enable --now changedetection +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/changedetection-v5-install.sh b/install/changedetection-v5-install.sh deleted file mode 100644 index 433ee0f9..00000000 --- a/install/changedetection-v5-install.sh +++ /dev/null @@ -1,137 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y pip -msg_ok "Installed Dependencies" - -msg_info "Installing Change Detection" -mkdir /opt/changedetection -$STD pip3 install changedetection.io -$STD python3 -m pip install dnspython==2.2.1 -msg_ok "Installed Change Detection" - -msg_info "Creating Service" -cat </etc/systemd/system/changedetection.service -[Unit] -Description=Change Detection -After=network-online.target -[Service] -Type=simple -WorkingDirectory=/opt/changedetection -ExecStart=changedetection.io -d /opt/changedetection -p 5000 -[Install] -WantedBy=multi-user.target -EOF -$STD systemctl enable --now changedetection -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/cronicle-install.sh b/install/cronicle-install.sh new file mode 100644 index 00000000..1060a494 --- /dev/null +++ b/install/cronicle-install.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y git +$STD apt-get install -y make +$STD apt-get install -y g++ +$STD apt-get install -y gcc +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x) +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing Cronicle Primary Server" +LATEST=$(curl -sL https://api.github.com/repos/jhuckaby/Cronicle/releases/latest | grep '"tag_name":' | cut -d'"' -f4) +IP=$(hostname -I | awk '{print $1}') +mkdir -p /opt/cronicle +cd /opt/cronicle +$STD tar zxvf <(curl -fsSL https://github.com/jhuckaby/Cronicle/archive/${LATEST}.tar.gz) --strip-components 1 +$STD npm install +$STD node bin/build.js dist +sed -i "s/localhost:3012/${IP}:3012/g" /opt/cronicle/conf/config.json +if [[ $SERV == "y" ]]; then $STD /opt/cronicle/bin/control.sh setup; fi +$STD /opt/cronicle/bin/control.sh start +$STD cp /opt/cronicle/bin/cronicled.init /etc/init.d/cronicled +chmod 775 /etc/init.d/cronicled +$STD update-rc.d cronicled defaults +msg_ok "Installed Cronicle Primary Server" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/cronicle-v5-install.sh b/install/cronicle-v5-install.sh deleted file mode 100644 index d9addbf6..00000000 --- a/install/cronicle-v5-install.sh +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y git -$STD apt-get install -y make -$STD apt-get install -y g++ -$STD apt-get install -y gcc -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x) -msg_ok "Set up Node.js Repository" - -msg_info "Installing Node.js" -$STD apt-get install -y nodejs -msg_ok "Installed Node.js" - -msg_info "Installing Cronicle Primary Server" -LATEST=$(curl -sL https://api.github.com/repos/jhuckaby/Cronicle/releases/latest | grep '"tag_name":' | cut -d'"' -f4) -IP=$(hostname -I | awk '{print $1}') -mkdir -p /opt/cronicle -cd /opt/cronicle -$STD tar zxvf <(curl -fsSL https://github.com/jhuckaby/Cronicle/archive/${LATEST}.tar.gz) --strip-components 1 -$STD npm install -$STD node bin/build.js dist -sed -i "s/localhost:3012/${IP}:3012/g" /opt/cronicle/conf/config.json -if [[ $SERV == "y" ]]; then $STD /opt/cronicle/bin/control.sh setup; fi -$STD /opt/cronicle/bin/control.sh start -$STD cp /opt/cronicle/bin/cronicled.init /etc/init.d/cronicled -chmod 775 /etc/init.d/cronicled -$STD update-rc.d cronicled defaults -msg_ok "Installed Cronicle Primary Server" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/daemonsync-install.sh b/install/daemonsync-install.sh new file mode 100644 index 00000000..dead1801 --- /dev/null +++ b/install/daemonsync-install.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y g++-multilib +msg_ok "Installed Dependencies" + +msg_info "Installing Daemon Sync Server" +wget -qL https://github.com/tteck/Proxmox/raw/main/misc/daemonsync_2.2.0.0059_amd64.deb +$STD dpkg -i daemonsync_2.2.0.0059_amd64.deb +msg_ok "Installed Daemon Sync Server" + +motd_ssh +root + +msg_info "Cleaning up" +rm -rf daemonsync_2.2.0.0059_amd64.deb +$STD apt-get autoremove >/dev/null +$STD apt-get autoclean >/dev/null +msg_ok "Cleaned" diff --git a/install/daemonsync-v5-install.sh b/install/daemonsync-v5-install.sh deleted file mode 100644 index abe4dec6..00000000 --- a/install/daemonsync-v5-install.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y g++-multilib -msg_ok "Installed Dependencies" - -msg_info "Installing Daemon Sync Server" -wget -qL https://github.com/tteck/Proxmox/raw/main/misc/daemonsync_2.2.0.0059_amd64.deb -$STD dpkg -i daemonsync_2.2.0.0059_amd64.deb -msg_ok "Installed Daemon Sync Server" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -rm -rf daemonsync_2.2.0.0059_amd64.deb -$STD apt-get autoremove >/dev/null -$STD apt-get autoclean >/dev/null -msg_ok "Cleaned" diff --git a/install/dashy-install.sh b/install/dashy-install.sh new file mode 100644 index 00000000..089fcdde --- /dev/null +++ b/install/dashy-install.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y git +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x) +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get install -y nodejs git make g++ gcc +msg_ok "Installed Node.js" + +msg_info "Installing Yarn" +$STD npm install --global yarn +msg_ok "Installed Yarn" + +msg_info "Installing Dashy (Patience)" +$STD git clone https://github.com/Lissy93/dashy.git +cd /dashy +$STD yarn +export NODE_OPTIONS=--max-old-space-size=1000 +$STD yarn build +msg_ok "Installed Dashy" + +msg_info "Creating Service" +cat </etc/systemd/system/dashy.service +[Unit] +Description=dashy + +[Service] +Type=simple +WorkingDirectory=/dashy +ExecStart=/usr/bin/yarn start +[Install] +WantedBy=multi-user.target +EOF +$STD systemctl enable dashy +systemctl start dashy +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/dashy-v5-install.sh b/install/dashy-v5-install.sh deleted file mode 100644 index 1bd8e71d..00000000 --- a/install/dashy-v5-install.sh +++ /dev/null @@ -1,153 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y git -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x) -msg_ok "Set up Node.js Repository" - -msg_info "Installing Node.js" -$STD apt-get install -y nodejs git make g++ gcc -msg_ok "Installed Node.js" - -msg_info "Installing Yarn" -$STD npm install --global yarn -msg_ok "Installed Yarn" - -msg_info "Installing Dashy (Patience)" -$STD git clone https://github.com/Lissy93/dashy.git -cd /dashy -$STD yarn -export NODE_OPTIONS=--max-old-space-size=1000 -$STD yarn build -msg_ok "Installed Dashy" - -msg_info "Creating Service" -cat </etc/systemd/system/dashy.service -[Unit] -Description=dashy - -[Service] -Type=simple -WorkingDirectory=/dashy -ExecStart=/usr/bin/yarn start -[Install] -WantedBy=multi-user.target -EOF -$STD systemctl enable dashy -systemctl start dashy -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/debian-install.sh b/install/debian-install.sh new file mode 100644 index 00000000..0e4905fb --- /dev/null +++ b/install/debian-install.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" \ No newline at end of file diff --git a/install/debian-v5-install.sh b/install/debian-v5-install.sh deleted file mode 100644 index ef9e1a6f..00000000 --- a/install/debian-v5-install.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/deconz-install.sh b/install/deconz-install.sh new file mode 100644 index 00000000..068cf5f3 --- /dev/null +++ b/install/deconz-install.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y gnupg +msg_ok "Installed Dependencies" + +msg_info "Setting Phoscon Repository" +$STD apt-key add <(curl -fsSL http://phoscon.de/apt/deconz.pub.key) +sh -c "echo 'deb [arch=amd64] http://phoscon.de/apt/deconz $(lsb_release -cs) main' > /etc/apt/sources.list.d/deconz.list" +msg_ok "Setup Phoscon Repository" + +msg_info "Installing deConz" +$STD apt-get update +$STD apt-get install -y deconz +msg_ok "Installed deConz" + +msg_info "Creating Service" +service_path="/lib/systemd/system/deconz.service" +echo "[Unit] +Description=deCONZ: ZigBee gateway -- REST API +Wants=deconz-init.service deconz-update.service +StartLimitIntervalSec=0 + +[Service] +User=root +ExecStart=/usr/bin/deCONZ -platform minimal --http-port=80 +Restart=on-failure +RestartSec=30 +AmbientCapabilities=CAP_NET_BIND_SERVICE CAP_KILL CAP_SYS_BOOT CAP_SYS_TIME + +[Install] +WantedBy=multi-user.target" >$service_path +$STD systemctl enable --now deconz +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/deconz-v5-install.sh b/install/deconz-v5-install.sh deleted file mode 100644 index ad060379..00000000 --- a/install/deconz-v5-install.sh +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y gnupg -msg_ok "Installed Dependencies" - -msg_info "Setting Phoscon Repository" -$STD apt-key add <(curl -fsSL http://phoscon.de/apt/deconz.pub.key) -sh -c "echo 'deb [arch=amd64] http://phoscon.de/apt/deconz $(lsb_release -cs) main' > /etc/apt/sources.list.d/deconz.list" -msg_ok "Setup Phoscon Repository" - -msg_info "Installing deConz" -$STD apt-get update -$STD apt-get install -y deconz -msg_ok "Installed deConz" - -msg_info "Creating Service" -service_path="/lib/systemd/system/deconz.service" -echo "[Unit] -Description=deCONZ: ZigBee gateway -- REST API -Wants=deconz-init.service deconz-update.service -StartLimitIntervalSec=0 - -[Service] -User=root -ExecStart=/usr/bin/deCONZ -platform minimal --http-port=80 -Restart=on-failure -RestartSec=30 -AmbientCapabilities=CAP_NET_BIND_SERVICE CAP_KILL CAP_SYS_BOOT CAP_SYS_TIME - -[Install] -WantedBy=multi-user.target" >$service_path -$STD systemctl enable --now deconz -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/deluge-install.sh b/install/deluge-install.sh new file mode 100644 index 00000000..1a55fb27 --- /dev/null +++ b/install/deluge-install.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing Python3-pip" +$STD apt-get install -y python3-pip +msg_ok "Installed Python3-pip" + +msg_info "Installing Deluge" +$STD pip install deluge[all] +$STD pip install lbry-libtorrent +msg_ok "Installed Deluge" + +msg_info "Creating Service" +service_path="/etc/systemd/system/deluged.service" +echo "[Unit] +Description=Deluge Bittorrent Client Daemon +Documentation=man:deluged +After=network-online.target + +[Service] +Type=simple +UMask=007 +ExecStart=/usr/local/bin/deluged -d +Restart=on-failure +TimeoutStopSec=300 + +[Install] +WantedBy=multi-user.target" >$service_path + +service_path="/etc/systemd/system/deluge-web.service" +echo "[Unit] +Description=Deluge Bittorrent Client Web Interface +Documentation=man:deluge-web +After=deluged.service +Wants=deluged.service + +[Service] +Type=simple +UMask=027 +ExecStart=/usr/local/bin/deluge-web -d +Restart=on-failure + +[Install] +WantedBy=multi-user.target" >$service_path +systemctl enable --now -q deluged.service +systemctl enable --now -q deluge-web.service +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/deluge-v5-install.sh b/install/deluge-v5-install.sh deleted file mode 100644 index dbc85972..00000000 --- a/install/deluge-v5-install.sh +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing Python3-pip" -$STD apt-get install -y python3-pip -msg_ok "Installed Python3-pip" - -msg_info "Installing Deluge" -$STD pip install deluge[all] -$STD pip install lbry-libtorrent -msg_ok "Installed Deluge" - -msg_info "Creating Service" -service_path="/etc/systemd/system/deluged.service" -echo "[Unit] -Description=Deluge Bittorrent Client Daemon -Documentation=man:deluged -After=network-online.target - -[Service] -Type=simple -UMask=007 -ExecStart=/usr/local/bin/deluged -d -Restart=on-failure -TimeoutStopSec=300 - -[Install] -WantedBy=multi-user.target" >$service_path - -service_path="/etc/systemd/system/deluge-web.service" -echo "[Unit] -Description=Deluge Bittorrent Client Web Interface -Documentation=man:deluge-web -After=deluged.service -Wants=deluged.service - -[Service] -Type=simple -UMask=027 -ExecStart=/usr/local/bin/deluge-web -d -Restart=on-failure - -[Install] -WantedBy=multi-user.target" >$service_path -systemctl enable --now -q deluged.service -systemctl enable --now -q deluge-web.service -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/devuan-install.sh b/install/devuan-install.sh new file mode 100644 index 00000000..eb2b237b --- /dev/null +++ b/install/devuan-install.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/devuan-v5-install.sh b/install/devuan-v5-install.sh deleted file mode 100644 index a8ca650d..00000000 --- a/install/devuan-v5-install.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/docker-install.sh b/install/docker-install.sh new file mode 100644 index 00000000..c2a33444 --- /dev/null +++ b/install/docker-install.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +get_latest_release() { + curl -sL https://api.github.com/repos/$1/releases/latest | grep '"tag_name":' | cut -d'"' -f4 +} + +DOCKER_LATEST_VERSION=$(get_latest_release "moby/moby") +PORTAINER_LATEST_VERSION=$(get_latest_release "portainer/portainer") +DOCKER_COMPOSE_LATEST_VERSION=$(get_latest_release "docker/compose") + +msg_info "Installing Docker $DOCKER_LATEST_VERSION" +DOCKER_CONFIG_PATH='/etc/docker/daemon.json' +mkdir -p $(dirname $DOCKER_CONFIG_PATH) +if [ "$ST" == "yes" ]; then +VER=$(curl -s https://api.github.com/repos/containers/fuse-overlayfs/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +cd /usr/local/bin +curl -sSL -o fuse-overlayfs https://github.com/containers/fuse-overlayfs/releases/download/$VER/fuse-overlayfs-x86_64 +chmod 755 /usr/local/bin/fuse-overlayfs +cd ~ +echo -e '{\n "storage-driver": "fuse-overlayfs",\n "log-driver": "journald"\n}' > /etc/docker/daemon.json +else +echo -e '{\n "log-driver": "journald"\n}' > /etc/docker/daemon.json +fi +$STD sh <(curl -sSL https://get.docker.com) +msg_ok "Installed Docker $DOCKER_LATEST_VERSION" + +read -r -p "Would you like to add Portainer? " prompt +if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + msg_info "Installing Portainer $PORTAINER_LATEST_VERSION" + docker volume create portainer_data >/dev/null + $STD docker run -d \ + -p 8000:8000 \ + -p 9000:9000 \ + --name=portainer \ + --restart=always \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v portainer_data:/data \ + portainer/portainer-ce:latest + msg_ok "Installed Portainer $PORTAINER_LATEST_VERSION" +fi + +read -r -p "Would you like to add Docker Compose? " prompt +if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + msg_info "Installing Docker Compose $DOCKER_COMPOSE_LATEST_VERSION" + DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} + mkdir -p $DOCKER_CONFIG/cli-plugins + curl -sSL https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_LATEST_VERSION/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose + chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose + msg_ok "Installed Docker Compose $DOCKER_COMPOSE_LATEST_VERSION" +fi + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/docker-v5-install.sh b/install/docker-v5-install.sh deleted file mode 100644 index 83339fb5..00000000 --- a/install/docker-v5-install.sh +++ /dev/null @@ -1,165 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -get_latest_release() { - curl -sL https://api.github.com/repos/$1/releases/latest | grep '"tag_name":' | cut -d'"' -f4 -} - -DOCKER_LATEST_VERSION=$(get_latest_release "moby/moby") -PORTAINER_LATEST_VERSION=$(get_latest_release "portainer/portainer") -DOCKER_COMPOSE_LATEST_VERSION=$(get_latest_release "docker/compose") - -msg_info "Installing Docker $DOCKER_LATEST_VERSION" -DOCKER_CONFIG_PATH='/etc/docker/daemon.json' -mkdir -p $(dirname $DOCKER_CONFIG_PATH) -if [ "$ST" == "yes" ]; then -VER=$(curl -s https://api.github.com/repos/containers/fuse-overlayfs/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -cd /usr/local/bin -curl -sSL -o fuse-overlayfs https://github.com/containers/fuse-overlayfs/releases/download/$VER/fuse-overlayfs-x86_64 -chmod 755 /usr/local/bin/fuse-overlayfs -cd ~ -echo -e '{\n "storage-driver": "fuse-overlayfs",\n "log-driver": "journald"\n}' > /etc/docker/daemon.json -else -echo -e '{\n "log-driver": "journald"\n}' > /etc/docker/daemon.json -fi -$STD sh <(curl -sSL https://get.docker.com) -msg_ok "Installed Docker $DOCKER_LATEST_VERSION" - -read -r -p "Would you like to add Portainer? " prompt -if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - msg_info "Installing Portainer $PORTAINER_LATEST_VERSION" - docker volume create portainer_data >/dev/null - $STD docker run -d \ - -p 8000:8000 \ - -p 9000:9000 \ - --name=portainer \ - --restart=always \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -v portainer_data:/data \ - portainer/portainer-ce:latest - msg_ok "Installed Portainer $PORTAINER_LATEST_VERSION" -fi - -read -r -p "Would you like to add Docker Compose? " prompt -if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - msg_info "Installing Docker Compose $DOCKER_COMPOSE_LATEST_VERSION" - DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} - mkdir -p $DOCKER_CONFIG/cli-plugins - curl -sSL https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_LATEST_VERSION/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose - chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose - msg_ok "Installed Docker Compose $DOCKER_COMPOSE_LATEST_VERSION" -fi - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/emby-install.sh b/install/emby-install.sh new file mode 100644 index 00000000..668222f7 --- /dev/null +++ b/install/emby-install.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +if [[ -z "$(grep -w "100000" /proc/self/uid_map)" ]]; then + msg_info "Setting Up Hardware Acceleration" + $STD apt-get -y install \ + va-driver-all \ + ocl-icd-libopencl1 + if [[ ${PCT_OSVERSION} == "20.04" ]]; then + $STD apt-get install -y beignet-opencl-icd + else + $STD apt-get install -y intel-opencl-icd + fi + /bin/chgrp video /dev/dri + /bin/chmod 755 /dev/dri + /bin/chmod 660 /dev/dri/* + msg_ok "Set Up Hardware Acceleration" +fi + +LATEST=$(curl -sL https://api.github.com/repos/MediaBrowser/Emby.Releases/releases/latest | grep '"tag_name":' | cut -d'"' -f4) + +msg_info "Installing Emby" +wget -q https://github.com/MediaBrowser/Emby.Releases/releases/download/${LATEST}/emby-server-deb_${LATEST}_amd64.deb +$STD dpkg -i emby-server-deb_${LATEST}_amd64.deb +msg_ok "Installed Emby" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +rm emby-server-deb_${LATEST}_amd64.deb +msg_ok "Cleaned" diff --git a/install/emby-v5-install.sh b/install/emby-v5-install.sh deleted file mode 100644 index 0a41c2c5..00000000 --- a/install/emby-v5-install.sh +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -if [[ -z "$(grep -w "100000" /proc/self/uid_map)" ]]; then - msg_info "Setting Up Hardware Acceleration" - $STD apt-get -y install \ - va-driver-all \ - ocl-icd-libopencl1 - if [[ ${PCT_OSVERSION} == "20.04" ]]; then - $STD apt-get install -y beignet-opencl-icd - else - $STD apt-get install -y intel-opencl-icd - fi - /bin/chgrp video /dev/dri - /bin/chmod 755 /dev/dri - /bin/chmod 660 /dev/dri/* - msg_ok "Set Up Hardware Acceleration" -fi - -LATEST=$(curl -sL https://api.github.com/repos/MediaBrowser/Emby.Releases/releases/latest | grep '"tag_name":' | cut -d'"' -f4) - -msg_info "Installing Emby" -wget -q https://github.com/MediaBrowser/Emby.Releases/releases/download/${LATEST}/emby-server-deb_${LATEST}_amd64.deb -$STD dpkg -i emby-server-deb_${LATEST}_amd64.deb -msg_ok "Installed Emby" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -rm emby-server-deb_${LATEST}_amd64.deb -msg_ok "Cleaned" diff --git a/install/emqx-install.sh b/install/emqx-install.sh new file mode 100644 index 00000000..74b3c2d3 --- /dev/null +++ b/install/emqx-install.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing EMQX" +$STD bash <(curl -fsSL https://packagecloud.io/install/repositories/emqx/emqx/script.deb.sh) +$STD apt-get install -y emqx +$STD systemctl enable --now emqx +msg_ok "Installed EMQX" + +motd_ssh +root + +msg_info "Cleaning up" +apt-get autoremove >/dev/null +apt-get autoclean >/dev/null +msg_ok "Cleaned" diff --git a/install/emqx-v5-install.sh b/install/emqx-v5-install.sh deleted file mode 100644 index 853a3cdb..00000000 --- a/install/emqx-v5-install.sh +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing EMQX" -$STD bash <(curl -fsSL https://packagecloud.io/install/repositories/emqx/emqx/script.deb.sh) -$STD apt-get install -y emqx -$STD systemctl enable --now emqx -msg_ok "Installed EMQX" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -msg_ok "Cleaned" diff --git a/install/esphome-install.sh b/install/esphome-install.sh new file mode 100644 index 00000000..fe8e8e46 --- /dev/null +++ b/install/esphome-install.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y git +msg_ok "Installed Dependencies" + +msg_info "Installing Python3-pip" +$STD apt-get install -y python3-pip +msg_ok "Installed Python3-pip" + +msg_info "Installing ESPHome" +$STD pip3 install esphome +msg_ok "Installed ESPHome" + +msg_info "Installing ESPHome Dashboard" +$STD pip3 install tornado esptool + +service_path="/etc/systemd/system/esphomeDashboard.service" +echo "[Unit] +Description=ESPHome Dashboard +After=network.target +[Service] +ExecStart=/usr/local/bin/esphome /root/config/ dashboard +Restart=always +User=root +[Install] +WantedBy=multi-user.target" >$service_path +$STD systemctl enable esphomeDashboard.service +systemctl start esphomeDashboard +msg_ok "Installed ESPHome Dashboard" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/esphome-v5-install.sh b/install/esphome-v5-install.sh deleted file mode 100644 index 7bd8b99f..00000000 --- a/install/esphome-v5-install.sh +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y git -msg_ok "Installed Dependencies" - -msg_info "Installing Python3-pip" -$STD apt-get install -y python3-pip -msg_ok "Installed Python3-pip" - -msg_info "Installing ESPHome" -$STD pip3 install esphome -msg_ok "Installed ESPHome" - -msg_info "Installing ESPHome Dashboard" -$STD pip3 install tornado esptool - -service_path="/etc/systemd/system/esphomeDashboard.service" -echo "[Unit] -Description=ESPHome Dashboard -After=network.target -[Service] -ExecStart=/usr/local/bin/esphome /root/config/ dashboard -Restart=always -User=root -[Install] -WantedBy=multi-user.target" >$service_path -$STD systemctl enable esphomeDashboard.service -systemctl start esphomeDashboard -msg_ok "Installed ESPHome Dashboard" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/go2rtc-install.sh b/install/go2rtc-install.sh new file mode 100644 index 00000000..75211aeb --- /dev/null +++ b/install/go2rtc-install.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing go2rtc" +mkdir -p /opt/go2rtc +cd /opt/go2rtc +wget -q https://github.com/AlexxIT/go2rtc/releases/latest/download/go2rtc_linux_amd64 +chmod +x go2rtc_linux_amd64 +msg_ok "Installed go2rtc" + +msg_info "Creating Service" +service_path="/etc/systemd/system/go2rtc.service" +echo "[Unit] +Description=go2rtc service +After=network.target + +[Service] +Type=simple +User=root +ExecStart=/opt/go2rtc/go2rtc_linux_amd64 + +[Install] +WantedBy=multi-user.target" >$service_path +systemctl enable -q --now go2rtc +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/go2rtc-v5-install.sh b/install/go2rtc-v5-install.sh deleted file mode 100644 index 57577695..00000000 --- a/install/go2rtc-v5-install.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing go2rtc" -mkdir -p /opt/go2rtc -cd /opt/go2rtc -wget -q https://github.com/AlexxIT/go2rtc/releases/latest/download/go2rtc_linux_amd64 -chmod +x go2rtc_linux_amd64 -msg_ok "Installed go2rtc" - -msg_info "Creating Service" -service_path="/etc/systemd/system/go2rtc.service" -echo "[Unit] -Description=go2rtc service -After=network.target - -[Service] -Type=simple -User=root -ExecStart=/opt/go2rtc/go2rtc_linux_amd64 - -[Install] -WantedBy=multi-user.target" >$service_path -systemctl enable -q --now go2rtc -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/grafana-install.sh b/install/grafana-install.sh new file mode 100644 index 00000000..718cc230 --- /dev/null +++ b/install/grafana-install.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y gnupg +$STD apt-get install -y apt-transport-https +$STD apt-get install -y software-properties-common +msg_ok "Installed Dependencies" + +msg_info "Setting up Grafana Repository" +wget -q -O /usr/share/keyrings/grafana.key https://apt.grafana.com/gpg.key +sh -c 'echo "deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main" > /etc/apt/sources.list.d/grafana.list' +msg_ok "Set up Grafana Repository" + +msg_info "Installing Grafana" +$STD apt-get update +$STD apt-get install -y grafana +msg_ok "Installed Grafana" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/grafana-v5-install.sh b/install/grafana-v5-install.sh deleted file mode 100644 index 9b327c23..00000000 --- a/install/grafana-v5-install.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y gnupg -$STD apt-get install -y apt-transport-https -$STD apt-get install -y software-properties-common -msg_ok "Installed Dependencies" - -msg_info "Setting up Grafana Repository" -wget -q -O /usr/share/keyrings/grafana.key https://apt.grafana.com/gpg.key -sh -c 'echo "deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main" > /etc/apt/sources.list.d/grafana.list' -msg_ok "Set up Grafana Repository" - -msg_info "Installing Grafana" -$STD apt-get update -$STD apt-get install -y grafana -msg_ok "Installed Grafana" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi -systemctl start grafana-server -$STD systemctl enable grafana-server.service - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/grocy-install.sh b/install/grocy-install.sh new file mode 100644 index 00000000..b51cfbcc --- /dev/null +++ b/install/grocy-install.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y apache2 +$STD apt-get install -y unzip +$STD apt-get install -y apt-transport-https +$STD apt-get install -y lsb-release +msg_ok "Installed Dependencies" + +msg_info "Installing PHP 8.1" +curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg +sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' +$STD apt-get update +$STD apt-get install -y php8.1 +$STD apt-get install -y libapache2-mod-php8.1 +$STD apt-get install -y php8.1-sqlite3 +$STD apt-get install -y php8.1-gd +$STD apt-get install -y php8.1-intl +$STD apt-get install -y php8.1-mbstring +msg_ok "Installed PHP 8.1" + +msg_info "Installing grocy" +wget -q https://releases.grocy.info/latest +$STD unzip latest -d /var/www/html +chown -R www-data:www-data /var/www/html +cp /var/www/html/config-dist.php /var/www/html/data/config.php +chmod +x /var/www/html/update.sh + +cat </etc/apache2/sites-available/grocy.conf + + ServerAdmin webmaster@localhost + DocumentRoot /var/www/html/public + ErrorLog /var/log/apache2/error.log + + Options Indexes FollowSymLinks MultiViews + AllowOverride All + Order allow,deny + allow from all + + +EOF + +$STD a2dissite 000-default.conf +$STD a2ensite grocy.conf +$STD a2enmod rewrite +systemctl reload apache2 +msg_ok "Installed grocy" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +rm -rf /root/latest +msg_ok "Cleaned" diff --git a/install/grocy-v5-install.sh b/install/grocy-v5-install.sh deleted file mode 100644 index f5bf1469..00000000 --- a/install/grocy-v5-install.sh +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y apache2 -$STD apt-get install -y unzip -$STD apt-get install -y apt-transport-https -$STD apt-get install -y lsb-release -msg_ok "Installed Dependencies" - -msg_info "Installing PHP 8.1" -curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg -sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' -$STD apt-get update -$STD apt-get install -y php8.1 -$STD apt-get install -y libapache2-mod-php8.1 -$STD apt-get install -y php8.1-sqlite3 -$STD apt-get install -y php8.1-gd -$STD apt-get install -y php8.1-intl -$STD apt-get install -y php8.1-mbstring -msg_ok "Installed PHP 8.1" - -msg_info "Installing grocy" -wget -q https://releases.grocy.info/latest -$STD unzip latest -d /var/www/html -chown -R www-data:www-data /var/www/html -cp /var/www/html/config-dist.php /var/www/html/data/config.php -chmod +x /var/www/html/update.sh - -cat </etc/apache2/sites-available/grocy.conf - - ServerAdmin webmaster@localhost - DocumentRoot /var/www/html/public - ErrorLog /var/log/apache2/error.log - - Options Indexes FollowSymLinks MultiViews - AllowOverride All - Order allow,deny - allow from all - - -EOF - -$STD a2dissite 000-default.conf -$STD a2ensite grocy.conf -$STD a2enmod rewrite -systemctl reload apache2 -msg_ok "Installed grocy" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -rm -rf /root/latest -msg_ok "Cleaned" diff --git a/install/heimdalldashboard-install.sh b/install/heimdalldashboard-install.sh new file mode 100644 index 00000000..8e83e9ef --- /dev/null +++ b/install/heimdalldashboard-install.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing PHP" +$STD apt-get install -y php +$STD apt-get install -y php-sqlite3 +$STD apt-get install -y php-zip +msg_ok "Installed PHP" + +RELEASE=$(curl -sX GET "https://api.github.com/repos/linuxserver/Heimdall/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]') +msg_info "Installing Heimdall Dashboard ${RELEASE}" +$STD curl --silent -o ${RELEASE}.tar.gz -L "https://github.com/linuxserver/Heimdall/archive/${RELEASE}.tar.gz" +$STD tar xvzf ${RELEASE}.tar.gz +VER=$(curl -s https://api.github.com/repos/linuxserver/Heimdall/releases/latest | + grep "tag_name" | + awk '{print substr($2, 3, length($2)-4) }') +rm -rf ${RELEASE}.tar.gz +mv Heimdall-${VER} /opt/Heimdall +msg_ok "Installed Heimdall Dashboard ${RELEASE}" + +msg_info "Creating Service" +service_path="/etc/systemd/system/heimdall.service" +echo "[Unit] +Description=Heimdall +After=network.target + +[Service] +Restart=always +RestartSec=5 +Type=simple +User=root +WorkingDirectory=/opt/Heimdall +ExecStart="/usr/bin/php" artisan serve --port 7990 --host 0.0.0.0 +TimeoutStopSec=30 + +[Install] +WantedBy=multi-user.target" >$service_path +$STD sudo systemctl enable --now heimdall.service +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/heimdalldashboard-v5-install.sh b/install/heimdalldashboard-v5-install.sh deleted file mode 100644 index 4fcc9888..00000000 --- a/install/heimdalldashboard-v5-install.sh +++ /dev/null @@ -1,153 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing PHP" -$STD apt-get install -y php -$STD apt-get install -y php-sqlite3 -$STD apt-get install -y php-zip -msg_ok "Installed PHP" - -RELEASE=$(curl -sX GET "https://api.github.com/repos/linuxserver/Heimdall/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]') -msg_info "Installing Heimdall Dashboard ${RELEASE}" -$STD curl --silent -o ${RELEASE}.tar.gz -L "https://github.com/linuxserver/Heimdall/archive/${RELEASE}.tar.gz" -$STD tar xvzf ${RELEASE}.tar.gz -VER=$(curl -s https://api.github.com/repos/linuxserver/Heimdall/releases/latest | - grep "tag_name" | - awk '{print substr($2, 3, length($2)-4) }') -rm -rf ${RELEASE}.tar.gz -mv Heimdall-${VER} /opt/Heimdall -msg_ok "Installed Heimdall Dashboard ${RELEASE}" - -msg_info "Creating Service" -service_path="/etc/systemd/system/heimdall.service" -echo "[Unit] -Description=Heimdall -After=network.target - -[Service] -Restart=always -RestartSec=5 -Type=simple -User=root -WorkingDirectory=/opt/Heimdall -ExecStart="/usr/bin/php" artisan serve --port 7990 --host 0.0.0.0 -TimeoutStopSec=30 - -[Install] -WantedBy=multi-user.target" >$service_path -$STD sudo systemctl enable --now heimdall.service -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/homeassistant-core-install.sh b/install/homeassistant-core-install.sh new file mode 100644 index 00000000..d7b64ad1 --- /dev/null +++ b/install/homeassistant-core-install.sh @@ -0,0 +1,107 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies (Patience)" +$STD apt-get install -y \ + make \ + build-essential \ + libjpeg-dev \ + libpcap-dev \ + libssl-dev \ + zlib1g-dev \ + libbz2-dev \ + libreadline-dev \ + libsqlite3-dev \ + libmariadb-dev-compat \ + autoconf \ + git \ + curl \ + sudo \ + mc \ + llvm \ + libncursesw5-dev \ + xz-utils \ + tzdata \ + bluez \ + tk-dev \ + libxml2-dev \ + libxmlsec1-dev \ + libffi-dev \ + libopenjp2-7 \ + libtiff5 \ + libturbojpeg0-dev \ + liblzma-dev +msg_ok "Installed Dependencies" + +msg_info "Installing Linux D-Bus Message Broker" +cat <>/etc/apt/sources.list +deb http://deb.debian.org/debian bullseye-backports main contrib non-free +deb-src http://deb.debian.org/debian bullseye-backports main contrib non-free +EOF +$STD apt-get update +$STD apt-get -t bullseye-backports install -y dbus-broker +$STD systemctl enable --now dbus-broker.service +msg_ok "Installed Linux D-Bus Message Broker" + +msg_info "Installing pyenv" +$STD git clone https://github.com/pyenv/pyenv.git ~/.pyenv +set +e +echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc +echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc +echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init --path)"\nfi' >> ~/.bashrc +msg_ok "Installed pyenv" +. ~/.bashrc +set -e +msg_info "Installing Python 3.11.1" +$STD pyenv install 3.11.1 +pyenv global 3.11.1 +msg_ok "Installed Python 3.11.1" + +msg_info "Installing Home Assistant-Core" +mkdir /srv/homeassistant +cd /srv/homeassistant +python3 -m venv . +source bin/activate +$STD pip install --upgrade pip +$STD python3 -m pip install wheel +$STD pip install mysqlclient +$STD pip install psycopg2-binary +$STD pip install homeassistant +mkdir -p /root/.homeassistant +msg_ok "Installed Home Assistant-Core" + +msg_info "Creating Service" +cat </etc/systemd/system/homeassistant.service +[Unit] +Description=Home Assistant +After=network-online.target +[Service] +Type=simple +WorkingDirectory=/root/.homeassistant +ExecStart=/srv/homeassistant/bin/hass -c "/root/.homeassistant" +RestartForceExitStatus=100 +[Install] +WantedBy=multi-user.target +EOF +$STD systemctl enable --now homeassistant +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/homeassistant-core-v5-install.sh b/install/homeassistant-core-v5-install.sh deleted file mode 100644 index 71f3186d..00000000 --- a/install/homeassistant-core-v5-install.sh +++ /dev/null @@ -1,195 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies (Patience)" -$STD apt-get install -y \ - make \ - build-essential \ - libjpeg-dev \ - libpcap-dev \ - libssl-dev \ - zlib1g-dev \ - libbz2-dev \ - libreadline-dev \ - libsqlite3-dev \ - libmariadb-dev-compat \ - autoconf \ - git \ - curl \ - sudo \ - mc \ - llvm \ - libncursesw5-dev \ - xz-utils \ - tzdata \ - bluez \ - tk-dev \ - libxml2-dev \ - libxmlsec1-dev \ - libffi-dev \ - libopenjp2-7 \ - libtiff5 \ - libturbojpeg0-dev \ - liblzma-dev -msg_ok "Installed Dependencies" - -msg_info "Installing Linux D-Bus Message Broker" -cat <>/etc/apt/sources.list -deb http://deb.debian.org/debian bullseye-backports main contrib non-free -deb-src http://deb.debian.org/debian bullseye-backports main contrib non-free -EOF -$STD apt-get update -$STD apt-get -t bullseye-backports install -y dbus-broker -$STD systemctl enable --now dbus-broker.service -msg_ok "Installed Linux D-Bus Message Broker" - -msg_info "Installing pyenv" -$STD git clone https://github.com/pyenv/pyenv.git ~/.pyenv -set +e -echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc -echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc -echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init --path)"\nfi' >> ~/.bashrc -msg_ok "Installed pyenv" -. ~/.bashrc -set -e -msg_info "Installing Python 3.11.1" -$STD pyenv install 3.11.1 -pyenv global 3.11.1 -msg_ok "Installed Python 3.11.1" - -msg_info "Installing Home Assistant-Core" -mkdir /srv/homeassistant -cd /srv/homeassistant -python3 -m venv . -source bin/activate -$STD pip install --upgrade pip -$STD python3 -m pip install wheel -$STD pip install mysqlclient -$STD pip install psycopg2-binary -$STD pip install homeassistant -mkdir -p /root/.homeassistant -msg_ok "Installed Home Assistant-Core" - -msg_info "Creating Service" -cat </etc/systemd/system/homeassistant.service -[Unit] -Description=Home Assistant -After=network-online.target -[Service] -Type=simple -WorkingDirectory=/root/.homeassistant -ExecStart=/srv/homeassistant/bin/hass -c "/root/.homeassistant" -RestartForceExitStatus=100 -[Install] -WantedBy=multi-user.target -EOF -$STD systemctl enable --now homeassistant -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/homeassistant-install.sh b/install/homeassistant-install.sh new file mode 100644 index 00000000..ab92e64a --- /dev/null +++ b/install/homeassistant-install.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing runlike" +$STD apt-get install -y python3-pip +$STD pip3 install runlike +msg_ok "Installed runlike" + +get_latest_release() { + curl -sL https://api.github.com/repos/$1/releases/latest | grep '"tag_name":' | cut -d'"' -f4 +} + +DOCKER_LATEST_VERSION=$(get_latest_release "moby/moby") +CORE_LATEST_VERSION=$(get_latest_release "home-assistant/core") +PORTAINER_LATEST_VERSION=$(get_latest_release "portainer/portainer") + +msg_info "Installing Docker $DOCKER_LATEST_VERSION" +DOCKER_CONFIG_PATH='/etc/docker/daemon.json' +mkdir -p $(dirname $DOCKER_CONFIG_PATH) +if [ "$ST" == "yes" ]; then +VER=$(curl -s https://api.github.com/repos/containers/fuse-overlayfs/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +cd /usr/local/bin +curl -sSL -o fuse-overlayfs https://github.com/containers/fuse-overlayfs/releases/download/$VER/fuse-overlayfs-x86_64 +chmod 755 /usr/local/bin/fuse-overlayfs +cd ~ +echo -e '{\n "storage-driver": "fuse-overlayfs",\n "log-driver": "journald"\n}' > /etc/docker/daemon.json +else +echo -e '{\n "log-driver": "journald"\n}' > /etc/docker/daemon.json +fi +$STD sh <(curl -sSL https://get.docker.com) +msg_ok "Installed Docker $DOCKER_LATEST_VERSION" + +msg_info "Pulling Portainer $PORTAINER_LATEST_VERSION Image" +$STD docker pull portainer/portainer-ce:latest +msg_ok "Pulled Portainer $PORTAINER_LATEST_VERSION Image" + +msg_info "Installing Portainer $PORTAINER_LATEST_VERSION" +$STD docker volume create portainer_data +$STD docker run -d \ + -p 8000:8000 \ + -p 9000:9000 \ + --name=portainer \ + --restart=always \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v portainer_data:/data \ + portainer/portainer-ce:latest +msg_ok "Installed Portainer $PORTAINER_LATEST_VERSION" + +msg_info "Pulling Home Assistant $CORE_LATEST_VERSION Image" +$STD docker pull homeassistant/home-assistant:stable +msg_ok "Pulled Home Assistant $CORE_LATEST_VERSION Image" + +msg_info "Installing Home Assistant $CORE_LATEST_VERSION" +$STD docker volume create hass_config +$STD docker run -d \ + --name homeassistant \ + --privileged \ + --restart unless-stopped \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v /dev:/dev \ + -v hass_config:/config \ + -v /etc/localtime:/etc/localtime:ro \ + --net=host \ + homeassistant/home-assistant:stable + mkdir /root/hass_config +msg_ok "Installed Home Assistant $CORE_LATEST_VERSION" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/homeassistant-v5-install.sh b/install/homeassistant-v5-install.sh deleted file mode 100644 index 12a5efbc..00000000 --- a/install/homeassistant-v5-install.sh +++ /dev/null @@ -1,180 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing runlike" -$STD apt-get install -y python3-pip -$STD pip3 install runlike -msg_ok "Installed runlike" - -get_latest_release() { - curl -sL https://api.github.com/repos/$1/releases/latest | grep '"tag_name":' | cut -d'"' -f4 -} - -DOCKER_LATEST_VERSION=$(get_latest_release "moby/moby") -CORE_LATEST_VERSION=$(get_latest_release "home-assistant/core") -PORTAINER_LATEST_VERSION=$(get_latest_release "portainer/portainer") - -msg_info "Installing Docker $DOCKER_LATEST_VERSION" -DOCKER_CONFIG_PATH='/etc/docker/daemon.json' -mkdir -p $(dirname $DOCKER_CONFIG_PATH) -if [ "$ST" == "yes" ]; then -VER=$(curl -s https://api.github.com/repos/containers/fuse-overlayfs/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -cd /usr/local/bin -curl -sSL -o fuse-overlayfs https://github.com/containers/fuse-overlayfs/releases/download/$VER/fuse-overlayfs-x86_64 -chmod 755 /usr/local/bin/fuse-overlayfs -cd ~ -echo -e '{\n "storage-driver": "fuse-overlayfs",\n "log-driver": "journald"\n}' > /etc/docker/daemon.json -else -echo -e '{\n "log-driver": "journald"\n}' > /etc/docker/daemon.json -fi -$STD sh <(curl -sSL https://get.docker.com) -msg_ok "Installed Docker $DOCKER_LATEST_VERSION" - -msg_info "Pulling Portainer $PORTAINER_LATEST_VERSION Image" -$STD docker pull portainer/portainer-ce:latest -msg_ok "Pulled Portainer $PORTAINER_LATEST_VERSION Image" - -msg_info "Installing Portainer $PORTAINER_LATEST_VERSION" -$STD docker volume create portainer_data -$STD docker run -d \ - -p 8000:8000 \ - -p 9000:9000 \ - --name=portainer \ - --restart=always \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -v portainer_data:/data \ - portainer/portainer-ce:latest -msg_ok "Installed Portainer $PORTAINER_LATEST_VERSION" - -msg_info "Pulling Home Assistant $CORE_LATEST_VERSION Image" -$STD docker pull homeassistant/home-assistant:stable -msg_ok "Pulled Home Assistant $CORE_LATEST_VERSION Image" - -msg_info "Installing Home Assistant $CORE_LATEST_VERSION" -$STD docker volume create hass_config -$STD docker run -d \ - --name homeassistant \ - --privileged \ - --restart unless-stopped \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -v /dev:/dev \ - -v hass_config:/config \ - -v /etc/localtime:/etc/localtime:ro \ - --net=host \ - homeassistant/home-assistant:stable - mkdir /root/hass_config -msg_ok "Installed Home Assistant $CORE_LATEST_VERSION" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/homebridge-install.sh b/install/homebridge-install.sh new file mode 100644 index 00000000..5c12bbfe --- /dev/null +++ b/install/homebridge-install.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x) +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get install -y nodejs gcc g++ make python net-tools +msg_ok "Installed Node.js" + +msg_info "Installing Homebridge" +$STD npm install -g --unsafe-perm homebridge homebridge-config-ui-x +msg_info "Installed Homebridge" + +msg_info "Creating Service" +$STD hb-service install --user homebridge +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/homebridge-v5-install.sh b/install/homebridge-v5-install.sh deleted file mode 100644 index ac0fec01..00000000 --- a/install/homebridge-v5-install.sh +++ /dev/null @@ -1,132 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x) -msg_ok "Set up Node.js Repository" - -msg_info "Installing Node.js" -$STD apt-get install -y nodejs gcc g++ make python net-tools -msg_ok "Installed Node.js" - -msg_info "Installing Homebridge" -$STD npm install -g --unsafe-perm homebridge homebridge-config-ui-x -msg_info "Installed Homebridge" - -msg_info "Creating Service" -$STD hb-service install --user homebridge -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/homepage-install.sh b/install/homepage-install.sh new file mode 100644 index 00000000..4ebc685e --- /dev/null +++ b/install/homepage-install.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y git +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x) +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get install -y nodejs +$STD npm install -g pnpm +msg_ok "Installed Node.js" + +msg_info "Installing Homepage (Patience)" +$STD git clone https://github.com/benphelps/homepage.git /opt/homepage +cd /opt/homepage +mkdir -p config +cp /opt/homepage/src/skeleton/* /opt/homepage/config +$STD pnpm install +$STD pnpm build +msg_ok "Installed Homepage" + +msg_info "Creating Service" +service_path="/etc/systemd/system/homepage.service" +echo "[Unit] +Description=Homepage +After=network.target +StartLimitIntervalSec=0 +[Service] +Type=simple +Restart=always +RestartSec=1 +User=root +WorkingDirectory=/opt/homepage/ +ExecStart=pnpm start +[Install] +WantedBy=multi-user.target" >$service_path +$STD systemctl enable --now homepage +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/homepage-v5-install.sh b/install/homepage-v5-install.sh deleted file mode 100644 index ca0fe0c4..00000000 --- a/install/homepage-v5-install.sh +++ /dev/null @@ -1,152 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y git -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x) -msg_ok "Set up Node.js Repository" - -msg_info "Installing Node.js" -$STD apt-get install -y nodejs -$STD npm install -g pnpm -msg_ok "Installed Node.js" - -msg_info "Installing Homepage (Patience)" -$STD git clone https://github.com/benphelps/homepage.git /opt/homepage -cd /opt/homepage -mkdir -p config -cp /opt/homepage/src/skeleton/* /opt/homepage/config -$STD pnpm install -$STD pnpm build -msg_ok "Installed Homepage" - -msg_info "Creating Service" -service_path="/etc/systemd/system/homepage.service" -echo "[Unit] -Description=Homepage -After=network.target -StartLimitIntervalSec=0 -[Service] -Type=simple -Restart=always -RestartSec=1 -User=root -WorkingDirectory=/opt/homepage/ -ExecStart=pnpm start -[Install] -WantedBy=multi-user.target" >$service_path -$STD systemctl enable --now homepage -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/homer-install.sh b/install/homer-install.sh new file mode 100644 index 00000000..197af604 --- /dev/null +++ b/install/homer-install.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y unzip +$STD apt-get install -y pip +msg_ok "Installed Dependencies" + +msg_info "Installing Homer" +mkdir -p /opt/homer +cd /opt/homer +wget -q https://github.com/bastienwirtz/homer/releases/latest/download/homer.zip +$STD unzip homer.zip +rm -rf homer.zip +cp assets/config.yml.dist assets/config.yml +msg_ok "Installed Homer" + +msg_info "Creating Service" +cat </etc/systemd/system/homer.service +[Unit] +Description=Homer Dashboard +After=network-online.target +[Service] +Type=simple +WorkingDirectory=/opt/homer +ExecStart=python3 -m http.server 8010 +[Install] +WantedBy=multi-user.target +EOF +$STD systemctl enable --now homer +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/homer-v5-install.sh b/install/homer-v5-install.sh deleted file mode 100644 index 539c4aed..00000000 --- a/install/homer-v5-install.sh +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y unzip -$STD apt-get install -y pip -msg_ok "Installed Dependencies" - -msg_info "Installing Homer" -mkdir -p /opt/homer -cd /opt/homer -wget -q https://github.com/bastienwirtz/homer/releases/latest/download/homer.zip -$STD unzip homer.zip -rm -rf homer.zip -cp assets/config.yml.dist assets/config.yml -msg_ok "Installed Homer" - -msg_info "Creating Service" -cat </etc/systemd/system/homer.service -[Unit] -Description=Homer Dashboard -After=network-online.target -[Service] -Type=simple -WorkingDirectory=/opt/homer -ExecStart=python3 -m http.server 8010 -[Install] -WantedBy=multi-user.target -EOF -$STD systemctl enable --now homer -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/hyperion-install.sh b/install/hyperion-install.sh new file mode 100644 index 00000000..f8a3df3c --- /dev/null +++ b/install/hyperion-install.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y lsb-release +$STD apt-get install -y gpg +$STD apt-get install -y apt-transport-https +msg_ok "Installed Dependencies" + +msg_info "Installing Hyperion" +wget -qO- https://apt.hyperion-project.org/hyperion.pub.key | gpg --dearmor -o /usr/share/keyrings/hyperion.pub.gpg +sh -c 'echo "deb [signed-by=/usr/share/keyrings/hyperion.pub.gpg] https://apt.hyperion-project.org/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/hyperion.list' +$STD apt-get update +$STD apt-get install -y hyperion +$STD systemctl enable --now hyperion@root.service +msg_ok "Installed Hyperion" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove >/dev/null +$STD apt-get autoclean >/dev/null +msg_ok "Cleaned" diff --git a/install/hyperion-v5-install.sh b/install/hyperion-v5-install.sh deleted file mode 100644 index 4e2668f2..00000000 --- a/install/hyperion-v5-install.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y lsb-release -$STD apt-get install -y gpg -$STD apt-get install -y apt-transport-https -msg_ok "Installed Dependencies" - -msg_info "Installing Hyperion" -wget -qO- https://apt.hyperion-project.org/hyperion.pub.key | gpg --dearmor -o /usr/share/keyrings/hyperion.pub.gpg -sh -c 'echo "deb [signed-by=/usr/share/keyrings/hyperion.pub.gpg] https://apt.hyperion-project.org/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/hyperion.list' -$STD apt-get update -$STD apt-get install -y hyperion -$STD systemctl enable --now hyperion@root.service -msg_ok "Installed Hyperion" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove >/dev/null -$STD apt-get autoclean >/dev/null -msg_ok "Cleaned" diff --git a/install/influxdb-install.sh b/install/influxdb-install.sh new file mode 100644 index 00000000..1c501b0b --- /dev/null +++ b/install/influxdb-install.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y lsb-base +$STD apt-get install -y lsb-release +$STD apt-get install -y gnupg2 +msg_ok "Installed Dependencies" + +msg_info "Setting up InfluxDB Repository" +wget -q https://repos.influxdata.com/influxdata-archive_compat.key +cat influxdata-archive_compat.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null +sh -c 'echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main" > /etc/apt/sources.list.d/influxdata.list' +msg_ok "Set up InfluxDB Repository" + +read -r -p "Which version of InfluxDB to install? (1 or 2) " prompt +if [[ $prompt == "2" ]]; then + INFLUX="2" +else + INFLUX="1" +fi + +msg_info "Installing InfluxDB" +$STD apt-get update +if [[ $INFLUX == "2" ]]; then + $STD apt-get install -y influxdb2 +else + $STD apt-get install -y influxdb +fi +$STD systemctl enable --now influxdb +msg_ok "Installed InfluxDB" + +read -r -p "Would you like to add Telegraf? " prompt +if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + msg_info "Installing Telegraf" + $STD apt-get install -y telegraf + msg_ok "Installed Telegraf" +fi + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/influxdb-v5-install.sh b/install/influxdb-v5-install.sh deleted file mode 100644 index 31fe8ece..00000000 --- a/install/influxdb-v5-install.sh +++ /dev/null @@ -1,149 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y lsb-base -$STD apt-get install -y lsb-release -$STD apt-get install -y gnupg2 -msg_ok "Installed Dependencies" - -msg_info "Setting up InfluxDB Repository" -wget -q https://repos.influxdata.com/influxdata-archive_compat.key -cat influxdata-archive_compat.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null -sh -c 'echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main" > /etc/apt/sources.list.d/influxdata.list' -msg_ok "Set up InfluxDB Repository" - -read -r -p "Which version of InfluxDB to install? (1 or 2) " prompt -if [[ $prompt == "2" ]]; then - INFLUX="2" -else - INFLUX="1" -fi - -msg_info "Installing InfluxDB" -$STD apt-get update -if [[ $INFLUX == "2" ]]; then - $STD apt-get install -y influxdb2 -else - $STD apt-get install -y influxdb -fi -$STD systemctl enable --now influxdb -msg_ok "Installed InfluxDB" - -read -r -p "Would you like to add Telegraf? " prompt -if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - msg_info "Installing Telegraf" - $STD apt-get install -y telegraf - msg_ok "Installed Telegraf" -fi - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/iobroker-install.sh b/install/iobroker-install.sh new file mode 100644 index 00000000..5146abea --- /dev/null +++ b/install/iobroker-install.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing ioBroker (Patience)" +$STD bash <(curl -fsSL https://iobroker.net/install.sh) +msg_ok "Installed ioBroker" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/iobroker-v5-install.sh b/install/iobroker-v5-install.sh deleted file mode 100644 index 7c8152b3..00000000 --- a/install/iobroker-v5-install.sh +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing ioBroker (Patience)" -$STD bash <(curl -fsSL https://iobroker.net/install.sh) -msg_ok "Installed ioBroker" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/jackett-install.sh b/install/jackett-install.sh new file mode 100644 index 00000000..b4982d3c --- /dev/null +++ b/install/jackett-install.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing Jackett" +RELEASE=$(wget -q https://github.com/Jackett/Jackett/releases/latest -O - | grep "title>Release" | cut -d " " -f 4) +wget -q https://github.com/Jackett/Jackett/releases/download/$RELEASE/Jackett.Binaries.LinuxAMDx64.tar.gz +tar -xzf Jackett.Binaries.LinuxAMDx64.tar.gz -C /opt +rm -rf Jackett.Binaries.LinuxAMDx64.tar.gz +msg_ok "Installed Jackett" + +msg_info "Creating Service" +cat </etc/systemd/system/jackett.service +[Unit] +Description=Jackett Daemon +After=network.target +[Service] +SyslogIdentifier=jackett +Restart=always +RestartSec=5 +Type=simple +WorkingDirectory=/opt/Jackett +ExecStart=/bin/sh /opt/Jackett/jackett_launcher.sh +TimeoutStopSec=30 +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now jackett.service +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/jackett-v5-install.sh b/install/jackett-v5-install.sh deleted file mode 100644 index 7baee1b1..00000000 --- a/install/jackett-v5-install.sh +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing Jackett" -RELEASE=$(wget -q https://github.com/Jackett/Jackett/releases/latest -O - | grep "title>Release" | cut -d " " -f 4) -wget -q https://github.com/Jackett/Jackett/releases/download/$RELEASE/Jackett.Binaries.LinuxAMDx64.tar.gz -tar -xzf Jackett.Binaries.LinuxAMDx64.tar.gz -C /opt -rm -rf Jackett.Binaries.LinuxAMDx64.tar.gz -msg_ok "Installed Jackett" - -msg_info "Creating Service" -cat </etc/systemd/system/jackett.service -[Unit] -Description=Jackett Daemon -After=network.target -[Service] -SyslogIdentifier=jackett -Restart=always -RestartSec=5 -Type=simple -WorkingDirectory=/opt/Jackett -ExecStart=/bin/sh /opt/Jackett/jackett_launcher.sh -TimeoutStopSec=30 -[Install] -WantedBy=multi-user.target -EOF -systemctl enable -q --now jackett.service -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/jellyfin-install.sh b/install/jellyfin-install.sh new file mode 100644 index 00000000..e0ac97b4 --- /dev/null +++ b/install/jellyfin-install.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y apt-transport-https +$STD apt-get install -y software-properties-common +msg_ok "Installed Dependencies" + +if [[ -z "$(grep -w "100000" /proc/self/uid_map)" ]]; then + msg_info "Setting Up Hardware Acceleration" + $STD apt-get -y install \ + va-driver-all \ + ocl-icd-libopencl1 + if [[ ${PCT_OSVERSION} == "20.04" ]]; then + $STD apt-get install -y beignet-opencl-icd + else + $STD apt-get install -y intel-opencl-icd + fi + /bin/chgrp video /dev/dri + /bin/chmod 755 /dev/dri + /bin/chmod 660 /dev/dri/* + msg_ok "Set Up Hardware Acceleration" +fi + +msg_info "Setting Up Jellyfin Repository" +$STD add-apt-repository universe -y +$STD apt-key add <(curl -fsSL https://repo.jellyfin.org/ubuntu/jellyfin_team.gpg.key) +sh -c 'echo "deb [arch=$(dpkg --print-architecture)] https://repo.jellyfin.org/ubuntu $(lsb_release -c -s) main" > /etc/apt/sources.list.d/jellyfin.list' +msg_ok "Set Up Jellyfin Repository" + +msg_info "Installing Jellyfin" +$STD apt-get update +$STD apt install jellyfin-server -y +$STD apt install jellyfin-ffmpeg5 -y +msg_ok "Installed Jellyfin" + +msg_info "Creating Service" +cat <<'EOF' >/lib/systemd/system/jellyfin.service +[Unit] +Description = Jellyfin Media Server +After = network.target +[Service] +Type = simple +EnvironmentFile = /etc/default/jellyfin +User = root +ExecStart = /usr/bin/jellyfin +Restart = on-failure +TimeoutSec = 15 +[Install] +WantedBy = multi-user.target +EOF +ln -s /usr/share/jellyfin/web/ /usr/lib/jellyfin/bin/jellyfin-web +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/jellyfin-v5-install.sh b/install/jellyfin-v5-install.sh deleted file mode 100644 index 821bfe0e..00000000 --- a/install/jellyfin-v5-install.sh +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y apt-transport-https -$STD apt-get install -y software-properties-common -msg_ok "Installed Dependencies" - -if [[ -z "$(grep -w "100000" /proc/self/uid_map)" ]]; then - msg_info "Setting Up Hardware Acceleration" - $STD apt-get -y install \ - va-driver-all \ - ocl-icd-libopencl1 - if [[ ${PCT_OSVERSION} == "20.04" ]]; then - $STD apt-get install -y beignet-opencl-icd - else - $STD apt-get install -y intel-opencl-icd - fi - /bin/chgrp video /dev/dri - /bin/chmod 755 /dev/dri - /bin/chmod 660 /dev/dri/* - msg_ok "Set Up Hardware Acceleration" -fi - -msg_info "Setting Up Jellyfin Repository" -$STD add-apt-repository universe -y -$STD apt-key add <(curl -fsSL https://repo.jellyfin.org/ubuntu/jellyfin_team.gpg.key) -sh -c 'echo "deb [arch=$(dpkg --print-architecture)] https://repo.jellyfin.org/ubuntu $(lsb_release -c -s) main" > /etc/apt/sources.list.d/jellyfin.list' -msg_ok "Set Up Jellyfin Repository" - -msg_info "Installing Jellyfin" -$STD apt-get update -$STD apt install jellyfin-server -y -$STD apt install jellyfin-ffmpeg5 -y -msg_ok "Installed Jellyfin" - -msg_info "Creating Service" -cat <<'EOF' >/lib/systemd/system/jellyfin.service -[Unit] -Description = Jellyfin Media Server -After = network.target -[Service] -Type = simple -EnvironmentFile = /etc/default/jellyfin -User = root -ExecStart = /usr/bin/jellyfin -Restart = on-failure -TimeoutSec = 15 -[Install] -WantedBy = multi-user.target -EOF -ln -s /usr/share/jellyfin/web/ /usr/lib/jellyfin/bin/jellyfin-web -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/k0s-install.sh b/install/k0s-install.sh new file mode 100644 index 00000000..7e772932 --- /dev/null +++ b/install/k0s-install.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y git +msg_ok "Installed Dependencies" + +msg_info "Installing k0s Kubernetes" +$STD bash <(curl -sSLf https://get.k0s.sh) +$STD k0s install controller --single +$STD k0s start +mkdir -p /etc/k0s +k0s config create > /etc/k0s/k0s.yaml +msg_ok "Installed k0s Kubernetes" + +read -r -p "Would you like to add Helm Package Manager? " prompt +if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then +msg_info "Installing Helm" +$STD bash <(curl -sSLf https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3) +msg_ok "Installed Helm" +fi +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/k0s-v5-install.sh b/install/k0s-v5-install.sh deleted file mode 100644 index c5bb38f5..00000000 --- a/install/k0s-v5-install.sh +++ /dev/null @@ -1,130 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y git -msg_ok "Installed Dependencies" - -msg_info "Installing k0s Kubernetes" -$STD bash <(curl -sSLf https://get.k0s.sh) -$STD k0s install controller --single -$STD k0s start -mkdir -p /etc/k0s -k0s config create > /etc/k0s/k0s.yaml -msg_ok "Installed k0s Kubernetes" - -read -r -p "Would you like to add Helm Package Manager? " prompt -if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then -msg_info "Installing Helm" -$STD bash <(curl -sSLf https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3) -msg_ok "Installed Helm" -fi -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/kavita-install.sh b/install/kavita-install.sh new file mode 100644 index 00000000..72e353d9 --- /dev/null +++ b/install/kavita-install.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing Kavita" +cd /opt +RELEASE=$(curl -s https://api.github.com/repos/Kareadita/Kavita/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +$STD tar -xvzf <(curl -fsSL https://github.com/Kareadita/Kavita/releases/download/$RELEASE/kavita-linux-x64.tar.gz) && +msg_ok "Installed Kavita" + +msg_info "Creating Service" +service_path="/etc/systemd/system/kavita.service" +echo "[Unit] +Description=Kavita Server +After=network.target + +[Service] +Type=simple +WorkingDirectory=/opt/Kavita +ExecStart=/opt/Kavita/Kavita +TimeoutStopSec=20 +KillMode=process +Restart=on-failure + +[Install] +WantedBy=multi-user.target" >$service_path +chmod +x /opt/Kavita/* && chown root /opt/Kavita/* +systemctl enable --now -q kavita.service +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/kavita-v5-install.sh b/install/kavita-v5-install.sh deleted file mode 100644 index fb3d3af2..00000000 --- a/install/kavita-v5-install.sh +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" - - -function error_exit() { - trap - ERR - local reason="Unknown failure occurred." - local msg="${1:-$reason}" - local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" - echo -e "$flag $msg" 1>&2 - exit $EXIT -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing Kavita" -cd /opt -RELEASE=$(curl -s https://api.github.com/repos/Kareadita/Kavita/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -$STD tar -xvzf <(curl -fsSL https://github.com/Kareadita/Kavita/releases/download/$RELEASE/kavita-linux-x64.tar.gz) && -msg_ok "Installed Kavita" - -msg_info "Creating Service" -service_path="/etc/systemd/system/kavita.service" -echo "[Unit] -Description=Kavita Server -After=network.target - -[Service] -Type=simple -WorkingDirectory=/opt/Kavita -ExecStart=/opt/Kavita/Kavita -TimeoutStopSec=20 -KillMode=process -Restart=on-failure - -[Install] -WantedBy=multi-user.target" >$service_path -chmod +x /opt/Kavita/* && chown root /opt/Kavita/* -systemctl enable --now -q kavita.service -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/keycloak-install.sh b/install/keycloak-install.sh new file mode 100644 index 00000000..0dcf8c8f --- /dev/null +++ b/install/keycloak-install.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies (Patience)" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y openjdk-11-jdk +msg_ok "Installed Dependencies" + +RELEASE=$(curl -s https://api.github.com/repos/keycloak/keycloak/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +msg_info "Installing Keycloak v$RELEASE" +cd /opt +wget -q https://github.com/keycloak/keycloak/releases/download/$RELEASE/keycloak-$RELEASE.tar.gz +$STD tar -xvf keycloak-$RELEASE.tar.gz +mv keycloak-$RELEASE keycloak +msg_ok "Installed Keycloak" + +msg_info "Creating Service" +service_path="/etc/systemd/system/keycloak.service" +echo "[Unit] +Description=Keycloak +After=network-online.target +[Service] +User=root +WorkingDirectory=/opt/keycloak +ExecStart=/opt/keycloak/bin/kc.sh start-dev +[Install] +WantedBy=multi-user.target" >$service_path +$STD systemctl enable --now keycloak.service +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/keycloak-v5-install.sh b/install/keycloak-v5-install.sh deleted file mode 100644 index 65fc382c..00000000 --- a/install/keycloak-v5-install.sh +++ /dev/null @@ -1,139 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies (Patience)" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y openjdk-11-jdk -msg_ok "Installed Dependencies" - -RELEASE=$(curl -s https://api.github.com/repos/keycloak/keycloak/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -msg_info "Installing Keycloak v$RELEASE" -cd /opt -wget -q https://github.com/keycloak/keycloak/releases/download/$RELEASE/keycloak-$RELEASE.tar.gz -$STD tar -xvf keycloak-$RELEASE.tar.gz -mv keycloak-$RELEASE keycloak -msg_ok "Installed Keycloak" - -msg_info "Creating Service" -service_path="/etc/systemd/system/keycloak.service" -echo "[Unit] -Description=Keycloak -After=network-online.target -[Service] -User=root -WorkingDirectory=/opt/keycloak -ExecStart=/opt/keycloak/bin/kc.sh start-dev -[Install] -WantedBy=multi-user.target" >$service_path -$STD systemctl enable --now keycloak.service -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/lidarr-install.sh b/install/lidarr-install.sh new file mode 100644 index 00000000..a7ec14d2 --- /dev/null +++ b/install/lidarr-install.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y sqlite3 +$STD apt-get install -y libchromaprint-tools +$STD apt-get install -y mediainfo +msg_ok "Installed Dependencies" + +msg_info "Installing Lidarr" +mkdir -p /var/lib/lidarr/ +chmod 775 /var/lib/lidarr/ +$STD wget --content-disposition 'https://lidarr.servarr.com/v1/update/master/updatefile?os=linux&runtime=netcore&arch=x64' +$STD tar -xvzf Lidarr.master.*.tar.gz +mv Lidarr /opt +chmod 775 /opt/Lidarr +msg_ok "Installed Lidarr" + +msg_info "Creating Service" +cat </etc/systemd/system/lidarr.service +[Unit] +Description=Lidarr Daemon +After=syslog.target network.target +[Service] +UMask=0002 +Type=simple +ExecStart=/opt/Lidarr/Lidarr -nobrowser -data=/var/lib/lidarr/ +TimeoutStopSec=20 +KillMode=process +Restart=on-failure +[Install] +WantedBy=multi-user.target +EOF +systemctl -q daemon-reload +systemctl enable --now -q lidarr +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +rm -rf Lidarr.master.*.tar.gz +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/lidarr-v5-install.sh b/install/lidarr-v5-install.sh deleted file mode 100644 index 35354173..00000000 --- a/install/lidarr-v5-install.sh +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y sqlite3 -$STD apt-get install -y libchromaprint-tools -$STD apt-get install -y mediainfo -msg_ok "Installed Dependencies" - -msg_info "Installing Lidarr" -mkdir -p /var/lib/lidarr/ -chmod 775 /var/lib/lidarr/ -$STD wget --content-disposition 'https://lidarr.servarr.com/v1/update/master/updatefile?os=linux&runtime=netcore&arch=x64' -$STD tar -xvzf Lidarr.master.*.tar.gz -mv Lidarr /opt -chmod 775 /opt/Lidarr -msg_ok "Installed Lidarr" - -msg_info "Creating Service" -cat </etc/systemd/system/lidarr.service -[Unit] -Description=Lidarr Daemon -After=syslog.target network.target -[Service] -UMask=0002 -Type=simple -ExecStart=/opt/Lidarr/Lidarr -nobrowser -data=/var/lib/lidarr/ -TimeoutStopSec=20 -KillMode=process -Restart=on-failure -[Install] -WantedBy=multi-user.target -EOF -systemctl -q daemon-reload -systemctl enable --now -q lidarr -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -rm -rf Lidarr.master.*.tar.gz -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/magicmirror-v5-install.sh b/install/magicmirror-install.sh similarity index 61% rename from install/magicmirror-v5-install.sh rename to install/magicmirror-install.sh index 3cfc369d..249f46a6 100644 --- a/install/magicmirror-v5-install.sh +++ b/install/magicmirror-install.sh @@ -5,86 +5,13 @@ # License: MIT # https://github.com/tteck/Proxmox/raw/main/LICENSE -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os msg_info "Installing Dependencies" $STD apt-get install -y curl @@ -220,23 +147,8 @@ WantedBy=multi-user.target" >$service_path $STD systemctl enable --now magicmirror msg_ok "Created Service" -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi +motd_ssh +root msg_info "Cleaning up" $STD apt-get autoremove diff --git a/install/mariadb-install.sh b/install/mariadb-install.sh new file mode 100644 index 00000000..a3326a35 --- /dev/null +++ b/install/mariadb-install.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing MariaDB" +$STD bash <(curl -fsSL https://r.mariadb.com/downloads/mariadb_repo_setup) +$STD apt-get update +$STD apt-get install -y mariadb-server +msg_ok "Installed MariaDB" + +read -r -p "Would you like to add Adminer? " prompt +if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + msg_info "Installing Adminer" + $STD apt install -y adminer + $STD a2enconf adminer + systemctl reload apache2 + msg_ok "Installed Adminer" +fi + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/mariadb-v5-install.sh b/install/mariadb-v5-install.sh deleted file mode 100644 index 63b2899e..00000000 --- a/install/mariadb-v5-install.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing MariaDB" -$STD bash <(curl -fsSL https://r.mariadb.com/downloads/mariadb_repo_setup) -$STD apt-get update -$STD apt-get install -y mariadb-server -msg_ok "Installed MariaDB" - -read -r -p "Would you like to add Adminer? " prompt -if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - msg_info "Installing Adminer" - $STD apt install -y adminer - $STD a2enconf adminer - systemctl reload apache2 - msg_ok "Installed Adminer" -fi - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/meshcentral-install.sh b/install/meshcentral-install.sh new file mode 100644 index 00000000..3defc5eb --- /dev/null +++ b/install/meshcentral-install.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x) +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing MeshCentral" +mkdir /opt/meshcentral +cd /opt/meshcentral +$STD npm install meshcentral +$STD node node_modules/meshcentral --install +msg_ok "Installed MeshCentral" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/meshcentral-v5-install.sh b/install/meshcentral-v5-install.sh deleted file mode 100644 index f0b22abb..00000000 --- a/install/meshcentral-v5-install.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x) -msg_ok "Set up Node.js Repository" - -msg_info "Installing Node.js" -$STD apt-get install -y nodejs -msg_ok "Installed Node.js" - -msg_info "Installing MeshCentral" -mkdir /opt/meshcentral -cd /opt/meshcentral -$STD npm install meshcentral -$STD node node_modules/meshcentral --install -msg_ok "Installed MeshCentral" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/motioneye-install.sh b/install/motioneye-install.sh new file mode 100644 index 00000000..69489209 --- /dev/null +++ b/install/motioneye-install.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y cifs-utils +msg_ok "Installed Dependencies" + +msg_info "Installing Motion" +$STD apt-get install -y motion +systemctl stop motion +$STD systemctl disable motion +msg_ok "Installed Motion" + +msg_info "Installing FFmpeg" +$STD apt-get install -y ffmpeg v4l-utils +msg_ok "Installed FFmpeg" + +msg_info "Installing Python" +$STD apt-get update +$STD apt-get install -y python2 +curl -sSL https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py +$STD python2 get-pip.py +$STD apt-get install -y libffi-dev libzbar-dev libzbar0 +$STD apt-get install -y python2-dev libssl-dev libcurl4-openssl-dev libjpeg-dev +msg_ok "Installed Python" + +msg_info "Installing MotionEye" +$STD apt-get update +$STD pip install motioneye +mkdir -p /etc/motioneye +cp /usr/local/share/motioneye/extra/motioneye.conf.sample /etc/motioneye/motioneye.conf +mkdir -p /var/lib/motioneye +msg_ok "Installed MotionEye" + +msg_info "Creating Service" +cp /usr/local/share/motioneye/extra/motioneye.systemd-unit-local /etc/systemd/system/motioneye.service +$STD systemctl enable motioneye +systemctl start motioneye +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/motioneye-v5-install.sh b/install/motioneye-v5-install.sh deleted file mode 100644 index 14ea8991..00000000 --- a/install/motioneye-v5-install.sh +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y cifs-utils -msg_ok "Installed Dependencies" - -msg_info "Installing Motion" -$STD apt-get install -y motion -systemctl stop motion -$STD systemctl disable motion -msg_ok "Installed Motion" - -msg_info "Installing FFmpeg" -$STD apt-get install -y ffmpeg v4l-utils -msg_ok "Installed FFmpeg" - -msg_info "Installing Python" -$STD apt-get update -$STD apt-get install -y python2 -curl -sSL https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py -$STD python2 get-pip.py -$STD apt-get install -y libffi-dev libzbar-dev libzbar0 -$STD apt-get install -y python2-dev libssl-dev libcurl4-openssl-dev libjpeg-dev -msg_ok "Installed Python" - -msg_info "Installing MotionEye" -$STD apt-get update -$STD pip install motioneye -mkdir -p /etc/motioneye -cp /usr/local/share/motioneye/extra/motioneye.conf.sample /etc/motioneye/motioneye.conf -mkdir -p /var/lib/motioneye -msg_ok "Installed MotionEye" - -msg_info "Creating Service" -cp /usr/local/share/motioneye/extra/motioneye.systemd-unit-local /etc/systemd/system/motioneye.service -$STD systemctl enable motioneye -systemctl start motioneye -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/mqtt-install.sh b/install/mqtt-install.sh new file mode 100644 index 00000000..135abf56 --- /dev/null +++ b/install/mqtt-install.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y gnupg +msg_ok "Installed Dependencies" + +msg_info "Installing Mosquitto MQTT Broker" +$STD wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key +$STD apt-key add mosquitto-repo.gpg.key +cd /etc/apt/sources.list.d/ +$STD wget http://repo.mosquitto.org/debian/mosquitto-bullseye.list +$STD apt-get update +$STD apt-get -y install mosquitto +$STD apt-get -y install mosquitto-clients +msg_ok "Installed Mosquitto MQTT Broker" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/mqtt-v5-install.sh b/install/mqtt-v5-install.sh deleted file mode 100644 index 3f13f8a4..00000000 --- a/install/mqtt-v5-install.sh +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y gnupg -msg_ok "Installed Dependencies" - -msg_info "Installing Mosquitto MQTT Broker" -$STD wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key -$STD apt-key add mosquitto-repo.gpg.key -cd /etc/apt/sources.list.d/ -$STD wget http://repo.mosquitto.org/debian/mosquitto-bullseye.list -$STD apt-get update -$STD apt-get -y install mosquitto -$STD apt-get -y install mosquitto-clients -msg_ok "Installed Mosquitto MQTT Broker" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/n8n-install.sh b/install/n8n-install.sh new file mode 100644 index 00000000..7e735a09 --- /dev/null +++ b/install/n8n-install.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x) +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing n8n (Patience)" +$STD npm install --global n8n +msg_ok "Installed n8n" + +msg_info "Creating Service" +cat </etc/systemd/system/n8n.service +[Unit] +Description=n8n + +[Service] +Type=simple +ExecStart=n8n start +[Install] +WantedBy=multi-user.target +EOF +$STD systemctl enable --now n8n +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/n8n-v5-install.sh b/install/n8n-v5-install.sh deleted file mode 100644 index 76a45c05..00000000 --- a/install/n8n-v5-install.sh +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x) -msg_ok "Set up Node.js Repository" - -msg_info "Installing Node.js" -$STD apt-get install -y nodejs -msg_ok "Installed Node.js" - -msg_info "Installing n8n (Patience)" -$STD npm install --global n8n -msg_ok "Installed n8n" - -msg_info "Creating Service" -cat </etc/systemd/system/n8n.service -[Unit] -Description=n8n - -[Service] -Type=simple -ExecStart=n8n start -[Install] -WantedBy=multi-user.target -EOF -$STD systemctl enable --now n8n -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/navidrome-install.sh b/install/navidrome-install.sh new file mode 100644 index 00000000..67f255a2 --- /dev/null +++ b/install/navidrome-install.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies (patience)" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y ffmpeg +msg_ok "Installed Dependencies" + +RELEASE=$(curl -s https://api.github.com/repos/navidrome/navidrome/releases/latest | + grep "tag_name" | + awk '{print substr($2, 3, length($2)-4) }') + +msg_info "Installing Navidrome" +install -d -o root -g root /opt/navidrome +install -d -o root -g root /var/lib/navidrome +$STD wget https://github.com/navidrome/navidrome/releases/download/v${RELEASE}/navidrome_${RELEASE}_Linux_x86_64.tar.gz -O Navidrome.tar.gz +$STD tar -xvzf Navidrome.tar.gz -C /opt/navidrome/ +chown -R root:root /opt/navidrome +mkdir -p /music +cat </var/lib/navidrome/navidrome.toml +MusicFolder = '/music' +EOF +msg_ok "Installed Navidrome" + +msg_info "Creating Service" +service_path="/etc/systemd/system/navidrome.service" + +echo "[Unit] +Description=Navidrome Music Server and Streamer compatible with Subsonic/Airsonic +After=remote-fs.target network.target +AssertPathExists=/var/lib/navidrome + +[Service] +User=root +Group=root +Type=simple +ExecStart=/opt/navidrome/navidrome --configfile '/var/lib/navidrome/navidrome.toml' +WorkingDirectory=/var/lib/navidrome +TimeoutStopSec=20 +KillMode=process +Restart=on-failure +DevicePolicy=closed +NoNewPrivileges=yes +PrivateTmp=yes +PrivateUsers=yes +ProtectControlGroups=yes +ProtectKernelModules=yes +ProtectKernelTunables=yes +RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 +RestrictNamespaces=yes +RestrictRealtime=yes +SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap +ReadWritePaths=/var/lib/navidrome +ProtectSystem=full + +[Install] +WantedBy=multi-user.target" >$service_path +systemctl daemon-reload +$STD systemctl enable --now navidrome.service + +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +rm -rf /root/Navidrome.tar.gz +msg_ok "Cleaned" diff --git a/install/navidrome-v5-install.sh b/install/navidrome-v5-install.sh deleted file mode 100644 index 67a38067..00000000 --- a/install/navidrome-v5-install.sh +++ /dev/null @@ -1,171 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies (patience)" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y ffmpeg -msg_ok "Installed Dependencies" - -RELEASE=$(curl -s https://api.github.com/repos/navidrome/navidrome/releases/latest | - grep "tag_name" | - awk '{print substr($2, 3, length($2)-4) }') - -msg_info "Installing Navidrome" -install -d -o root -g root /opt/navidrome -install -d -o root -g root /var/lib/navidrome -$STD wget https://github.com/navidrome/navidrome/releases/download/v${RELEASE}/navidrome_${RELEASE}_Linux_x86_64.tar.gz -O Navidrome.tar.gz -$STD tar -xvzf Navidrome.tar.gz -C /opt/navidrome/ -chown -R root:root /opt/navidrome -mkdir -p /music -cat </var/lib/navidrome/navidrome.toml -MusicFolder = '/music' -EOF -msg_ok "Installed Navidrome" - -msg_info "Creating Service" -service_path="/etc/systemd/system/navidrome.service" - -echo "[Unit] -Description=Navidrome Music Server and Streamer compatible with Subsonic/Airsonic -After=remote-fs.target network.target -AssertPathExists=/var/lib/navidrome - -[Service] -User=root -Group=root -Type=simple -ExecStart=/opt/navidrome/navidrome --configfile '/var/lib/navidrome/navidrome.toml' -WorkingDirectory=/var/lib/navidrome -TimeoutStopSec=20 -KillMode=process -Restart=on-failure -DevicePolicy=closed -NoNewPrivileges=yes -PrivateTmp=yes -PrivateUsers=yes -ProtectControlGroups=yes -ProtectKernelModules=yes -ProtectKernelTunables=yes -RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 -RestrictNamespaces=yes -RestrictRealtime=yes -SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap -ReadWritePaths=/var/lib/navidrome -ProtectSystem=full - -[Install] -WantedBy=multi-user.target" >$service_path -systemctl daemon-reload -$STD systemctl enable --now navidrome.service - -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -rm -rf /root/Navidrome.tar.gz -msg_ok "Cleaned" diff --git a/install/nextcloudpi-install.sh b/install/nextcloudpi-install.sh new file mode 100644 index 00000000..0e73cb55 --- /dev/null +++ b/install/nextcloudpi-install.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing NextCloudPi (Patience)" +$STD bash <(curl -fsSL https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/install.sh) +sed -i "s/3 => 'nextcloudpi.lan',/3 => '0.0.0.0',/g" /var/www/nextcloud/config/config.php +sed -i '{s|root:/usr/sbin/nologin|root:/bin/bash|g}' /etc/passwd +service apache2 restart +msg_ok "Installed NextCloudPi" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/nextcloudpi-v5-install.sh b/install/nextcloudpi-v5-install.sh deleted file mode 100644 index 6ccada06..00000000 --- a/install/nextcloudpi-v5-install.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing NextCloudPi (Patience)" -$STD bash <(curl -fsSL https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/install.sh) -sed -i "s/3 => 'nextcloudpi.lan',/3 => '0.0.0.0',/g" /var/www/nextcloud/config/config.php -sed -i '{s|root:/usr/sbin/nologin|root:/bin/bash|g}' /etc/passwd -service apache2 restart -msg_ok "Installed NextCloudPi" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/nginxproxymanager-v5-install.sh b/install/nginxproxymanager-install.sh similarity index 62% rename from install/nginxproxymanager-v5-install.sh rename to install/nginxproxymanager-install.sh index d66e0adf..b2baa37f 100644 --- a/install/nginxproxymanager-v5-install.sh +++ b/install/nginxproxymanager-install.sh @@ -5,86 +5,13 @@ # License: MIT # https://github.com/tteck/Proxmox/raw/main/LICENSE -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os msg_info "Installing Dependencies" $STD apt-get update @@ -250,23 +177,8 @@ WantedBy=multi-user.target EOF msg_ok "Created Service" -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi +motd_ssh +root msg_info "Starting Services" $STD systemctl enable --now openresty diff --git a/install/nocodb-install.sh b/install/nocodb-install.sh new file mode 100644 index 00000000..63bf1ca6 --- /dev/null +++ b/install/nocodb-install.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y git +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x) +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD sudo apt-get install -y nodejs git make g++ gcc +msg_ok "Installed Node.js" + +msg_info "Installing NocoDB" +$STD git clone https://github.com/nocodb/nocodb-seed +mv nocodb-seed /opt/nocodb +cd /opt/nocodb +$STD npm install +msg_ok "Installed NocoDB" + +msg_info "Creating Service" +service_path="/etc/systemd/system/nocodb.service" +echo "[Unit] +Description=nocodb + +[Service] +Type=simple +Restart=always +User=root +WorkingDirectory=/opt/nocodb +ExecStart=/usr/bin/npm start + +[Install] +WantedBy=multi-user.target" >$service_path +systemctl enable --now nocodb.service &>/dev/null +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/nocodb-v5-install.sh b/install/nocodb-v5-install.sh deleted file mode 100644 index fb618460..00000000 --- a/install/nocodb-v5-install.sh +++ /dev/null @@ -1,149 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y git -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x) -msg_ok "Set up Node.js Repository" - -msg_info "Installing Node.js" -$STD sudo apt-get install -y nodejs git make g++ gcc -msg_ok "Installed Node.js" - -msg_info "Installing NocoDB" -$STD git clone https://github.com/nocodb/nocodb-seed -mv nocodb-seed /opt/nocodb -cd /opt/nocodb -$STD npm install -msg_ok "Installed NocoDB" - -msg_info "Creating Service" -service_path="/etc/systemd/system/nocodb.service" -echo "[Unit] -Description=nocodb - -[Service] -Type=simple -Restart=always -User=root -WorkingDirectory=/opt/nocodb -ExecStart=/usr/bin/npm start - -[Install] -WantedBy=multi-user.target" >$service_path -systemctl enable --now nocodb.service &>/dev/null -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/node-red-install.sh b/install/node-red-install.sh new file mode 100644 index 00000000..fd2760f4 --- /dev/null +++ b/install/node-red-install.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y git +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +$STD bash <(curl -fsSL https://deb.nodesource.com/setup_18.x) +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing Node-Red" +$STD npm install -g --unsafe-perm node-red +msg_ok "Installed Node-Red" + +msg_info "Creating Service" +service_path="/etc/systemd/system/nodered.service" +echo "[Unit] +Description=Node-RED +After=syslog.target network.target + +[Service] +ExecStart=/usr/bin/node-red --max-old-space-size=128 -v +Restart=on-failure +KillSignal=SIGINT + +SyslogIdentifier=node-red +StandardOutput=syslog + +WorkingDirectory=/root/ +User=root +Group=root + +[Install] +WantedBy=multi-user.target" >$service_path +$STD systemctl enable --now nodered.service +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/node-red-v5-install.sh b/install/node-red-v5-install.sh deleted file mode 100644 index e20934ef..00000000 --- a/install/node-red-v5-install.sh +++ /dev/null @@ -1,152 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y git -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -$STD bash <(curl -fsSL https://deb.nodesource.com/setup_18.x) -msg_ok "Set up Node.js Repository" - -msg_info "Installing Node.js" -$STD apt-get install -y nodejs -msg_ok "Installed Node.js" - -msg_info "Installing Node-Red" -$STD npm install -g --unsafe-perm node-red -msg_ok "Installed Node-Red" - -msg_info "Creating Service" -service_path="/etc/systemd/system/nodered.service" -echo "[Unit] -Description=Node-RED -After=syslog.target network.target - -[Service] -ExecStart=/usr/bin/node-red --max-old-space-size=128 -v -Restart=on-failure -KillSignal=SIGINT - -SyslogIdentifier=node-red -StandardOutput=syslog - -WorkingDirectory=/root/ -User=root -Group=root - -[Install] -WantedBy=multi-user.target" >$service_path -$STD systemctl enable --now nodered.service -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/omada-install.sh b/install/omada-install.sh new file mode 100644 index 00000000..0bc5fe85 --- /dev/null +++ b/install/omada-install.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y gnupg +$STD apt-get install -y openjdk-8-jre-headless +$STD apt-get install -y jsvc +wget -qL https://repo.mongodb.org/apt/ubuntu/dists/bionic/mongodb-org/3.6/multiverse/binary-amd64/mongodb-org-server_3.6.23_amd64.deb +$STD dpkg -i mongodb-org-server_3.6.23_amd64.deb +msg_ok "Installed Dependencies" + +msg_info "Installing Omada Controller v5.9.31" +wget -qL https://static.tp-link.com/upload/software/2023/202303/20230321/Omada_SDN_Controller_v5.9.31_Linux_x64.deb +$STD dpkg -i Omada_SDN_Controller_v5.9.31_Linux_x64.deb +msg_ok "Installed Omada Controller" + +motd_ssh +root + +msg_info "Cleaning up" +rm -rf Omada_SDN_Controller_v5.9.9_Linux_x64.deb mongodb-org-server_3.6.23_amd64.deb +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/omada-v5-install.sh b/install/omada-v5-install.sh deleted file mode 100644 index 6e79e690..00000000 --- a/install/omada-v5-install.sh +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y gnupg -$STD apt-get install -y openjdk-8-jre-headless -$STD apt-get install -y jsvc -wget -qL https://repo.mongodb.org/apt/ubuntu/dists/bionic/mongodb-org/3.6/multiverse/binary-amd64/mongodb-org-server_3.6.23_amd64.deb -$STD dpkg -i mongodb-org-server_3.6.23_amd64.deb -msg_ok "Installed Dependencies" - -msg_info "Installing Omada Controller v5.9.9" -wget -qL https://static.tp-link.com/upload/software/2023/202302/20230227/Omada_SDN_Controller_v5.9.9_Linux_x64.deb -$STD dpkg -i Omada_SDN_Controller_v5.9.9_Linux_x64.deb -msg_ok "Installed Omada Controller" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -rm -rf Omada_SDN_Controller_v5.9.9_Linux_x64.deb mongodb-org-server_3.6.23_amd64.deb -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/omv-install.sh b/install/omv-install.sh new file mode 100644 index 00000000..fbc2f03b --- /dev/null +++ b/install/omv-install.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y gnupg +msg_ok "Installed Dependencies" + +msg_info "Installing OpenMediaVault (Patience)" +wget -q -O "/etc/apt/trusted.gpg.d/openmediavault-archive-keyring.asc" https://packages.openmediavault.org/public/archive.key +$STD apt-key add "/etc/apt/trusted.gpg.d/openmediavault-archive-keyring.asc" &>/dev/null + +cat <>/etc/apt/sources.list.d/openmediavault.list +deb https://packages.openmediavault.org/public shaitan main +# deb https://downloads.sourceforge.net/project/openmediavault/packages shaitan main +## Uncomment the following line to add software from the proposed repository. +# deb https://packages.openmediavault.org/public shaitan-proposed main +# deb https://downloads.sourceforge.net/project/openmediavault/packages shaitan-proposed main +## This software is not part of OpenMediaVault, but is offered by third-party +## developers as a service to OpenMediaVault users. +# deb https://packages.openmediavault.org/public shaitan partner +# deb https://downloads.sourceforge.net/project/openmediavault/packages shaitan partner +EOF +$STD apt-get update +$STD apt-get -y install openmediavault-keyring +$STD apt-get --yes --auto-remove --show-upgraded --allow-downgrades --allow-change-held-packages --no-install-recommends install openmediavault +omv-confdbadm populate +msg_ok "Installed OpenMediaVault" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/omv-v5-install.sh b/install/omv-v5-install.sh deleted file mode 100644 index 6f0e8a1e..00000000 --- a/install/omv-v5-install.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -export DEBIAN_FRONTEND=noninteractive -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y gnupg -msg_ok "Installed Dependencies" - -msg_info "Installing OpenMediaVault (Patience)" -wget -q -O "/etc/apt/trusted.gpg.d/openmediavault-archive-keyring.asc" https://packages.openmediavault.org/public/archive.key -$STD apt-key add "/etc/apt/trusted.gpg.d/openmediavault-archive-keyring.asc" &>/dev/null - -cat <>/etc/apt/sources.list.d/openmediavault.list -deb https://packages.openmediavault.org/public shaitan main -# deb https://downloads.sourceforge.net/project/openmediavault/packages shaitan main -## Uncomment the following line to add software from the proposed repository. -# deb https://packages.openmediavault.org/public shaitan-proposed main -# deb https://downloads.sourceforge.net/project/openmediavault/packages shaitan-proposed main -## This software is not part of OpenMediaVault, but is offered by third-party -## developers as a service to OpenMediaVault users. -# deb https://packages.openmediavault.org/public shaitan partner -# deb https://downloads.sourceforge.net/project/openmediavault/packages shaitan partner -EOF -$STD apt-get update -$STD apt-get -y install openmediavault-keyring -$STD apt-get --yes --auto-remove --show-upgraded --allow-downgrades --allow-change-held-packages --no-install-recommends install openmediavault -omv-confdbadm populate -msg_ok "Installed OpenMediaVault" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/openhab-install.sh b/install/openhab-install.sh new file mode 100644 index 00000000..43d5454b --- /dev/null +++ b/install/openhab-install.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y gnupg +$STD apt-get install -y apt-transport-https +msg_ok "Installed Dependencies" + +msg_info "Installing Azul Zulu" +$STD apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xB1998361219BD9C9 +wget -q https://cdn.azul.com/zulu/bin/zulu-repo_1.0.0-3_all.deb +$STD apt-get install ./zulu-repo_1.0.0-3_all.deb +$STD apt-get update +$STD apt-get -y install zulu11-jdk +msg_ok "Installed Azul Zulu" + +msg_info "Installing openHAB" +curl -fsSL "https://openhab.jfrog.io/artifactory/api/gpg/key/public" | gpg --dearmor >openhab.gpg +mv openhab.gpg /usr/share/keyrings +chmod u=rw,g=r,o=r /usr/share/keyrings/openhab.gpg +sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/openhab.gpg] https://openhab.jfrog.io/artifactory/openhab-linuxpkg stable main" > /etc/apt/sources.list.d/openhab.list' +$STD apt update +$STD apt-get -y install openhab +systemctl daemon-reload +$STD systemctl enable --now openhab.service +msg_ok "Installed openHAB" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/openhab-v5-install.sh b/install/openhab-v5-install.sh deleted file mode 100644 index 1899ae34..00000000 --- a/install/openhab-v5-install.sh +++ /dev/null @@ -1,137 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y gnupg -$STD apt-get install -y apt-transport-https -msg_ok "Installed Dependencies" - -msg_info "Installing Azul Zulu" -$STD apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xB1998361219BD9C9 -wget -q https://cdn.azul.com/zulu/bin/zulu-repo_1.0.0-3_all.deb -$STD apt-get install ./zulu-repo_1.0.0-3_all.deb -$STD apt-get update -$STD apt-get -y install zulu11-jdk -msg_ok "Installed Azul Zulu" - -msg_info "Installing openHAB" -curl -fsSL "https://openhab.jfrog.io/artifactory/api/gpg/key/public" | gpg --dearmor >openhab.gpg -mv openhab.gpg /usr/share/keyrings -chmod u=rw,g=r,o=r /usr/share/keyrings/openhab.gpg -sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/openhab.gpg] https://openhab.jfrog.io/artifactory/openhab-linuxpkg stable main" > /etc/apt/sources.list.d/openhab.list' -$STD apt update -$STD apt-get -y install openhab -systemctl daemon-reload -$STD systemctl enable --now openhab.service -msg_ok "Installed openHAB" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/paperless-ngx-v5-install.sh b/install/paperless-ngx-install.sh similarity index 64% rename from install/paperless-ngx-v5-install.sh rename to install/paperless-ngx-install.sh index 5efaa813..8d31b183 100644 --- a/install/paperless-ngx-v5-install.sh +++ b/install/paperless-ngx-install.sh @@ -5,86 +5,13 @@ # License: MIT # https://github.com/tteck/Proxmox/raw/main/LICENSE -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os msg_info "Installing Python3" $STD apt-get install -y --no-install-recommends \ @@ -263,26 +190,10 @@ sed -i -e 's/rights="none" pattern="PDF"/rights="read|write" pattern="PDF"/' /et systemctl daemon-reload $STD systemctl enable --now paperless-consumer paperless-webserver paperless-scheduler paperless-task-queue.service - msg_ok "Created Services" -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi +motd_ssh +root msg_info "Cleaning up" $STD apt-get autoremove diff --git a/install/photoprism-v5-install.sh b/install/photoprism-install.sh similarity index 53% rename from install/photoprism-v5-install.sh rename to install/photoprism-install.sh index ac39c48d..92c00afb 100644 --- a/install/photoprism-v5-install.sh +++ b/install/photoprism-install.sh @@ -5,86 +5,13 @@ # License: MIT # https://github.com/tteck/Proxmox/raw/main/LICENSE -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os msg_info "Installing Dependencies (Patience)" $STD apt-get install -y curl @@ -191,23 +118,8 @@ ExecStop=/opt/photoprism/bin/photoprism down WantedBy=multi-user.target" >$service_path msg_ok "Created Service" -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi +motd_ssh +root msg_info "Cleaning up" $STD apt-get autoremove diff --git a/install/pihole-install.sh b/install/pihole-install.sh new file mode 100644 index 00000000..8cf049f7 --- /dev/null +++ b/install/pihole-install.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y ufw +$STD apt-get install -y ntp +msg_ok "Installed Dependencies" + +msg_info "Installing Pi-hole" +systemctl stop systemd-resolved +echo "DNSStubListener=no" >>/etc/systemd/resolved.conf +ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf +mkdir -p /etc/pihole/ +cat </etc/pihole/setupVars.conf +PIHOLE_INTERFACE=eth0 +PIHOLE_DNS_1=8.8.8.8 +PIHOLE_DNS_2=8.8.4.4 +QUERY_LOGGING=true +INSTALL_WEB_SERVER=true +INSTALL_WEB_INTERFACE=true +LIGHTTPD_ENABLED=true +CACHE_SIZE=10000 +DNS_FQDN_REQUIRED=true +DNS_BOGUS_PRIV=true +DNSMASQ_LISTENING=local +WEBPASSWORD=$(openssl rand -base64 48) +BLOCKING_ENABLED=true +EOF + +$STD bash <(curl -fsSL https://install.pi-hole.net) /dev/stdin --unattended +msg_ok "Installed Pi-hole" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/pihole-v5-install.sh b/install/pihole-v5-install.sh deleted file mode 100644 index 63df2f5b..00000000 --- a/install/pihole-v5-install.sh +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -export DEBIAN_FRONTEND=noninteractive -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y ufw -$STD apt-get install -y ntp -msg_ok "Installed Dependencies" - -msg_info "Installing Pi-hole" -systemctl stop systemd-resolved -echo "DNSStubListener=no" >>/etc/systemd/resolved.conf -ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf -mkdir -p /etc/pihole/ -cat </etc/pihole/setupVars.conf -PIHOLE_INTERFACE=eth0 -PIHOLE_DNS_1=8.8.8.8 -PIHOLE_DNS_2=8.8.4.4 -QUERY_LOGGING=true -INSTALL_WEB_SERVER=true -INSTALL_WEB_INTERFACE=true -LIGHTTPD_ENABLED=true -CACHE_SIZE=10000 -DNS_FQDN_REQUIRED=true -DNS_BOGUS_PRIV=true -DNSMASQ_LISTENING=local -WEBPASSWORD=$(openssl rand -base64 48) -BLOCKING_ENABLED=true -EOF - -$STD bash <(curl -fsSL https://install.pi-hole.net) /dev/stdin --unattended -msg_ok "Installed Pi-hole" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/plex-install.sh b/install/plex-install.sh new file mode 100644 index 00000000..01744201 --- /dev/null +++ b/install/plex-install.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y gnupg +msg_ok "Installed Dependencies" + +if [[ -z "$(grep -w "100000" /proc/self/uid_map)" ]]; then + msg_info "Setting Up Hardware Acceleration" + $STD apt-get -y install \ + va-driver-all \ + ocl-icd-libopencl1 + if [[ ${PCT_OSVERSION} == "20.04" ]]; then + $STD apt-get install -y beignet-opencl-icd + else + $STD apt-get install -y intel-opencl-icd + fi + /bin/chgrp video /dev/dri + /bin/chmod 755 /dev/dri + /bin/chmod 660 /dev/dri/* + msg_ok "Set Up Hardware Acceleration" +fi + +msg_info "Setting Up Plex Media Server Repository" +$STD apt-key add <(curl -fsSL https://downloads.plex.tv/plex-keys/PlexSign.key) +sh -c 'echo "deb [arch=$(dpkg --print-architecture)] https://downloads.plex.tv/repo/deb/ public main" > /etc/apt/sources.list.d/plexmediaserver.list' +msg_ok "Set Up Plex Media Server Repository" + +msg_info "Installing Plex Media Server" +$STD apt-get update +$STD apt-get -o Dpkg::Options::="--force-confold" install -y plexmediaserver +msg_ok "Installed Plex Media Server" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/plex-v5-install.sh b/install/plex-v5-install.sh deleted file mode 100644 index f866c55e..00000000 --- a/install/plex-v5-install.sh +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y gnupg -msg_ok "Installed Dependencies" - -if [[ -z "$(grep -w "100000" /proc/self/uid_map)" ]]; then - msg_info "Setting Up Hardware Acceleration" - $STD apt-get -y install \ - va-driver-all \ - ocl-icd-libopencl1 - if [[ ${PCT_OSVERSION} == "20.04" ]]; then - $STD apt-get install -y beignet-opencl-icd - else - $STD apt-get install -y intel-opencl-icd - fi - /bin/chgrp video /dev/dri - /bin/chmod 755 /dev/dri - /bin/chmod 660 /dev/dri/* - msg_ok "Set Up Hardware Acceleration" -fi - -msg_info "Setting Up Plex Media Server Repository" -$STD apt-key add <(curl -fsSL https://downloads.plex.tv/plex-keys/PlexSign.key) -sh -c 'echo "deb [arch=$(dpkg --print-architecture)] https://downloads.plex.tv/repo/deb/ public main" > /etc/apt/sources.list.d/plexmediaserver.list' -msg_ok "Set Up Plex Media Server Repository" - -msg_info "Installing Plex Media Server" -$STD apt-get update -$STD apt-get -o Dpkg::Options::="--force-confold" install -y plexmediaserver -msg_ok "Installed Plex Media Server" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/podman-homeassistant-install.sh b/install/podman-homeassistant-install.sh new file mode 100644 index 00000000..70351f5e --- /dev/null +++ b/install/podman-homeassistant-install.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing Podman" +$STD apt-get -y install podman +$STD systemctl enable --now podman.socket +msg_ok "Installed Podman" + +msg_info "Pulling Home Assistant Image" +$STD podman pull docker.io/homeassistant/home-assistant:stable +msg_ok "Pulled Home Assistant Image" + +msg_info "Installing Home Assistant" +$STD podman volume create hass_config +$STD podman run -d \ + --name homeassistant \ + --restart unless-stopped \ + -v /dev:/dev \ + -v hass_config:/config \ + -v /etc/localtime:/etc/localtime:ro \ + -v /etc/timezone:/etc/timezone:ro \ + --net=host \ + homeassistant/home-assistant:stable +podman generate systemd \ + --new --name homeassistant \ + >/etc/systemd/system/homeassistant.service +$STD systemctl enable --now homeassistant +msg_ok "Installed Home Assistant" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/podman-homeassistant-v5-install.sh b/install/podman-homeassistant-v5-install.sh deleted file mode 100644 index 4b594c70..00000000 --- a/install/podman-homeassistant-v5-install.sh +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing Podman" -$STD apt-get -y install podman -$STD systemctl enable --now podman.socket -msg_ok "Installed Podman" - -msg_info "Pulling Home Assistant Image" -$STD podman pull docker.io/homeassistant/home-assistant:stable -msg_ok "Pulled Home Assistant Image" - -msg_info "Installing Home Assistant" -$STD podman volume create hass_config -$STD podman run -d \ - --name homeassistant \ - --restart unless-stopped \ - -v /dev:/dev \ - -v hass_config:/config \ - -v /etc/localtime:/etc/localtime:ro \ - -v /etc/timezone:/etc/timezone:ro \ - --net=host \ - homeassistant/home-assistant:stable -podman generate systemd \ - --new --name homeassistant \ - >/etc/systemd/system/homeassistant.service -$STD systemctl enable --now homeassistant -msg_ok "Installed Home Assistant" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/podman-install.sh b/install/podman-install.sh new file mode 100644 index 00000000..8c248463 --- /dev/null +++ b/install/podman-install.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing Podman" +$STD apt-get -y install podman +$STD systemctl enable --now podman.socket +echo -e 'unqualified-search-registries=["docker.io"]' >> /etc/containers/registries.conf +msg_ok "Installed Podman" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/podman-v5-install.sh b/install/podman-v5-install.sh deleted file mode 100644 index 3e2aa3e8..00000000 --- a/install/podman-v5-install.sh +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing Podman" -$STD apt-get -y install podman -$STD systemctl enable --now podman.socket -echo -e 'unqualified-search-registries=["docker.io"]' >> /etc/containers/registries.conf -msg_ok "Installed Podman" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/postgresql-v5-install.sh b/install/postgresql-install.sh similarity index 60% rename from install/postgresql-v5-install.sh rename to install/postgresql-install.sh index 7a003eb5..53fb2a25 100644 --- a/install/postgresql-v5-install.sh +++ b/install/postgresql-install.sh @@ -5,89 +5,13 @@ # License: MIT # https://github.com/tteck/Proxmox/raw/main/LICENSE -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -LANG=$(grep -v '^#' /etc/locale.gen | grep -o '^[^ ]*') -update-locale LANG=$LANG -echo "export LANG=$LANG" >> ~/.bashrc -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os msg_info "Installing Dependencies" $STD apt-get install -y curl @@ -217,23 +141,8 @@ if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then msg_ok "Installed Adminer" fi -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi +motd_ssh +root msg_info "Cleaning up" $STD apt-get autoremove diff --git a/install/prometheus-install.sh b/install/prometheus-install.sh new file mode 100644 index 00000000..4d3d77a2 --- /dev/null +++ b/install/prometheus-install.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing Prometheus" +RELEASE=$(curl -s https://api.github.com/repos/prometheus/prometheus/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +mkdir -p /etc/prometheus +mkdir -p /var/lib/prometheus +$STD wget https://github.com/prometheus/prometheus/releases/download/v${RELEASE}/prometheus-${RELEASE}.linux-amd64.tar.gz +$STD tar -xvf prometheus-${RELEASE}.linux-amd64.tar.gz +cd prometheus-${RELEASE}.linux-amd64 +mv prometheus promtool /usr/local/bin/ +mv consoles/ console_libraries/ /etc/prometheus/ +mv prometheus.yml /etc/prometheus/prometheus.yml +msg_ok "Installed Prometheus" + +msg_info "Creating Service" +service_path="/etc/systemd/system/prometheus.service" +echo "[Unit] +Description=Prometheus +Wants=network-online.target +After=network-online.target + +[Service] +User=root +Restart=always +Type=simple +ExecStart=/usr/local/bin/prometheus \ + --config.file=/etc/prometheus/prometheus.yml \ + --storage.tsdb.path=/var/lib/prometheus/ \ + --web.console.templates=/etc/prometheus/consoles \ + --web.console.libraries=/etc/prometheus/console_libraries \ + --web.listen-address=0.0.0.0:9090 + +[Install] +WantedBy=multi-user.target" >$service_path +$STD sudo systemctl enable --now prometheus +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +rm -rf /root/prometheus-${RELEASE}.linux-amd64 /root/prometheus-${RELEASE}.linux-amd64.tar.gz +msg_ok "Cleaned" diff --git a/install/prometheus-v5-install.sh b/install/prometheus-v5-install.sh deleted file mode 100644 index 7d561256..00000000 --- a/install/prometheus-v5-install.sh +++ /dev/null @@ -1,152 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing Prometheus" -RELEASE=$(curl -s https://api.github.com/repos/prometheus/prometheus/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') -mkdir -p /etc/prometheus -mkdir -p /var/lib/prometheus -$STD wget https://github.com/prometheus/prometheus/releases/download/v${RELEASE}/prometheus-${RELEASE}.linux-amd64.tar.gz -$STD tar -xvf prometheus-${RELEASE}.linux-amd64.tar.gz -cd prometheus-${RELEASE}.linux-amd64 -mv prometheus promtool /usr/local/bin/ -mv consoles/ console_libraries/ /etc/prometheus/ -mv prometheus.yml /etc/prometheus/prometheus.yml -msg_ok "Installed Prometheus" - -msg_info "Creating Service" -service_path="/etc/systemd/system/prometheus.service" -echo "[Unit] -Description=Prometheus -Wants=network-online.target -After=network-online.target - -[Service] -User=root -Restart=always -Type=simple -ExecStart=/usr/local/bin/prometheus \ - --config.file=/etc/prometheus/prometheus.yml \ - --storage.tsdb.path=/var/lib/prometheus/ \ - --web.console.templates=/etc/prometheus/consoles \ - --web.console.libraries=/etc/prometheus/console_libraries \ - --web.listen-address=0.0.0.0:9090 - -[Install] -WantedBy=multi-user.target" >$service_path -$STD sudo systemctl enable --now prometheus -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -rm -rf /root/prometheus-${RELEASE}.linux-amd64 /root/prometheus-${RELEASE}.linux-amd64.tar.gz -msg_ok "Cleaned" diff --git a/install/prowlarr-install.sh b/install/prowlarr-install.sh new file mode 100644 index 00000000..638d93c1 --- /dev/null +++ b/install/prowlarr-install.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y sqlite3 +msg_ok "Installed Dependencies" + +msg_info "Installing Prowlarr" +mkdir -p /var/lib/prowlarr/ +chmod 775 /var/lib/prowlarr/ +$STD wget --content-disposition 'https://prowlarr.servarr.com/v1/update/master/updatefile?os=linux&runtime=netcore&arch=x64' +$STD tar -xvzf Prowlarr.master.*.tar.gz +mv Prowlarr /opt +chmod 775 /opt/Prowlarr +msg_ok "Installed Prowlarr" + +msg_info "Creating Service" +cat </etc/systemd/system/prowlarr.service +[Unit] +Description=Prowlarr Daemon +After=syslog.target network.target +[Service] +UMask=0002 +Type=simple +ExecStart=/opt/Prowlarr/Prowlarr -nobrowser -data=/var/lib/prowlarr/ +TimeoutStopSec=20 +KillMode=process +Restart=on-failure +[Install] +WantedBy=multi-user.target +EOF +systemctl -q daemon-reload +systemctl enable --now -q prowlarr +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +rm -rf Prowlarr.master.*.tar.gz +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/prowlarr-v5-install.sh b/install/prowlarr-v5-install.sh deleted file mode 100644 index 565541ac..00000000 --- a/install/prowlarr-v5-install.sh +++ /dev/null @@ -1,145 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y sqlite3 -msg_ok "Installed Dependencies" - -msg_info "Installing Prowlarr" -mkdir -p /var/lib/prowlarr/ -chmod 775 /var/lib/prowlarr/ -$STD wget --content-disposition 'https://prowlarr.servarr.com/v1/update/master/updatefile?os=linux&runtime=netcore&arch=x64' -$STD tar -xvzf Prowlarr.master.*.tar.gz -mv Prowlarr /opt -chmod 775 /opt/Prowlarr -msg_ok "Installed Prowlarr" - -msg_info "Creating Service" -cat </etc/systemd/system/prowlarr.service -[Unit] -Description=Prowlarr Daemon -After=syslog.target network.target -[Service] -UMask=0002 -Type=simple -ExecStart=/opt/Prowlarr/Prowlarr -nobrowser -data=/var/lib/prowlarr/ -TimeoutStopSec=20 -KillMode=process -Restart=on-failure -[Install] -WantedBy=multi-user.target -EOF -systemctl -q daemon-reload -systemctl enable --now -q prowlarr -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -rm -rf Prowlarr.master.*.tar.gz -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/qbittorrent-install.sh b/install/qbittorrent-install.sh new file mode 100644 index 00000000..6995f6bb --- /dev/null +++ b/install/qbittorrent-install.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing qbittorrent-nox" +$STD apt-get install -y qbittorrent-nox +msg_ok "qbittorrent-nox" + +msg_info "Creating Service" +cat </etc/systemd/system/qbittorrent-nox.service +[Unit] +Description=qBittorrent client +After=network.target +[Service] +ExecStart=/usr/bin/qbittorrent-nox --webui-port=8090 +Restart=always +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now qbittorrent-nox +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/qbittorrent-v5-install.sh b/install/qbittorrent-v5-install.sh deleted file mode 100644 index 8ced8627..00000000 --- a/install/qbittorrent-v5-install.sh +++ /dev/null @@ -1,133 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing qbittorrent-nox" -$STD apt-get install -y qbittorrent-nox -msg_ok "qbittorrent-nox" - -msg_info "Creating Service" -cat </etc/systemd/system/qbittorrent-nox.service -[Unit] -Description=qBittorrent client -After=network.target -[Service] -ExecStart=/usr/bin/qbittorrent-nox --webui-port=8090 -Restart=always -[Install] -WantedBy=multi-user.target -EOF -systemctl enable -q --now qbittorrent-nox -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/radarr-install.sh b/install/radarr-install.sh new file mode 100644 index 00000000..4c736895 --- /dev/null +++ b/install/radarr-install.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y sqlite3 +msg_ok "Installed Dependencies" + +msg_info "Installing Radarr" +mkdir -p /var/lib/radarr/ +chmod 775 /var/lib/radarr/ +$STD wget --content-disposition 'https://radarr.servarr.com/v1/update/master/updatefile?os=linux&runtime=netcore&arch=x64' +$STD tar -xvzf Radarr.master.*.tar.gz +mv Radarr /opt +chmod 775 /opt/Radarr +msg_ok "Installed Radarr" + +msg_info "Creating Service" +cat </etc/systemd/system/radarr.service +[Unit] +Description=Radarr Daemon +After=syslog.target network.target +[Service] +UMask=0002 +Type=simple +ExecStart=/opt/Radarr/Radarr -nobrowser -data=/var/lib/radarr/ +TimeoutStopSec=20 +KillMode=process +Restart=on-failure +[Install] +WantedBy=multi-user.target +EOF +systemctl -q daemon-reload +systemctl enable --now -q radarr +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +rm -rf Radarr.master.*.tar.gz +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/radarr-v5-install.sh b/install/radarr-v5-install.sh deleted file mode 100644 index 655bf395..00000000 --- a/install/radarr-v5-install.sh +++ /dev/null @@ -1,145 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y sqlite3 -msg_ok "Installed Dependencies" - -msg_info "Installing Radarr" -mkdir -p /var/lib/radarr/ -chmod 775 /var/lib/radarr/ -$STD wget --content-disposition 'https://radarr.servarr.com/v1/update/master/updatefile?os=linux&runtime=netcore&arch=x64' -$STD tar -xvzf Radarr.master.*.tar.gz -mv Radarr /opt -chmod 775 /opt/Radarr -msg_ok "Installed Radarr" - -msg_info "Creating Service" -cat </etc/systemd/system/radarr.service -[Unit] -Description=Radarr Daemon -After=syslog.target network.target -[Service] -UMask=0002 -Type=simple -ExecStart=/opt/Radarr/Radarr -nobrowser -data=/var/lib/radarr/ -TimeoutStopSec=20 -KillMode=process -Restart=on-failure -[Install] -WantedBy=multi-user.target -EOF -systemctl -q daemon-reload -systemctl enable --now -q radarr -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -rm -rf Radarr.master.*.tar.gz -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/readarr-install.sh b/install/readarr-install.sh new file mode 100644 index 00000000..9452caa3 --- /dev/null +++ b/install/readarr-install.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y sqlite3 +msg_ok "Installed Dependencies" + +msg_info "Installing Readarr" +mkdir -p /var/lib/readarr/ +chmod 775 /var/lib/readarr/ +$STD wget --content-disposition 'https://readarr.servarr.com/v1/update/develop/updatefile?os=linux&runtime=netcore&arch=x64' +$STD tar -xvzf Readarr.develop.*.tar.gz +mv Readarr /opt +chmod 775 /opt/Readarr +msg_ok "Installed Readarr" + +msg_info "Creating Service" +cat </etc/systemd/system/readarr.service +[Unit] +Description=Readarr Daemon +After=syslog.target network.target +[Service] +UMask=0002 +Type=simple +ExecStart=/opt/Readarr/Readarr -nobrowser -data=/var/lib/readarr/ +TimeoutStopSec=20 +KillMode=process +Restart=on-failure +[Install] +WantedBy=multi-user.target +EOF +systemctl -q daemon-reload +systemctl enable --now -q readarr +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +rm -rf Readarr.develop.*.tar.gz +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/readarr-v5-install.sh b/install/readarr-v5-install.sh deleted file mode 100644 index f2388649..00000000 --- a/install/readarr-v5-install.sh +++ /dev/null @@ -1,145 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y sqlite3 -msg_ok "Installed Dependencies" - -msg_info "Installing Readarr" -mkdir -p /var/lib/readarr/ -chmod 775 /var/lib/readarr/ -$STD wget --content-disposition 'https://readarr.servarr.com/v1/update/develop/updatefile?os=linux&runtime=netcore&arch=x64' -$STD tar -xvzf Readarr.develop.*.tar.gz -mv Readarr /opt -chmod 775 /opt/Readarr -msg_ok "Installed Readarr" - -msg_info "Creating Service" -cat </etc/systemd/system/readarr.service -[Unit] -Description=Readarr Daemon -After=syslog.target network.target -[Service] -UMask=0002 -Type=simple -ExecStart=/opt/Readarr/Readarr -nobrowser -data=/var/lib/readarr/ -TimeoutStopSec=20 -KillMode=process -Restart=on-failure -[Install] -WantedBy=multi-user.target -EOF -systemctl -q daemon-reload -systemctl enable --now -q readarr -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -rm -rf Readarr.develop.*.tar.gz -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/rstptoweb-install.sh b/install/rstptoweb-install.sh new file mode 100644 index 00000000..76c3792d --- /dev/null +++ b/install/rstptoweb-install.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y git +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing Golang" +$STD wget https://golang.org/dl/go1.20.1.linux-amd64.tar.gz +$STD tar -xzf go1.20.1.linux-amd64.tar.gz -C /usr/local +$STD ln -s /usr/local/go/bin/go /usr/local/bin/go +rm -rf go1.20.1.linux-amd64.tar.gz +msg_ok "Installed Golang" + +msg_info "Installing RSTPtoWEB" +$STD git clone https://github.com/deepch/RTSPtoWeb /opt/rtsptoweb +cat <>/opt/rtsptoweb/start +#!/bin/bash +cd /opt/rtsptoweb && GO111MODULE=on go run *.go +EOF +chmod +x /opt/rtsptoweb/start +msg_ok "Installed RSTPtoWEB" + +msg_info "Creating Service" +service_path="/etc/systemd/system/rtsptoweb.service" +echo "[Unit] +Description=RTSP to Web Streaming Service +After=network.target + +[Service] +Type=simple +User=root +ExecStart=/opt/rtsptoweb/start + +[Install] +WantedBy=multi-user.target" >$service_path +systemctl enable -q --now rtsptoweb +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/rstptoweb-v5-install.sh b/install/rstptoweb-v5-install.sh deleted file mode 100644 index f1c28169..00000000 --- a/install/rstptoweb-v5-install.sh +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y git -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing Golang" -$STD wget https://golang.org/dl/go1.20.1.linux-amd64.tar.gz -$STD tar -xzf go1.20.1.linux-amd64.tar.gz -C /usr/local -$STD ln -s /usr/local/go/bin/go /usr/local/bin/go -rm -rf go1.20.1.linux-amd64.tar.gz -msg_ok "Installed Golang" - -msg_info "Installing RSTPtoWEB" -$STD git clone https://github.com/deepch/RTSPtoWeb /opt/rtsptoweb -cat <>/opt/rtsptoweb/start -#!/bin/bash -cd /opt/rtsptoweb && GO111MODULE=on go run *.go -EOF -chmod +x /opt/rtsptoweb/start -msg_ok "Installed RSTPtoWEB" - -msg_info "Creating Service" -service_path="/etc/systemd/system/rtsptoweb.service" -echo "[Unit] -Description=RTSP to Web Streaming Service -After=network.target - -[Service] -Type=simple -User=root -ExecStart=/opt/rtsptoweb/start - -[Install] -WantedBy=multi-user.target" >$service_path -systemctl enable -q --now rtsptoweb -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/sabnzbd-install.sh b/install/sabnzbd-install.sh new file mode 100644 index 00000000..b779e31d --- /dev/null +++ b/install/sabnzbd-install.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y unzip +$STD apt-get install -y par2 +$STD apt-get install -y p7zip-full +wget -q http://http.us.debian.org/debian/pool/non-free/u/unrar-nonfree/unrar_6.0.3-1+deb11u1_amd64.deb +$STD dpkg -i unrar_6.0.3-1+deb11u1_amd64.deb +rm unrar_6.0.3-1+deb11u1_amd64.deb +msg_ok "Installed Dependencies" + +msg_info "Installing Python3-pip" +$STD apt-get install -y python3-setuptools +$STD apt-get install -y python3-pip +msg_ok "Installed Python3-pip" + +msg_info "Installing SABnzbd" +RELEASE=$(curl -s https://api.github.com/repos/sabnzbd/sabnzbd/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +$STD tar zxvf <(curl -fsSL https://github.com/sabnzbd/sabnzbd/releases/download/$RELEASE/SABnzbd-${RELEASE}-src.tar.gz) +mv SABnzbd-${RELEASE} /opt/sabnzbd +cd /opt/sabnzbd +$STD python3 -m pip install -r requirements.txt +msg_ok "Installed SABnzbd" + +msg_info "Creating Service" +service_path="/etc/systemd/system/sabnzbd.service" +echo "[Unit] +Description=SABnzbd +After=network.target +[Service] +WorkingDirectory=/opt/sabnzbd +ExecStart=python3 SABnzbd.py -s 0.0.0.0:7777 +Restart=always +User=root +[Install] +WantedBy=multi-user.target" >$service_path +systemctl enable --now -q sabnzbd.service +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/sabnzbd-v5-install.sh b/install/sabnzbd-v5-install.sh deleted file mode 100644 index 9d9cb825..00000000 --- a/install/sabnzbd-v5-install.sh +++ /dev/null @@ -1,149 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y unzip -$STD apt-get install -y par2 -$STD apt-get install -y p7zip-full -wget -q http://http.us.debian.org/debian/pool/non-free/u/unrar-nonfree/unrar_6.0.3-1+deb11u1_amd64.deb -$STD dpkg -i unrar_6.0.3-1+deb11u1_amd64.deb -rm unrar_6.0.3-1+deb11u1_amd64.deb -msg_ok "Installed Dependencies" - -msg_info "Installing Python3-pip" -$STD apt-get install -y python3-setuptools -$STD apt-get install -y python3-pip -msg_ok "Installed Python3-pip" - -msg_info "Installing SABnzbd" -RELEASE=$(curl -s https://api.github.com/repos/sabnzbd/sabnzbd/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -$STD tar zxvf <(curl -fsSL https://github.com/sabnzbd/sabnzbd/releases/download/$RELEASE/SABnzbd-${RELEASE}-src.tar.gz) -mv SABnzbd-${RELEASE} /opt/sabnzbd -cd /opt/sabnzbd -$STD python3 -m pip install -r requirements.txt -msg_ok "Installed SABnzbd" - -msg_info "Creating Service" -service_path="/etc/systemd/system/sabnzbd.service" -echo "[Unit] -Description=SABnzbd -After=network.target -[Service] -WorkingDirectory=/opt/sabnzbd -ExecStart=python3 SABnzbd.py -s 0.0.0.0:7777 -Restart=always -User=root -[Install] -WantedBy=multi-user.target" >$service_path -systemctl enable --now -q sabnzbd.service -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/scrypted-install.sh b/install/scrypted-install.sh new file mode 100644 index 00000000..5294e95b --- /dev/null +++ b/install/scrypted-install.sh @@ -0,0 +1,117 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get -y install software-properties-common apt-utils +$STD apt-get -y update +$STD apt-get -y upgrade +$STD apt-get -y install \ + build-essential \ + gcc \ + gir1.2-gtk-3.0 \ + libcairo2-dev \ + libgirepository1.0-dev \ + libglib2.0-dev \ + libjpeg-dev \ + libgif-dev \ + libopenjp2-7 \ + libpango1.0-dev \ + librsvg2-dev \ + pkg-config \ + curl \ + sudo \ + mc +msg_ok "Installed Dependencies" + +msg_info "Installing GStreamer" +$STD apt-get -y install \ + gstreamer1.0-tools \ + libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev \ + libgstreamer-plugins-bad1.0-dev \ + gstreamer1.0-plugins-base \ + gstreamer1.0-plugins-good \ + gstreamer1.0-plugins-bad \ + gstreamer1.0-plugins-ugly \ + gstreamer1.0-libav \ + gstreamer1.0-alsa +msg_ok "Installed GStreamer" + +msg_info "Setting up Node.js Repository" +$STD bash <(curl -fsSL https://deb.nodesource.com/setup_18.x) +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing Python3" +$STD apt-get -y install \ + python3 \ + python3-dev \ + python3-gi \ + python3-gst-1.0 \ + python3-matplotlib \ + python3-numpy \ + python3-opencv \ + python3-pil \ + python3-pip \ + python3-setuptools \ + python3-skimage \ + python3-wheel +$STD python3 -m pip install --upgrade pip +$STD python3 -m pip install aiofiles debugpy typing_extensions typing +msg_ok "Installed Python3" + +read -r -p "Would you like to add Coral Edge TPU support? " prompt +if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then +msg_info "Adding Coral Edge TPU Support" +$STD apt-key add <(curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg) +sh -c 'echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" > /etc/apt/sources.list.d/coral-edgetpu.list' +$STD apt-get -y update +$STD apt-get -y install libedgetpu1-std +msg_ok "Coral Edge TPU Support Added" +fi + +msg_info "Installing Scrypted" +$STD sudo -u root npx -y scrypted@latest install-server +msg_info "Installed Scrypted" + +msg_info "Creating Service" +service_path="/etc/systemd/system/scrypted.service" +echo "[Unit] +Description=Scrypted service +After=network.target + +[Service] +User=root +Group=root +Type=simple +ExecStart=/usr/bin/npx -y scrypted serve +Restart=on-failure +RestartSec=3 + +[Install] +WantedBy=multi-user.target" >$service_path +$STD systemctl enable --now scrypted.service +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/scrypted-v5-install.sh b/install/scrypted-v5-install.sh deleted file mode 100644 index 60b1e6e9..00000000 --- a/install/scrypted-v5-install.sh +++ /dev/null @@ -1,203 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get -y install software-properties-common apt-utils -$STD apt-get -y update -$STD apt-get -y upgrade -$STD apt-get -y install \ - build-essential \ - gcc \ - gir1.2-gtk-3.0 \ - libcairo2-dev \ - libgirepository1.0-dev \ - libglib2.0-dev \ - libjpeg-dev \ - libgif-dev \ - libopenjp2-7 \ - libpango1.0-dev \ - librsvg2-dev \ - pkg-config \ - curl \ - sudo \ - mc -msg_ok "Installed Dependencies" - -msg_info "Installing GStreamer" -$STD apt-get -y install \ - gstreamer1.0-tools \ - libgstreamer1.0-dev \ - libgstreamer-plugins-base1.0-dev \ - libgstreamer-plugins-bad1.0-dev \ - gstreamer1.0-plugins-base \ - gstreamer1.0-plugins-good \ - gstreamer1.0-plugins-bad \ - gstreamer1.0-plugins-ugly \ - gstreamer1.0-libav \ - gstreamer1.0-alsa -msg_ok "Installed GStreamer" - -msg_info "Setting up Node.js Repository" -$STD bash <(curl -fsSL https://deb.nodesource.com/setup_18.x) -msg_ok "Set up Node.js Repository" - -msg_info "Installing Node.js" -$STD apt-get install -y nodejs -msg_ok "Installed Node.js" - -msg_info "Installing Python3" -$STD apt-get -y install \ - python3 \ - python3-dev \ - python3-gi \ - python3-gst-1.0 \ - python3-matplotlib \ - python3-numpy \ - python3-opencv \ - python3-pil \ - python3-pip \ - python3-setuptools \ - python3-skimage \ - python3-wheel -$STD python3 -m pip install --upgrade pip -$STD python3 -m pip install aiofiles debugpy typing_extensions typing -msg_ok "Installed Python3" - -read -r -p "Would you like to add Coral Edge TPU support? " prompt -if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then -msg_info "Adding Coral Edge TPU Support" -$STD apt-key add <(curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg) -sh -c 'echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" > /etc/apt/sources.list.d/coral-edgetpu.list' -$STD apt-get -y update -$STD apt-get -y install libedgetpu1-std -msg_ok "Coral Edge TPU Support Added" -fi - -msg_info "Installing Scrypted" -$STD sudo -u root npx -y scrypted@latest install-server -msg_info "Installed Scrypted" - -msg_info "Creating Service" -service_path="/etc/systemd/system/scrypted.service" -echo "[Unit] -Description=Scrypted service -After=network.target - -[Service] -User=root -Group=root -Type=simple -ExecStart=/usr/bin/npx -y scrypted serve -Restart=on-failure -RestartSec=3 - -[Install] -WantedBy=multi-user.target" >$service_path -$STD systemctl enable --now scrypted.service -msg_ok "Created Service" -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/shinobi-install.sh b/install/shinobi-install.sh new file mode 100644 index 00000000..d6682ba3 --- /dev/null +++ b/install/shinobi-install.sh @@ -0,0 +1,90 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +ubuntuversion=$(lsb_release -r | awk '{print $2}' | cut -d . -f1) +if [ "$ubuntuversion" = "18" ] || [ "$ubuntuversion" -le "18" ]; then + apt install sudo wget -y + sudo apt install -y software-properties-common + sudo add-apt-repository universe -y + apt update -y + apt update --fix-missing -y +fi + +msg_info "Installing Dependencies" +$STD apt-get install -y curl sudo git mc +$STD apt-get install -y make zip net-tools +$STD apt-get install -y gcc g++ cmake +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +$STD bash <(curl -fsSL https://deb.nodesource.com/setup_18.x) +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing FFMPEG" +$STD apt-get install -y ffmpeg +msg_ok "Installed FFMPEG" + +msg_info "Clonning Shinobi" +cd /opt +$STD git clone https://gitlab.com/Shinobi-Systems/Shinobi.git -b master Shinobi +cd Shinobi +gitVersionNumber=$(git rev-parse HEAD) +theDateRightNow=$(date) +touch version.json +chmod 777 version.json +echo '{"Product" : "'"Shinobi"'" , "Branch" : "'"master"'" , "Version" : "'"$gitVersionNumber"'" , "Date" : "'"$theDateRightNow"'" , "Repository" : "'"https://gitlab.com/Shinobi-Systems/Shinobi.git"'"}' > version.json +msg_ok "Cloned Shinobi" + +msg_info "Installing Database" +sqlpass="" +echo "mariadb-server mariadb-server/root_password password $sqlpass" | debconf-set-selections +echo "mariadb-server mariadb-server/root_password_again password $sqlpass" | debconf-set-selections +$STD apt-get install -y mariadb-server +service mysql start +sqluser="root" +mysql -e "source sql/user.sql" || true +mysql -e "source sql/framework.sql" || true +msg_ok "Installed Database" +cp conf.sample.json conf.json +cronKey=$(head -c 1024 < /dev/urandom | sha256sum | awk '{print substr($1,1,29)}') +sed -i -e 's/Shinobi/'"$cronKey"'/g' conf.json +cp super.sample.json super.json + +msg_info "Installing Shinobi" +$STD npm i npm -g +$STD npm install --unsafe-perm +$STD npm install pm2@latest -g +chmod -R 755 . +touch INSTALL/installed.txt +ln -s /opt/Shinobi/INSTALL/shinobi /usr/bin/shinobi +node /opt/Shinobi/tools/modifyConfiguration.js addToConfig="{\"cron\":{\"key\":\"$(head -c 64 < /dev/urandom | sha256sum | awk '{print substr($1,1,60)}')\"}}" &>/dev/null +$STD pm2 start camera.js +$STD pm2 start cron.js +$STD pm2 startup +$STD pm2 save +$STD pm2 list +msg_ok "Installed Shinobi" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/shinobi-v5-install.sh b/install/shinobi-v5-install.sh deleted file mode 100644 index 755148af..00000000 --- a/install/shinobi-v5-install.sh +++ /dev/null @@ -1,178 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update --fix-missing -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -ubuntuversion=$(lsb_release -r | awk '{print $2}' | cut -d . -f1) -if [ "$ubuntuversion" = "18" ] || [ "$ubuntuversion" -le "18" ]; then - apt install sudo wget -y - sudo apt install -y software-properties-common - sudo add-apt-repository universe -y - apt update -y - apt update --fix-missing -y -fi - -msg_info "Installing Dependencies" -$STD apt-get install -y curl sudo git mc -$STD apt-get install -y make zip net-tools -$STD apt-get install -y gcc g++ cmake -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -$STD bash <(curl -fsSL https://deb.nodesource.com/setup_18.x) -msg_ok "Set up Node.js Repository" - -msg_info "Installing Node.js" -$STD apt-get install -y nodejs -msg_ok "Installed Node.js" - -msg_info "Installing FFMPEG" -$STD apt-get install -y ffmpeg -msg_ok "Installed FFMPEG" - -msg_info "Clonning Shinobi" -cd /opt -$STD git clone https://gitlab.com/Shinobi-Systems/Shinobi.git -b master Shinobi -cd Shinobi -gitVersionNumber=$(git rev-parse HEAD) -theDateRightNow=$(date) -touch version.json -chmod 777 version.json -echo '{"Product" : "'"Shinobi"'" , "Branch" : "'"master"'" , "Version" : "'"$gitVersionNumber"'" , "Date" : "'"$theDateRightNow"'" , "Repository" : "'"https://gitlab.com/Shinobi-Systems/Shinobi.git"'"}' > version.json -msg_ok "Cloned Shinobi" - -msg_info "Installing Database" -sqlpass="" -echo "mariadb-server mariadb-server/root_password password $sqlpass" | debconf-set-selections -echo "mariadb-server mariadb-server/root_password_again password $sqlpass" | debconf-set-selections -$STD apt-get install -y mariadb-server -service mysql start -sqluser="root" -mysql -e "source sql/user.sql" || true -mysql -e "source sql/framework.sql" || true -msg_ok "Installed Database" -cp conf.sample.json conf.json -cronKey=$(head -c 1024 < /dev/urandom | sha256sum | awk '{print substr($1,1,29)}') -sed -i -e 's/Shinobi/'"$cronKey"'/g' conf.json -cp super.sample.json super.json - -msg_info "Installing Shinobi" -$STD npm i npm -g -$STD npm install --unsafe-perm -$STD npm install pm2@latest -g -chmod -R 755 . -touch INSTALL/installed.txt -ln -s /opt/Shinobi/INSTALL/shinobi /usr/bin/shinobi -node /opt/Shinobi/tools/modifyConfiguration.js addToConfig="{\"cron\":{\"key\":\"$(head -c 64 < /dev/urandom | sha256sum | awk '{print substr($1,1,60)}')\"}}" &>/dev/null -$STD pm2 start camera.js -$STD pm2 start cron.js -$STD pm2 startup -$STD pm2 save -$STD pm2 list -msg_ok "Installed Shinobi" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/sonarr-install.sh b/install/sonarr-install.sh new file mode 100644 index 00000000..52961b31 --- /dev/null +++ b/install/sonarr-install.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y gnupg +$STD apt-get install -y ca-certificates +msg_ok "Installed Dependencies" + +msg_info "Installing Sonarr" +$STD apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 2009837CBFFD68F45BC180471F4F90DE2A9B4BF8 +sh -c 'echo "deb https://apt.sonarr.tv/debian buster-develop main" > /etc/apt/sources.list.d/sonarr.list' +$STD apt-get update +$STD apt-get -o Dpkg::Options::="--force-confold" install -y sonarr +msg_ok "Installed Sonarr" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/sonarr-v5-install.sh b/install/sonarr-v5-install.sh deleted file mode 100644 index 9ca338dc..00000000 --- a/install/sonarr-v5-install.sh +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -export DEBIAN_FRONTEND=noninteractive -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y gnupg -$STD apt-get install -y ca-certificates -msg_ok "Installed Dependencies" - -msg_info "Installing Sonarr" -$STD apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 2009837CBFFD68F45BC180471F4F90DE2A9B4BF8 -sh -c 'echo "deb https://apt.sonarr.tv/debian buster-develop main" > /etc/apt/sources.list.d/sonarr.list' -$STD apt-get update -$STD apt-get -o Dpkg::Options::="--force-confold" install -y sonarr -msg_ok "Installed Sonarr" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/syncthing-install.sh b/install/syncthing-install.sh new file mode 100644 index 00000000..14cd1b99 --- /dev/null +++ b/install/syncthing-install.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y gnupg +msg_ok "Installed Dependencies" + +msg_info "Installing Syncthing" +curl -s -o /usr/share/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg +sh -c 'echo "deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable" > /etc/apt/sources.list.d/syncthing.list' +$STD apt-get update +$STD apt-get install -y syncthing +$STD systemctl enable syncthing@root.service +systemctl start syncthing@root.service +sleep 5 +sed -i "{s/127.0.0.1:8384/0.0.0.0:8384/g}" /root/.config/syncthing/config.xml +systemctl restart syncthing@root.service +msg_ok "Installed Syncthing" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/syncthing-v5-install.sh b/install/syncthing-v5-install.sh deleted file mode 100644 index 315a88da..00000000 --- a/install/syncthing-v5-install.sh +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y gnupg -msg_ok "Installed Dependencies" - -msg_info "Installing Syncthing" -curl -s -o /usr/share/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg -sh -c 'echo "deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable" > /etc/apt/sources.list.d/syncthing.list' -$STD apt-get update -$STD apt-get install -y syncthing -$STD systemctl enable syncthing@root.service -systemctl start syncthing@root.service -sleep 5 -sed -i "{s/127.0.0.1:8384/0.0.0.0:8384/g}" /root/.config/syncthing/config.xml -systemctl restart syncthing@root.service -msg_ok "Installed Syncthing" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/tdarr-install.sh b/install/tdarr-install.sh new file mode 100644 index 00000000..34e4ce6a --- /dev/null +++ b/install/tdarr-install.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y unzip +msg_ok "Installed Dependencies" + +msg_info "Installing Tdarr" +mkdir -p /opt/tdarr +cd /opt/tdarr +wget -q https://f000.backblazeb2.com/file/tdarrs/versions/2.00.15/linux_x64/Tdarr_Updater.zip +$STD unzip Tdarr_Updater.zip +chmod +x Tdarr_Updater +$STD ./Tdarr_Updater +msg_ok "Installed Tdarr" + +msg_info "Creating Service" +service_path="/etc/systemd/system/tdarr-server.service" +echo "[Unit] +Description=Tdarr Server Daemon +After=network.target +# Enable if using ZFS, edit and enable if other FS mounting is required to access directory +#Requires=zfs-mount.service + +[Service] +User=root +Group=root + +Type=simple +WorkingDirectory=/opt/tdarr/Tdarr_Server +ExecStartPre=/opt/tdarr/Tdarr_Updater +ExecStart=/opt/tdarr/Tdarr_Server/Tdarr_Server +TimeoutStopSec=20 +KillMode=process +Restart=on-failure + +[Install] +WantedBy=multi-user.target" >$service_path + +service_path="/etc/systemd/system/tdarr-node.service" +echo "[Unit] +Description=Tdarr Node Daemon +After=network.target +Requires=tdarr-server.service + +[Service] +User=root +Group=root + +Type=simple +WorkingDirectory=/opt/tdarr/Tdarr_Node +ExecStart=/opt/tdarr/Tdarr_Node/Tdarr_Node +TimeoutStopSec=20 +KillMode=process +Restart=on-failure + +[Install] +WantedBy=multi-user.target" >$service_path +systemctl enable --now -q tdarr-server.service +systemctl enable --now -q tdarr-node.service +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +rm -rf Tdarr_Updater.zip +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/tdarr-v5-install.sh b/install/tdarr-v5-install.sh deleted file mode 100644 index 705a53ce..00000000 --- a/install/tdarr-v5-install.sh +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y unzip -msg_ok "Installed Dependencies" - -msg_info "Installing Tdarr" -mkdir -p /opt/tdarr -cd /opt/tdarr -wget -q https://f000.backblazeb2.com/file/tdarrs/versions/2.00.15/linux_x64/Tdarr_Updater.zip -$STD unzip Tdarr_Updater.zip -chmod +x Tdarr_Updater -$STD ./Tdarr_Updater -msg_ok "Installed Tdarr" - -msg_info "Creating Service" -service_path="/etc/systemd/system/tdarr-server.service" -echo "[Unit] -Description=Tdarr Server Daemon -After=network.target -# Enable if using ZFS, edit and enable if other FS mounting is required to access directory -#Requires=zfs-mount.service - -[Service] -User=root -Group=root - -Type=simple -WorkingDirectory=/opt/tdarr/Tdarr_Server -ExecStartPre=/opt/tdarr/Tdarr_Updater -ExecStart=/opt/tdarr/Tdarr_Server/Tdarr_Server -TimeoutStopSec=20 -KillMode=process -Restart=on-failure - -[Install] -WantedBy=multi-user.target" >$service_path - -service_path="/etc/systemd/system/tdarr-node.service" -echo "[Unit] -Description=Tdarr Node Daemon -After=network.target -Requires=tdarr-server.service - -[Service] -User=root -Group=root - -Type=simple -WorkingDirectory=/opt/tdarr/Tdarr_Node -ExecStart=/opt/tdarr/Tdarr_Node/Tdarr_Node -TimeoutStopSec=20 -KillMode=process -Restart=on-failure - -[Install] -WantedBy=multi-user.target" >$service_path -systemctl enable --now -q tdarr-server.service -systemctl enable --now -q tdarr-node.service -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -rm -rf Tdarr_Updater.zip -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/technitiumdns-install.sh b/install/technitiumdns-install.sh new file mode 100644 index 00000000..a795fa37 --- /dev/null +++ b/install/technitiumdns-install.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing ASP.NET Core Runtime" +wget -q https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb +$STD dpkg -i packages-microsoft-prod.deb +rm -rf packages-microsoft-prod.deb +$STD apt-get update +$STD apt-get install -y aspnetcore-runtime-7.0 +msg_ok "Installed ASP.NET Core Runtime" + +msg_info "Installing Technitium DNS" +systemctl stop systemd-resolved +echo "DNSStubListener=no" >>/etc/systemd/resolved.conf +ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf +$STD bash <(curl -fsSL https://download.technitium.com/dns/install.sh) +msg_ok "Installed Technitium DNS" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/technitiumdns-v5-install.sh b/install/technitiumdns-v5-install.sh deleted file mode 100644 index 8570aebc..00000000 --- a/install/technitiumdns-v5-install.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing ASP.NET Core Runtime" -wget -q https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb -$STD dpkg -i packages-microsoft-prod.deb -rm -rf packages-microsoft-prod.deb -$STD apt-get update -$STD apt-get install -y aspnetcore-runtime-7.0 -msg_ok "Installed ASP.NET Core Runtime" - -msg_info "Installing Technitium DNS" -systemctl stop systemd-resolved -echo "DNSStubListener=no" >>/etc/systemd/resolved.conf -ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf -$STD bash <(curl -fsSL https://download.technitium.com/dns/install.sh) -msg_ok "Installed Technitium DNS" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/transmission-install.sh b/install/transmission-install.sh new file mode 100644 index 00000000..1c7c6f0c --- /dev/null +++ b/install/transmission-install.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + + +msg_info "Installing Transmission" +$STD apt-get install -y transmission-daemon +systemctl stop transmission-daemon +sed -i '{s/"rpc-whitelist-enabled": true/"rpc-whitelist-enabled": false/g; s/"rpc-host-whitelist-enabled": true,/"rpc-host-whitelist-enabled": false,/g}' /etc/transmission-daemon/settings.json +systemctl start transmission-daemon +msg_ok "Installed Transmission" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/transmission-v5-install.sh b/install/transmission-v5-install.sh deleted file mode 100644 index c2e22764..00000000 --- a/install/transmission-v5-install.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - - -msg_info "Installing Transmission" -$STD apt-get install -y transmission-daemon -systemctl stop transmission-daemon -sed -i '{s/"rpc-whitelist-enabled": true/"rpc-whitelist-enabled": false/g; s/"rpc-host-whitelist-enabled": true,/"rpc-host-whitelist-enabled": false,/g}' /etc/transmission-daemon/settings.json -systemctl start transmission-daemon -msg_ok "Installed Transmission" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/trilium-install.sh b/install/trilium-install.sh new file mode 100644 index 00000000..02ab6d0f --- /dev/null +++ b/install/trilium-install.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +RELEASE=$(curl -s https://api.github.com/repos/zadam/trilium/releases/latest | + grep "tag_name" | + awk '{print substr($2, 3, length($2)-4) }') + +msg_info "Installing Trilium" +wget -q https://github.com/zadam/trilium/releases/download/v$RELEASE/trilium-linux-x64-server-$RELEASE.tar.xz +$STD tar -xvf trilium-linux-x64-server-$RELEASE.tar.xz +mv trilium-linux-x64-server /opt/trilium +msg_ok "Installed Trilium" + +msg_info "Creating Service" +service_path="/etc/systemd/system/trilium.service" + +echo "[Unit] +Description=Trilium Daemon +After=syslog.target network.target + +[Service] +User=root +Type=simple +ExecStart=/opt/trilium/trilium.sh +WorkingDirectory=/opt/trilium/ +TimeoutStopSec=20 +Restart=always + +[Install] +WantedBy=multi-user.target" >$service_path +systemctl enable --now -q trilium +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +rm -rf /root/trilium-linux-x64-server-$RELEASE.tar.xz +msg_ok "Cleaned" diff --git a/install/trilium-v5-install.sh b/install/trilium-v5-install.sh deleted file mode 100644 index 05a61efa..00000000 --- a/install/trilium-v5-install.sh +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -RELEASE=$(curl -s https://api.github.com/repos/zadam/trilium/releases/latest | - grep "tag_name" | - awk '{print substr($2, 3, length($2)-4) }') - -msg_info "Installing Trilium" -wget -q https://github.com/zadam/trilium/releases/download/v$RELEASE/trilium-linux-x64-server-$RELEASE.tar.xz -$STD tar -xvf trilium-linux-x64-server-$RELEASE.tar.xz -mv trilium-linux-x64-server /opt/trilium -msg_ok "Installed Trilium" - -msg_info "Creating Service" -service_path="/etc/systemd/system/trilium.service" - -echo "[Unit] -Description=Trilium Daemon -After=syslog.target network.target - -[Service] -User=root -Type=simple -ExecStart=/opt/trilium/trilium.sh -WorkingDirectory=/opt/trilium/ -TimeoutStopSec=20 -Restart=always - -[Install] -WantedBy=multi-user.target" >$service_path -systemctl enable --now -q trilium -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -rm -rf /root/trilium-linux-x64-server-$RELEASE.tar.xz -msg_ok "Cleaned" diff --git a/install/ubuntu-install.sh b/install/ubuntu-install.sh new file mode 100644 index 00000000..eb2b237b --- /dev/null +++ b/install/ubuntu-install.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/ubuntu-v5-install.sh b/install/ubuntu-v5-install.sh deleted file mode 100644 index 9f1409ff..00000000 --- a/install/ubuntu-v5-install.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/umbrel-install.sh b/install/umbrel-install.sh new file mode 100644 index 00000000..4ec349db --- /dev/null +++ b/install/umbrel-install.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing Umbrel (Patience)" +DOCKER_CONFIG_PATH='/etc/docker/daemon.json' +mkdir -p $(dirname $DOCKER_CONFIG_PATH) +if [ "$ST" == "yes" ]; then +VER=$(curl -s https://api.github.com/repos/containers/fuse-overlayfs/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +cd /usr/local/bin +curl -sSL -o fuse-overlayfs https://github.com/containers/fuse-overlayfs/releases/download/$VER/fuse-overlayfs-x86_64 +chmod 755 /usr/local/bin/fuse-overlayfs +cd ~ +echo -e '{\n "storage-driver": "fuse-overlayfs",\n "log-driver": "journald"\n}' > /etc/docker/daemon.json +else +echo -e '{\n "log-driver": "journald"\n}' > /etc/docker/daemon.json +fi +$STD bash <(curl -fsSL https://umbrel.sh) +systemctl daemon-reload +$STD systemctl enable --now umbrel-startup.service +msg_ok "Installed Umbrel" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/umbrel-v5-install.sh b/install/umbrel-v5-install.sh deleted file mode 100644 index 8846aa68..00000000 --- a/install/umbrel-v5-install.sh +++ /dev/null @@ -1,133 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing Umbrel (Patience)" -DOCKER_CONFIG_PATH='/etc/docker/daemon.json' -mkdir -p $(dirname $DOCKER_CONFIG_PATH) -if [ "$ST" == "yes" ]; then -VER=$(curl -s https://api.github.com/repos/containers/fuse-overlayfs/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -cd /usr/local/bin -curl -sSL -o fuse-overlayfs https://github.com/containers/fuse-overlayfs/releases/download/$VER/fuse-overlayfs-x86_64 -chmod 755 /usr/local/bin/fuse-overlayfs -cd ~ -echo -e '{\n "storage-driver": "fuse-overlayfs",\n "log-driver": "journald"\n}' > /etc/docker/daemon.json -else -echo -e '{\n "log-driver": "journald"\n}' > /etc/docker/daemon.json -fi -$STD bash <(curl -fsSL https://umbrel.sh) -systemctl daemon-reload -$STD systemctl enable --now umbrel-startup.service -msg_ok "Installed Umbrel" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/unifi-install.sh b/install/unifi-install.sh new file mode 100644 index 00000000..530fcd0d --- /dev/null +++ b/install/unifi-install.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +read -r -p "Local Controller? " prompt +if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + LOCAL="--local-controller" +else + LOCAL="" +fi + +msg_info "Installing UniFi Network Application (Patience)" +wget -qL https://get.glennr.nl/unifi/install/install_latest/unifi-latest.sh +$STD bash unifi-latest.sh --skip --add-repository $LOCAL +msg_ok "Installed UniFi Network Application" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/unifi-v5-install.sh b/install/unifi-v5-install.sh deleted file mode 100644 index 1eaa6cf3..00000000 --- a/install/unifi-v5-install.sh +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -#https://community.ui.com/questions/UniFi-Installation-Scripts-or-UniFi-Easy-Update-Script-or-UniFi-Lets-Encrypt-or-UniFi-Easy-Encrypt-/ccbc7530-dd61-40a7-82ec-22b17f027776 -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -read -r -p "Local Controller? " prompt -if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - LOCAL="--local-controller" -else - LOCAL="" -fi - -msg_info "Installing UniFi Network Application (Patience)" -wget -qL https://get.glennr.nl/unifi/install/install_latest/unifi-latest.sh -$STD bash unifi-latest.sh --skip --add-repository $LOCAL -msg_ok "Installed UniFi Network Application" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/uptimekuma-install.sh b/install/uptimekuma-install.sh new file mode 100644 index 00000000..d5af2231 --- /dev/null +++ b/install/uptimekuma-install.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y git +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +$STD bash <(curl -fsSL https://deb.nodesource.com/setup_18.x) +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD sudo apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing Uptime Kuma" +$STD git clone https://github.com/louislam/uptime-kuma.git +mv uptime-kuma /opt/uptime-kuma +cd /opt/uptime-kuma +$STD npm run setup +msg_ok "Installed Uptime Kuma" + +msg_info "Creating Service" +service_path="/etc/systemd/system/uptime-kuma.service" +echo "[Unit] +Description=uptime-kuma + +[Service] +Type=simple +Restart=always +User=root +WorkingDirectory=/opt/uptime-kuma +ExecStart=/usr/bin/npm start + +[Install] +WantedBy=multi-user.target" >$service_path +$STD systemctl enable --now uptime-kuma.service +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/uptimekuma-v5-install.sh b/install/uptimekuma-v5-install.sh deleted file mode 100644 index d9c8284b..00000000 --- a/install/uptimekuma-v5-install.sh +++ /dev/null @@ -1,149 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y git -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -$STD bash <(curl -fsSL https://deb.nodesource.com/setup_18.x) -msg_ok "Set up Node.js Repository" - -msg_info "Installing Node.js" -$STD sudo apt-get install -y nodejs -msg_ok "Installed Node.js" - -msg_info "Installing Uptime Kuma" -$STD git clone https://github.com/louislam/uptime-kuma.git -mv uptime-kuma /opt/uptime-kuma -cd /opt/uptime-kuma -$STD npm run setup -msg_ok "Installed Uptime Kuma" - -msg_info "Creating Service" -service_path="/etc/systemd/system/uptime-kuma.service" -echo "[Unit] -Description=uptime-kuma - -[Service] -Type=simple -Restart=always -User=root -WorkingDirectory=/opt/uptime-kuma -ExecStart=/usr/bin/npm start - -[Install] -WantedBy=multi-user.target" >$service_path -$STD systemctl enable --now uptime-kuma.service -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/vaultwarden-v5-install.sh b/install/vaultwarden-install.sh similarity index 50% rename from install/vaultwarden-v5-install.sh rename to install/vaultwarden-install.sh index c1d63e1f..dd079560 100644 --- a/install/vaultwarden-v5-install.sh +++ b/install/vaultwarden-install.sh @@ -5,86 +5,13 @@ # License: MIT # https://github.com/tteck/Proxmox/raw/main/LICENSE -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os msg_info "Installing Dependencies" $STD apt-get update @@ -182,23 +109,8 @@ systemctl daemon-reload $STD systemctl enable --now vaultwarden.service msg_ok "Created Service" -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi +motd_ssh +root msg_info "Cleaning up" $STD apt-get autoremove diff --git a/install/whisparr-install.sh b/install/whisparr-install.sh new file mode 100644 index 00000000..64b757f5 --- /dev/null +++ b/install/whisparr-install.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y sqlite3 +msg_ok "Installed Dependencies" + +msg_info "Installing Whisparr" +mkdir -p /var/lib/whisparr/ +chmod 775 /var/lib/whisparr/ +$STD wget --content-disposition 'https://whisparr.servarr.com/v1/update/nightly/updatefile?os=linux&runtime=netcore&arch=x64' +$STD tar -xvzf Whisparr.develop.*.tar.gz +mv Whisparr /opt +chmod 775 /opt/Whisparr +msg_ok "Installed Whisparr" + +msg_info "Creating Service" +cat </etc/systemd/system/whisparr.service +[Unit] +Description=whisparr Daemon +After=syslog.target network.target +[Service] +UMask=0002 +Type=simple +ExecStart=/opt/Whisparr/Whisparr -nobrowser -data=/var/lib/whisparr/ +TimeoutStopSec=20 +KillMode=process +Restart=on-failure +[Install] +WantedBy=multi-user.target +EOF +systemctl -q daemon-reload +systemctl enable --now -q whisparr +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +rm -rf Whisparr.develop.*.tar.gz +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/whisparr-v5-install.sh b/install/whisparr-v5-install.sh deleted file mode 100644 index 82d4dce7..00000000 --- a/install/whisparr-v5-install.sh +++ /dev/null @@ -1,145 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y sqlite3 -msg_ok "Installed Dependencies" - -msg_info "Installing Whisparr" -mkdir -p /var/lib/whisparr/ -chmod 775 /var/lib/whisparr/ -$STD wget --content-disposition 'https://whisparr.servarr.com/v1/update/nightly/updatefile?os=linux&runtime=netcore&arch=x64' -$STD tar -xvzf Whisparr.develop.*.tar.gz -mv Whisparr /opt -chmod 775 /opt/Whisparr -msg_ok "Installed Whisparr" - -msg_info "Creating Service" -cat </etc/systemd/system/whisparr.service -[Unit] -Description=whisparr Daemon -After=syslog.target network.target -[Service] -UMask=0002 -Type=simple -ExecStart=/opt/Whisparr/Whisparr -nobrowser -data=/var/lib/whisparr/ -TimeoutStopSec=20 -KillMode=process -Restart=on-failure -[Install] -WantedBy=multi-user.target -EOF -systemctl -q daemon-reload -systemctl enable --now -q whisparr -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -rm -rf Whisparr.develop.*.tar.gz -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/whoogle-install.sh b/install/whoogle-install.sh new file mode 100644 index 00000000..943c59ad --- /dev/null +++ b/install/whoogle-install.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Installing Python3-pip" +$STD apt-get install -y python3-pip +msg_ok "Installed Python3-pip" + +msg_info "Installing Whoogle" +$STD pip install brotli +$STD pip install whoogle-search + +service_path="/etc/systemd/system/whoogle.service" +echo "[Unit] +Description=Whoogle-Search +After=network.target +[Service] +ExecStart=/usr/local/bin/whoogle-search --host 0.0.0.0 +Restart=always +User=root +[Install] +WantedBy=multi-user.target" >$service_path + +$STD systemctl enable --now whoogle.service +msg_ok "Installed Whoogle" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/whoogle-v5-install.sh b/install/whoogle-v5-install.sh deleted file mode 100644 index 816a32df..00000000 --- a/install/whoogle-v5-install.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -msg_ok "Installed Dependencies" - -msg_info "Installing Python3-pip" -$STD apt-get install -y python3-pip -msg_ok "Installed Python3-pip" - -msg_info "Installing Whoogle" -$STD pip install brotli -$STD pip install whoogle-search - -service_path="/etc/systemd/system/whoogle.service" -echo "[Unit] -Description=Whoogle-Search -After=network.target -[Service] -ExecStart=/usr/local/bin/whoogle-search --host 0.0.0.0 -Restart=always -User=root -[Install] -WantedBy=multi-user.target" >$service_path - -$STD systemctl enable --now whoogle.service -msg_ok "Installed Whoogle" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/wikijs-install.sh b/install/wikijs-install.sh new file mode 100644 index 00000000..4bea8690 --- /dev/null +++ b/install/wikijs-install.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y git +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x) +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing Wiki.js" +mkdir -p /opt/wikijs +cd /opt/wikijs +$STD wget https://github.com/Requarks/wiki/releases/latest/download/wiki-js.tar.gz +tar xzf wiki-js.tar.gz +rm wiki-js.tar.gz + +cat </opt/wikijs/config.yml +bindIP: 0.0.0.0 +port: 3000 +db: + type: sqlite + storage: /opt/wikijs/db.sqlite +logLevel: info +logFormat: default +dataPath: /opt/wikijs/data +bodyParserLimit: 5mb +EOF +$STD npm rebuild sqlite3 +msg_ok "Installed Wiki.js" + +msg_info "Creating Service" +service_path="/etc/systemd/system/wikijs.service" + +echo "[Unit] +Description=Wiki.js +After=network.target + +[Service] +Type=simple +ExecStart=/usr/bin/node server +Restart=always +User=root +Environment=NODE_ENV=production +WorkingDirectory=/opt/wikijs + +[Install] +WantedBy=multi-user.target" >$service_path +$STD systemctl enable --now wikijs +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/wikijs-v5-install.sh b/install/wikijs-v5-install.sh deleted file mode 100644 index 71a6e946..00000000 --- a/install/wikijs-v5-install.sh +++ /dev/null @@ -1,166 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y git -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x) -msg_ok "Set up Node.js Repository" - -msg_info "Installing Node.js" -$STD apt-get install -y nodejs -msg_ok "Installed Node.js" - -msg_info "Installing Wiki.js" -mkdir -p /opt/wikijs -cd /opt/wikijs -$STD wget https://github.com/Requarks/wiki/releases/latest/download/wiki-js.tar.gz -tar xzf wiki-js.tar.gz -rm wiki-js.tar.gz - -cat </opt/wikijs/config.yml -bindIP: 0.0.0.0 -port: 3000 -db: - type: sqlite - storage: /opt/wikijs/db.sqlite -logLevel: info -logFormat: default -dataPath: /opt/wikijs/data -bodyParserLimit: 5mb -EOF -$STD npm rebuild sqlite3 -msg_ok "Installed Wiki.js" - -msg_info "Creating Service" -service_path="/etc/systemd/system/wikijs.service" - -echo "[Unit] -Description=Wiki.js -After=network.target - -[Service] -Type=simple -ExecStart=/usr/bin/node server -Restart=always -User=root -Environment=NODE_ENV=production -WorkingDirectory=/opt/wikijs - -[Install] -WantedBy=multi-user.target" >$service_path -$STD systemctl enable --now wikijs -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/wireguard-install.sh b/install/wireguard-install.sh new file mode 100644 index 00000000..f63333c9 --- /dev/null +++ b/install/wireguard-install.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y gunicorn +msg_ok "Installed Dependencies" + +msg_info "Installing WireGuard (using pivpn.io)" +OPTIONS_PATH='/options.conf' +cat >$OPTIONS_PATH <<'EOF' +IPv4dev=eth0 +install_user=root +VPN=wireguard +pivpnNET=10.6.0.0 +subnetClass=24 +ALLOWED_IPS="0.0.0.0/0, ::0/0" +pivpnMTU=1420 +pivpnPORT=51820 +pivpnDNS1=1.1.1.1 +pivpnDNS2=8.8.8.8 +pivpnHOST= +pivpnPERSISTENTKEEPALIVE=25 +UNATTUPG=1 +EOF +$STD bash <(curl -fsSL https://install.pivpn.io) --unattended options.conf +msg_ok "Installed WireGuard" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/wireguard-v5-install.sh b/install/wireguard-v5-install.sh deleted file mode 100644 index 4d1b3127..00000000 --- a/install/wireguard-v5-install.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -OPTIONS_PATH='/options.conf' -cat >$OPTIONS_PATH <<'EOF' -IPv4dev=eth0 -install_user=root -VPN=wireguard -pivpnNET=10.6.0.0 -subnetClass=24 -ALLOWED_IPS="0.0.0.0/0, ::0/0" -pivpnMTU=1420 -pivpnPORT=51820 -pivpnDNS1=1.1.1.1 -pivpnDNS2=8.8.8.8 -pivpnHOST= -pivpnPERSISTENTKEEPALIVE=25 -UNATTUPG=1 -EOF - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y gunicorn -msg_ok "Installed Dependencies" - -msg_info "Installing WireGuard (using pivpn.io)" -$STD bash <(curl -fsSL https://install.pivpn.io) --unattended options.conf -msg_ok "Installed WireGuard" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/yunohost-install.sh b/install/yunohost-install.sh new file mode 100644 index 00000000..48e7bbd6 --- /dev/null +++ b/install/yunohost-install.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y gnupg +$STD apt-key adv --fetch-keys 'https://packages.sury.org/php/apt.gpg' +$STD apt-get install -y apt-transport-https +$STD apt-get install -y lsb-release +$STD apt-get install -y ca-certificates +msg_ok "Installed Dependencies" + +msg_info "Installing YunoHost (Patience)" +wget -q -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg +$STD bash <(curl -fsSL https://install.yunohost.org) -a +msg_ok "Installed YunoHost" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/yunohost-v5-install.sh b/install/yunohost-v5-install.sh deleted file mode 100644 index b8366bf0..00000000 --- a/install/yunohost-v5-install.sh +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y gnupg -$STD apt-key adv --fetch-keys 'https://packages.sury.org/php/apt.gpg' -$STD apt-get install -y apt-transport-https -$STD apt-get install -y lsb-release -$STD apt-get install -y ca-certificates -msg_ok "Installed Dependencies" - -msg_info "Installing YunoHost (Patience)" -wget -q -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg -$STD bash <(curl -fsSL https://install.yunohost.org) -a -msg_ok "Installed YunoHost" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/zigbee2mqtt-install.sh b/install/zigbee2mqtt-install.sh new file mode 100644 index 00000000..ca4e2905 --- /dev/null +++ b/install/zigbee2mqtt-install.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y git +$STD apt-get install -y make +$STD apt-get install -y g++ +$STD apt-get install -y gcc +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +$STD bash <(curl -fsSL https://deb.nodesource.com/setup_18.x) +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Setting up Zigbee2MQTT Repository" +$STD git clone https://github.com/Koenkk/zigbee2mqtt.git /opt/zigbee2mqtt +msg_ok "Set up Zigbee2MQTT Repository" + +read -r -p "Switch to Edge/dev branch? (y/N) " prompt +if [[ $prompt == "y" ]]; then + DEV="y" +else + DEV="n" +fi + +msg_info "Installing Zigbee2MQTT" +cd /opt/zigbee2mqtt +if [[ $DEV == "y" ]]; then +$STD git checkout dev +fi +$STD npm ci +msg_ok "Installed Zigbee2MQTT" + +msg_info "Creating Service" +service_path="/etc/systemd/system/zigbee2mqtt.service" +echo "[Unit] +Description=zigbee2mqtt +After=network.target +[Service] +Environment=NODE_ENV=production +ExecStart=/usr/bin/npm start +WorkingDirectory=/opt/zigbee2mqtt +StandardOutput=inherit +StandardError=inherit +Restart=always +User=root +[Install] +WantedBy=multi-user.target" >$service_path +$STD systemctl enable zigbee2mqtt.service +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/zigbee2mqtt-v5-install.sh b/install/zigbee2mqtt-v5-install.sh deleted file mode 100644 index ae1ec650..00000000 --- a/install/zigbee2mqtt-v5-install.sh +++ /dev/null @@ -1,165 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y git -$STD apt-get install -y make -$STD apt-get install -y g++ -$STD apt-get install -y gcc -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -$STD bash <(curl -fsSL https://deb.nodesource.com/setup_18.x) -msg_ok "Set up Node.js Repository" - -msg_info "Installing Node.js" -$STD apt-get install -y nodejs -msg_ok "Installed Node.js" - -msg_info "Setting up Zigbee2MQTT Repository" -$STD git clone https://github.com/Koenkk/zigbee2mqtt.git /opt/zigbee2mqtt -msg_ok "Set up Zigbee2MQTT Repository" - -read -r -p "Switch to Edge/dev branch? (y/N) " prompt -if [[ $prompt == "y" ]]; then - DEV="y" -else - DEV="n" -fi - -msg_info "Installing Zigbee2MQTT" -cd /opt/zigbee2mqtt -if [[ $DEV == "y" ]]; then -$STD git checkout dev -fi -$STD npm ci -msg_ok "Installed Zigbee2MQTT" - -msg_info "Creating Service" -service_path="/etc/systemd/system/zigbee2mqtt.service" -echo "[Unit] -Description=zigbee2mqtt -After=network.target -[Service] -Environment=NODE_ENV=production -ExecStart=/usr/bin/npm start -WorkingDirectory=/opt/zigbee2mqtt -StandardOutput=inherit -StandardError=inherit -Restart=always -User=root -[Install] -WantedBy=multi-user.target" >$service_path -$STD systemctl enable zigbee2mqtt.service -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/install/zwave-js-ui-install.sh b/install/zwave-js-ui-install.sh new file mode 100644 index 00000000..67862f1f --- /dev/null +++ b/install/zwave-js-ui-install.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +$STD apt-get install -y unzip +msg_ok "Installed Dependencies" + +msg_info "Installing Z-Wave JS UI" +mkdir /opt/zwave-js-ui +cd /opt/zwave-js-ui +RELEASE=$(curl -s https://api.github.com/repos/zwave-js/zwave-js-ui/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +$STD wget https://github.com/zwave-js/zwave-js-ui/releases/download/${RELEASE}/zwave-js-ui-${RELEASE}-linux.zip +$STD unzip zwave-js-ui-${RELEASE}-linux.zip +msg_ok "Installed Z-Wave JS UI" + +msg_info "Creating Service" +service_path="/etc/systemd/system/zwave-js-ui.service" +echo "[Unit] +Description=zwave-js-ui +Wants=network-online.target +After=network-online.target +[Service] +User=root +WorkingDirectory=/opt/zwave-js-ui +ExecStart=/opt/zwave-js-ui/zwave-js-ui-linux +[Install] +WantedBy=multi-user.target" >$service_path +systemctl start zwave-js-ui +$STD systemctl enable zwave-js-ui +msg_ok "Created Service" + +motd_ssh +root + +msg_info "Cleaning up" +rm zwave-js-ui-${RELEASE}-linux.zip +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" diff --git a/install/zwave-js-ui-v5-install.sh b/install/zwave-js-ui-v5-install.sh deleted file mode 100644 index 41cfb081..00000000 --- a/install/zwave-js-ui-v5-install.sh +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2023 tteck -# Author: tteck (tteckster) -# License: MIT -# https://github.com/tteck/Proxmox/raw/main/LICENSE - -if [ "$VERBOSE" = "yes" ]; then set -x; STD=""; else STD="silent"; fi -silent() { "$@" > /dev/null 2>&1; } -if [ "$DISABLEIPV6" == "yes" ]; then echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf; $STD sysctl -p; fi -YW=$(echo "\033[33m") -RD=$(echo "\033[01;31m") -BL=$(echo "\033[36m") -GN=$(echo "\033[1;92m") -CL=$(echo "\033[m") -RETRY_NUM=10 -RETRY_EVERY=3 -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -Eeuo pipefail -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -function error_handler() { - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message\n" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -echo $tz > /etc/timezone -ln -sf /usr/share/zoneinfo/$tz /etc/localtime -for ((i=RETRY_NUM; i>0; i--)); do - if [ "$(hostname -I)" != "" ]; then - break - fi - echo 1>&2 -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY -done -if [ "$(hostname -I)" = "" ]; then - echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - echo -e " 🖧 Check Network Settings" - exit 1 -fi -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -set +e -trap - ERR -if ping -c 1 -W 1 1.1.1.1 &> /dev/null; then msg_ok "Internet Connected"; else - msg_error "Internet NOT Connected" - read -r -p "Would you like to continue anyway? " prompt - if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then - echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" - else - echo -e " 🖧 Check Network Settings" - exit 1 - fi -fi -RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') -if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi -set -e -trap 'error_handler $LINENO "$BASH_COMMAND"' ERR - -msg_info "Updating Container OS" -$STD apt-get update -$STD apt-get -y upgrade -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc -$STD apt-get install -y unzip -msg_ok "Installed Dependencies" - -msg_info "Installing Z-Wave JS UI" -mkdir /opt/zwave-js-ui -cd /opt/zwave-js-ui -RELEASE=$(curl -s https://api.github.com/repos/zwave-js/zwave-js-ui/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -$STD wget https://github.com/zwave-js/zwave-js-ui/releases/download/${RELEASE}/zwave-js-ui-${RELEASE}-linux.zip -$STD unzip zwave-js-ui-${RELEASE}-linux.zip -msg_ok "Installed Z-Wave JS UI" - -msg_info "Creating Service" -service_path="/etc/systemd/system/zwave-js-ui.service" -echo "[Unit] -Description=zwave-js-ui -Wants=network-online.target -After=network-online.target -[Service] -User=root -WorkingDirectory=/opt/zwave-js-ui -ExecStart=/opt/zwave-js-ui/zwave-js-ui-linux -[Install] -WantedBy=multi-user.target" >$service_path -systemctl start zwave-js-ui -$STD systemctl enable zwave-js-ui -msg_ok "Created Service" - -echo "export TERM='xterm-256color'" >>/root/.bashrc -echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" > /etc/motd -chmod -x /etc/update-motd.d/* -if ! getent shadow root | grep -q "^root:[^\!*]"; then - msg_info "Customizing Container" - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat <$GETTY_OVERRIDE -[Service] -ExecStart= -ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM -EOF - systemctl daemon-reload - systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') - msg_ok "Customized Container" -fi -if [[ "${SSH_ROOT}" == "yes" ]]; then sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; systemctl restart sshd; fi - -msg_info "Cleaning up" -rm zwave-js-ui-${RELEASE}-linux.zip -$STD apt-get autoremove -$STD apt-get autoclean -msg_ok "Cleaned" diff --git a/misc/alpine-install.func b/misc/alpine-install.func new file mode 100644 index 00000000..f2f74a08 --- /dev/null +++ b/misc/alpine-install.func @@ -0,0 +1,116 @@ +color() { + YW=$(echo "\033[33m") + BL=$(echo "\033[36m") + RD=$(echo "\033[01;31m") + BGN=$(echo "\033[4;92m") + GN=$(echo "\033[1;92m") + DGN=$(echo "\033[32m") + CL=$(echo "\033[m") + RETRY_NUM=10 + RETRY_EVERY=3 + i=$RETRY_NUM + CM="${GN}✓${CL}" + CROSS="${RD}✗${CL}" + BFR="\\r\\033[K" + HOLD="-" +} + +verb_ip6() { + if [ "$VERBOSE" = "yes" ]; then + set -x + STD="" + else STD="silent"; fi + silent() { "$@" >/dev/null 2>&1; } + if [ "$DISABLEIPV6" == "yes" ]; then + echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf + $STD sysctl -p + fi +} + +catch_errors() { + set -Eeuo pipefail + trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +} + +error_handler() { + local exit_code="$?" + local line_number="$1" + local command="$2" + local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" + echo -e "\n$error_message\n" +} + +msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." +} + +msg_ok() { + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" +} + +msg_error() { + local msg="$1" + echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" +} + +setting_up_container() { + msg_info "Setting up Container OS" + while [ $i -gt 0 ]; do + if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" != "" ]; then + break + fi + echo 1>&2 -en "${CROSS}${RD} No Network! " + sleep $RETRY_EVERY + i=$((i - 1)) + done + + if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" = "" ]; then + echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" + echo -e " 🖧 Check Network Settings" + exit 1 + fi + cat </etc/apk/repositories +https://dl-cdn.alpinelinux.org/alpine/edge/main +https://dl-cdn.alpinelinux.org/alpine/edge/community +https://dl-cdn.alpinelinux.org/alpine/edge/testing +EOF + msg_ok "Set up Container OS" + msg_ok "Network Connected: ${BL}$(ip addr show | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1 | tail -n1)${CL}" +} + +network_check() { + set +e + trap - ERR + if ping -c 1 -W 1 1.1.1.1 &>/dev/null; then msg_ok "Internet Connected"; else + msg_error "Internet NOT Connected" + read -r -p "Would you like to continue anyway? " prompt + if echo "$prompt" | grep -Eq "^(y|yes)$"; then + echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" + else + echo -e " 🖧 Check Network Settings" + exit 1 + fi + fi + RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') + if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi + set -e + trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +} + +update_os() { + msg_info "Updating Container OS" + $STD apk update + $STD apk upgrade + msg_ok "Updated Container OS" +} + +motd_ssh() { + echo "export TERM='xterm-256color'" >>/root/.bashrc + echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" >/etc/motd + if [[ "${SSH_ROOT}" == "yes" ]]; then + $STD rc-update add sshd + $STD /etc/init.d/sshd start + fi +} diff --git a/misc/alpine.func b/misc/alpine.func new file mode 100644 index 00000000..b784217c --- /dev/null +++ b/misc/alpine.func @@ -0,0 +1,400 @@ +variables() { + NSAPP=$(echo ${APP,,} | tr -d ' ') + var_install="${NSAPP}-install" + INTEGER='^[0-9]+([.][0-9]+)?$' +} + +color() { + YW=$(echo "\033[33m") + BL=$(echo "\033[36m") + RD=$(echo "\033[01;31m") + BGN=$(echo "\033[4;92m") + GN=$(echo "\033[1;92m") + DGN=$(echo "\033[32m") + CL=$(echo "\033[m") + CM="${GN}✓${CL}" + CROSS="${RD}✗${CL}" + BFR="\\r\\033[K" + HOLD="-" +} + +catch_errors() { + set -Eeuo pipefail + trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +} + +error_handler() { + local exit_code="$?" + local line_number="$1" + local command="$2" + local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" + echo -e "\n$error_message\n" +} + +msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." +} + +msg_ok() { + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" +} + +msg_error() { + local msg="$1" + echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" +} + +pve_check() { + if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then + echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" + echo -e "Requires PVE Version 7.0 or higher" + echo -e "Exiting..." + sleep 2 + exit + fi +} + +arch_check() { + if [ "$(dpkg --print-architecture)" != "amd64" ]; then + echo -e "\n ${CROSS} This script will not work with PiMox! \n" + echo -e "Exiting..." + sleep 2 + exit + fi +} + +echo_default() { + echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" + echo -e "${DGN}Using Root Password: ${BGN}alpine${CL}" + echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" + echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" + echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" + echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" + echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" + echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" + echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" + echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" + echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" + echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" + echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" + echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" + echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" + echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" + echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" + echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" + echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" +} + +exit-script() { + clear + echo -e "⚠ User exited script \n" + exit +} + +advanced_settings() { + if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ + "1" "Unprivileged" ON \ + "0" "Privileged" OFF \ + 3>&1 1>&2 2>&3); then + echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" + else + exit-script + fi + + if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then + if [ -z $PW1 ]; then + PW1="Automatic Login" + PW=" " + else + PW="-password $PW1" + fi + echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" + else + exit-script + fi + + if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then + if [ -z "$CT_ID" ]; then + CT_ID="$NEXTID" + echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" + else + echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" + fi + else + exit + fi + + if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then + if [ -z "$CT_NAME" ]; then + HN="$NSAPP" + else + HN=$(echo ${CT_NAME,,} | tr -d ' ') + fi + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + else + exit-script + fi + + if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then + if [ -z "$DISK_SIZE" ]; then + DISK_SIZE="$var_disk" + echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" + else + if ! [[ $DISK_SIZE =~ $INTEGER ]]; then + echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" + advanced_settings + fi + echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" + fi + else + exit-script + fi + + if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then + if [ -z "$CORE_COUNT" ]; then + CORE_COUNT="$var_cpu" + echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" + else + echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" + fi + else + exit-script + fi + + if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then + if [ -z "$RAM_SIZE" ]; then + RAM_SIZE="$var_ram" + echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" + else + echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" + fi + else + exit-script + fi + + if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then + if [ -z "$BRG" ]; then + BRG="vmbr0" + echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" + else + echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" + fi + else + exit-script + fi + + if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then + if [ -z $NET ]; then + NET="dhcp" + echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" + else + echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" + fi + else + exit-script + fi + + if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then + if [ -z $GATE1 ]; then + GATE1="Default" + GATE="" + else + GATE=",gw=$GATE1" + fi + echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" + else + exit-script + fi + + if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then + DISABLEIP6="yes" + else + DISABLEIP6="no" + fi + echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" + + if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then + if [ -z $MTU1 ]; then + MTU1="Default" + MTU="" + else + MTU=",mtu=$MTU1" + fi + echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" + else + exit-script + fi + + if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then + if [ -z $SD ]; then + SX=Host + SD="" + else + SX=$SD + SD="-searchdomain=$SD" + fi + echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" + else + exit-script + fi + + if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then + if [ -z $NX ]; then + NX=Host + NS="" + else + NS="-nameserver=$NX" + fi + echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" + else + exit-script + fi + + if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then + if [ -z $MAC1 ]; then + MAC1="Default" + MAC="" + else + MAC=",hwaddr=$MAC1" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" + fi + else + exit-script + fi + + if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then + if [ -z $VLAN1 ]; then + VLAN1="Default" + VLAN="" + else + VLAN=",tag=$VLAN1" + fi + echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" + else + exit-script + fi + + if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then + SSH="yes" + else + SSH="no" + fi + echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" + + if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then + VERB="yes" + else + VERB="no" + fi + echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" + + if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then + echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" + else + clear + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi +} + +install_script() { + arch_check + pve_check + timezone=$(cat /etc/timezone) + NEXTID=$(pvesh get /cluster/nextid) + header_info + if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then + header_info + echo -e "${BL}Using Default Settings${CL}" + default_settings + else + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi +} + +start() { + if command -v pveversion >/dev/null 2>&1; then + if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then + clear + echo -e "⚠ User exited script \n" + exit + fi + install_script + fi + + if ! command -v pveversion >/dev/null 2>&1; then + if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then + clear + echo -e "⚠ User exited script \n" + exit + fi + set +e + update_script + fi +} + +build_container() { + if [ "$VERB" == "yes" ]; then set -x; fi + if [ "$CT_TYPE" == "1" ]; then + FEATURES="nesting=1,keyctl=1" + else + FEATURES="nesting=1" + fi + TEMP_DIR=$(mktemp -d) + pushd $TEMP_DIR >/dev/null + export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/alpine-install.func)" + export tz="$timezone" + export DISABLEIPV6="$DISABLEIP6" + export APPLICATION="$APP" + export VERBOSE="$VERB" + export SSH_ROOT="${SSH}" + export CTID=$CT_ID" + export PCT_OSTYPE="$var_os" + export PCT_OSVERSION="$var_version" + export PCT_DISK_SIZE="$DISK_SIZE" + export PCT_OPTIONS=" + -features $FEATURES + -hostname $HN + $SD + $NS + -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU + -onboot 1 + -cores $CORE_COUNT + -memory $RAM_SIZE + -unprivileged $CT_TYPE + $PW + " + bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit + if [ "$CT_TYPE" == "0" ]; then + LXC_CONFIG=/etc/pve/lxc/${CTID}.conf + cat <>$LXC_CONFIG +lxc.cgroup2.devices.allow: a +lxc.cap.drop: +lxc.cgroup2.devices.allow: c 188:* rwm +lxc.cgroup2.devices.allow: c 189:* rwm +lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir +lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file +lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file +lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file +lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file +EOF + fi + msg_info "Starting LXC Container" + pct start "$CTID" + msg_ok "Started LXC Container" + pct exec "$CTID" -- ash -c "apk add bash >/dev/null" + lxc-attach -n "$CTID" -- bash -c "$(wget -qO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit + +} + +description() { + IP=$(pct exec "$CTID" ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) + pct set "$CTID" -description "# ${APP} LXC + ### https://tteck.github.io/Proxmox/ + " +} diff --git a/misc/debian.func b/misc/debian.func new file mode 100644 index 00000000..fff5e559 --- /dev/null +++ b/misc/debian.func @@ -0,0 +1,403 @@ +variables() { + NSAPP=$(echo ${APP,,} | tr -d ' ') + var_install="${NSAPP}-install" + timezone=$(cat /etc/timezone) + INTEGER='^[0-9]+([.][0-9]+)?$' +} + +color() { + YW=$(echo "\033[33m") + BL=$(echo "\033[36m") + RD=$(echo "\033[01;31m") + BGN=$(echo "\033[4;92m") + GN=$(echo "\033[1;92m") + DGN=$(echo "\033[32m") + CL=$(echo "\033[m") + CM="${GN}✓${CL}" + CROSS="${RD}✗${CL}" + BFR="\\r\\033[K" + HOLD="-" +} + +catch_errors() { + set -Eeuo pipefail + trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +} + +error_handler() { + local exit_code="$?" + local line_number="$1" + local command="$2" + local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" + echo -e "\n$error_message\n" +} + +msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." +} + +msg_ok() { + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" +} + +msg_error() { + local msg="$1" + echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" +} + +pve_check() { + if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then + echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" + echo -e "Requires PVE Version 7.0 or higher" + echo -e "Exiting..." + sleep 2 + exit + fi +} + +arch_check() { + if [ "$(dpkg --print-architecture)" != "amd64" ]; then + echo -e "\n ${CROSS} This script will not work with PiMox! \n" + echo -e "Exiting..." + sleep 2 + exit + fi +} + +echo_default() { + echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" + echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" + echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" + echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" + echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" + echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" + echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" + echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" + echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" + echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" + echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" + echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" + echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" + echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" + echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" + echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" + echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" + echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" + echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" +} + +exit-script() { + clear + echo -e "⚠ User exited script \n" + exit +} + +advanced_settings() { + if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ + "1" "Unprivileged" ON \ + "0" "Privileged" OFF \ + 3>&1 1>&2 2>&3); then + echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" + else + exit-script + fi + + if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then + if [ -z $PW1 ]; then + PW1="Automatic Login" + PW=" " + else + PW="-password $PW1" + fi + echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" + else + exit-script + fi + + if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then + if [ -z "$CT_ID" ]; then + CT_ID="$NEXTID" + echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" + else + echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" + fi + else + exit + fi + + if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then + if [ -z "$CT_NAME" ]; then + HN="$NSAPP" + else + HN=$(echo ${CT_NAME,,} | tr -d ' ') + fi + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + else + exit-script + fi + + if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then + if [ -z "$DISK_SIZE" ]; then + DISK_SIZE="$var_disk" + echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" + else + if ! [[ $DISK_SIZE =~ $INTEGER ]]; then + echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" + advanced_settings + fi + echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" + fi + else + exit-script + fi + + if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then + if [ -z "$CORE_COUNT" ]; then + CORE_COUNT="$var_cpu" + echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" + else + echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" + fi + else + exit-script + fi + + if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then + if [ -z "$RAM_SIZE" ]; then + RAM_SIZE="$var_ram" + echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" + else + echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" + fi + else + exit-script + fi + + if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then + if [ -z "$BRG" ]; then + BRG="vmbr0" + echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" + else + echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" + fi + else + exit-script + fi + + if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then + if [ -z $NET ]; then + NET="dhcp" + echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" + else + echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" + fi + else + exit-script + fi + + if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then + if [ -z $GATE1 ]; then + GATE1="Default" + GATE="" + else + GATE=",gw=$GATE1" + fi + echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" + else + exit-script + fi + + if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then + DISABLEIP6="yes" + else + DISABLEIP6="no" + fi + echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" + + if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then + if [ -z $MTU1 ]; then + MTU1="Default" + MTU="" + else + MTU=",mtu=$MTU1" + fi + echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" + else + exit-script + fi + + if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then + if [ -z $SD ]; then + SX=Host + SD="" + else + SX=$SD + SD="-searchdomain=$SD" + fi + echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" + else + exit-script + fi + + if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then + if [ -z $NX ]; then + NX=Host + NS="" + else + NS="-nameserver=$NX" + fi + echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" + else + exit-script + fi + + if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then + if [ -z $MAC1 ]; then + MAC1="Default" + MAC="" + else + MAC=",hwaddr=$MAC1" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" + fi + else + exit-script + fi + + if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then + if [ -z $VLAN1 ]; then + VLAN1="Default" + VLAN="" + else + VLAN=",tag=$VLAN1" + fi + echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" + else + exit-script + fi + + if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then + SSH="yes" + else + SSH="no" + fi + echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" + + if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then + VERB="yes" + else + VERB="no" + fi + echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" + + if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then + echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" + else + clear + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi +} + +install_script() { + arch_check + pve_check + NEXTID=$(pvesh get /cluster/nextid) + header_info + if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then + header_info + echo -e "${BL}Using Default Settings${CL}" + default_settings + else + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi +} + +start() { + if command -v pveversion >/dev/null 2>&1; then + if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then + clear + echo -e "⚠ User exited script \n" + exit + fi + install_script + fi + + if ! command -v pveversion >/dev/null 2>&1; then + if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then + clear + echo -e "⚠ User exited script \n" + exit + fi + update_script + fi +} + +build_container() { + if [ "$VERB" == "yes" ]; then set -x; fi + if [ "$CT_TYPE" == "1" ]; then + FEATURES="nesting=1,keyctl=1" + else + FEATURES="nesting=1" + fi + TEMP_DIR=$(mktemp -d) + pushd $TEMP_DIR >/dev/null + export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/install.func)" + export tz="$timezone" + export DISABLEIPV6="$DISABLEIP6" + export APPLICATION="$APP" + export VERBOSE="$VERB" + export SSH_ROOT="${SSH}" + export CTID="$CT_ID" + export PCT_OSTYPE="$var_os" + export PCT_OSVERSION="$var_version" + export PCT_DISK_SIZE="$DISK_SIZE" + export PCT_OPTIONS=" + -features $FEATURES + -hostname $HN + $SD + $NS + -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU + -onboot 1 + -cores $CORE_COUNT + -memory $RAM_SIZE + -unprivileged $CT_TYPE + $PW + " + bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit + LXC_CONFIG=/etc/pve/lxc/${CTID}.conf + if [ "$CT_TYPE" == "0" ]; then + cat <>$LXC_CONFIG +lxc.cgroup2.devices.allow: a +lxc.cap.drop: +lxc.cgroup2.devices.allow: c 188:* rwm +lxc.cgroup2.devices.allow: c 189:* rwm +lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir +lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file +lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file +lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file +lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file +EOF + else + cat <>$LXC_CONFIG +lxc.cgroup2.devices.allow: a +lxc.cap.drop: +EOF + fi + msg_info "Starting LXC Container" + pct start "$CTID" + msg_ok "Started LXC Container" + lxc-attach -n "$CTID" -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit + +} + +description() { + IP=$(pct exec "$CTID" ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) + pct set "$CTID" -description "# ${APP} LXC + ### https://tteck.github.io/Proxmox/ + " +} diff --git a/misc/docker.func b/misc/docker.func new file mode 100644 index 00000000..702f598e --- /dev/null +++ b/misc/docker.func @@ -0,0 +1,409 @@ +variables() { + NSAPP=$(echo ${APP,,} | tr -d ' ') + var_install="${NSAPP}-install" + timezone=$(cat /etc/timezone) + INTEGER='^[0-9]+([.][0-9]+)?$' +} + +color() { + YW=$(echo "\033[33m") + BL=$(echo "\033[36m") + RD=$(echo "\033[01;31m") + BGN=$(echo "\033[4;92m") + GN=$(echo "\033[1;92m") + DGN=$(echo "\033[32m") + CL=$(echo "\033[m") + CM="${GN}✓${CL}" + CROSS="${RD}✗${CL}" + BFR="\\r\\033[K" + HOLD="-" +} + +catch_errors() { + set -Eeuo pipefail + trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +} + +error_handler() { + local exit_code="$?" + local line_number="$1" + local command="$2" + local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" + echo -e "\n$error_message\n" +} + +msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." +} + +msg_ok() { + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" +} + +msg_error() { + local msg="$1" + echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" +} + +pve_check() { + if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then + echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" + echo -e "Requires PVE Version 7.0 or higher" + echo -e "Exiting..." + sleep 2 + exit + fi +} + +arch_check() { + if [ "$(dpkg --print-architecture)" != "amd64" ]; then + echo -e "\n ${CROSS} This script will not work with PiMox! \n" + echo -e "Exiting..." + sleep 2 + exit + fi +} + +echo_default() { + echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" + echo -e "${DGN}Using Root Password: ${BGN}Automatic Login${CL}" + echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" + echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" + echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" + echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" + echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" + echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" + echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" + echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" + echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" + echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" + echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" + echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" + echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" + echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" + echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" + echo -e "${DGN}Enable Fuse Overlayfs (ZFS): ${BGN}No${CL}" + echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" + echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" +} + +exit-script() { + clear + echo -e "⚠ User exited script \n" + exit +} + +advanced_settings() { + if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ + "1" "Unprivileged" ON \ + "0" "Privileged" OFF \ + 3>&1 1>&2 2>&3); then + echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" + else + exit-script + fi + + if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then + if [ -z $PW1 ]; then + PW1="Automatic Login" + PW=" " + else + PW="-password $PW1" + fi + echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" + else + exit-script + fi + + if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then + if [ -z "$CT_ID" ]; then + CT_ID="$NEXTID" + echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" + else + echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" + fi + else + exit + fi + + if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then + if [ -z "$CT_NAME" ]; then + HN="$NSAPP" + else + HN=$(echo ${CT_NAME,,} | tr -d ' ') + fi + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + else + exit-script + fi + + if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then + if [ -z "$DISK_SIZE" ]; then + DISK_SIZE="$var_disk" + echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" + else + if ! [[ $DISK_SIZE =~ $INTEGER ]]; then + echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" + advanced_settings + fi + echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" + fi + else + exit-script + fi + + if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then + if [ -z "$CORE_COUNT" ]; then + CORE_COUNT="$var_cpu" + echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" + else + echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" + fi + else + exit-script + fi + + if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then + if [ -z "$RAM_SIZE" ]; then + RAM_SIZE="$var_ram" + echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" + else + echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" + fi + else + exit-script + fi + + if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then + if [ -z "$BRG" ]; then + BRG="vmbr0" + echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" + else + echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" + fi + else + exit-script + fi + + if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then + if [ -z $NET ]; then + NET="dhcp" + echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" + else + echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" + fi + else + exit-script + fi + + if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then + if [ -z $GATE1 ]; then + GATE1="Default" + GATE="" + else + GATE=",gw=$GATE1" + fi + echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" + else + exit-script + fi + + if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then + DISABLEIP6="yes" + else + DISABLEIP6="no" + fi + echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" + + if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then + if [ -z $MTU1 ]; then + MTU1="Default" + MTU="" + else + MTU=",mtu=$MTU1" + fi + echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" + else + exit-script + fi + + if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then + if [ -z $SD ]; then + SX=Host + SD="" + else + SX=$SD + SD="-searchdomain=$SD" + fi + echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" + else + exit-script + fi + + if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then + if [ -z $NX ]; then + NX=Host + NS="" + else + NS="-nameserver=$NX" + fi + echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" + else + exit-script + fi + + if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then + if [ -z $MAC1 ]; then + MAC1="Default" + MAC="" + else + MAC=",hwaddr=$MAC1" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" + fi + else + exit-script + fi + + if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then + if [ -z $VLAN1 ]; then + VLAN1="Default" + VLAN="" + else + VLAN=",tag=$VLAN1" + fi + echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" + else + exit-script + fi + + if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then + SSH="yes" + else + SSH="no" + fi + echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" + + if (whiptail --defaultno --title "FUSE OVERLAYFS" --yesno "(ZFS) Enable Fuse Overlayfs?" 10 58); then + FUSE="yes" + else + FUSE="no" + fi + echo -e "${DGN}Enable Fuse Overlayfs (ZFS): ${BGN}$FUSE${CL}" + + if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then + VERB="yes" + else + VERB="no" + fi + echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" + + if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then + echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" + else + clear + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi +} + +install_script() { + arch_check + pve_check + NEXTID=$(pvesh get /cluster/nextid) + header_info + if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then + header_info + echo -e "${BL}Using Default Settings${CL}" + default_settings + else + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi +} + +start() { + if command -v pveversion >/dev/null 2>&1; then + if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then + clear + echo -e "⚠ User exited script \n" + exit + fi + install_script + fi + + if ! command -v pveversion >/dev/null 2>&1; then + if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then + clear + echo -e "⚠ User exited script \n" + exit + fi + update_script + fi +} + +build_container() { + if [ "$VERB" == "yes" ]; then set -x; fi + if [ "$FUSE" == "yes" ]; then + FEATURES="fuse=1,keyctl=1,nesting=1" + else + FEATURES="keyctl=1,nesting=1" + fi + TEMP_DIR=$(mktemp -d) + pushd $TEMP_DIR >/dev/null + export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/install.func)" + export tz="$timezone" + export ST="$FUSE" + export DISABLEIPV6="$DISABLEIP6" + export APPLICATION="$APP" + export VERBOSE="$VERB" + export SSH_ROOT="${SSH}" + export CTID="$CT_ID" + export PCT_OSTYPE="$var_os" + export PCT_OSVERSION="$var_version" + export PCT_DISK_SIZE="$DISK_SIZE" + export PCT_OPTIONS=" + -features $FEATURES + -hostname $HN + $SD + $NS + -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU + -onboot 1 + -cores $CORE_COUNT + -memory $RAM_SIZE + -unprivileged $CT_TYPE + $PW + " + bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit + LXC_CONFIG=/etc/pve/lxc/${CTID}.conf + cat <>$LXC_CONFIG +lxc.cgroup2.devices.allow: a +lxc.cap.drop: +EOF + if [ "$CT_TYPE" == "0" ]; then + cat <>$LXC_CONFIG +lxc.cgroup2.devices.allow: c 188:* rwm +lxc.cgroup2.devices.allow: c 189:* rwm +lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir +lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file +lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file +lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file +lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file +EOF + fi + msg_info "Starting LXC Container" + pct start "$CTID" + msg_ok "Started LXC Container" + lxc-attach -n "$CTID" -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit + +} + +description() { + IP=$(pct exec "$CTID" ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) + pct set "$CTID" -description "# ${APP} LXC + ### https://tteck.github.io/Proxmox/ + " +} diff --git a/misc/install.func b/misc/install.func new file mode 100644 index 00000000..a2fa99e0 --- /dev/null +++ b/misc/install.func @@ -0,0 +1,133 @@ +color() { + YW=$(echo "\033[33m") + BL=$(echo "\033[36m") + RD=$(echo "\033[01;31m") + BGN=$(echo "\033[4;92m") + GN=$(echo "\033[1;92m") + DGN=$(echo "\033[32m") + CL=$(echo "\033[m") + RETRY_NUM=10 + RETRY_EVERY=3 + CM="${GN}✓${CL}" + CROSS="${RD}✗${CL}" + BFR="\\r\\033[K" + HOLD="-" +} + +verb_ip6() { + if [ "$VERBOSE" = "yes" ]; then + set -x + STD="" + else STD="silent"; fi + silent() { "$@" >/dev/null 2>&1; } + if [ "$DISABLEIPV6" == "yes" ]; then + echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf + $STD sysctl -p + fi +} + +catch_errors() { + set -Eeuo pipefail + trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +} + +error_handler() { + local exit_code="$?" + local line_number="$1" + local command="$2" + local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" + echo -e "\n$error_message\n" +} + +msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." +} + +msg_ok() { + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" +} + +msg_error() { + local msg="$1" + echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" +} + +setting_up_container() { + msg_info "Setting up Container OS" + sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen + locale-gen >/dev/null + echo $tz >/etc/timezone + ln -sf /usr/share/zoneinfo/$tz /etc/localtime + for ((i = RETRY_NUM; i > 0; i--)); do + if [ "$(hostname -I)" != "" ]; then + break + fi + echo 1>&2 -en "${CROSS}${RD} No Network! " + sleep $RETRY_EVERY + done + if [ "$(hostname -I)" = "" ]; then + echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" + echo -e " 🖧 Check Network Settings" + exit 1 + fi + msg_ok "Set up Container OS" + msg_ok "Network Connected: ${BL}$(hostname -I)" +} + +network_check() { + set +e + trap - ERR + if ping -c 1 -W 1 1.1.1.1 &>/dev/null; then msg_ok "Internet Connected"; else + msg_error "Internet NOT Connected" + read -r -p "Would you like to continue anyway? " prompt + if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + echo -e " ⚠️ ${RD}Expect Issues Without Internet${CL}" + else + echo -e " 🖧 Check Network Settings" + exit 1 + fi + fi + RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }') + if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved github.com to ${BL}$RESOLVEDIP${CL}"; fi + set -e + trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +} + +update_os() { + msg_info "Updating Container OS" + $STD apt-get update + $STD apt-get -y upgrade + msg_ok "Updated Container OS" +} + +motd_ssh() { + echo "export TERM='xterm-256color'" >>/root/.bashrc + echo -e "$APPLICATION LXC provided by https://tteck.github.io/Proxmox/\n" >/etc/motd + chmod -x /etc/update-motd.d/* + if [[ "${SSH_ROOT}" == "yes" ]]; then + sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config + systemctl restart sshd + fi +} + +customize() { + msg_info "Customizing Container" + GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" + mkdir -p $(dirname $GETTY_OVERRIDE) + cat <$GETTY_OVERRIDE + [Service] + ExecStart= + ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM +EOF + systemctl daemon-reload + systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') + msg_ok "Customized Container" +} + +root() { + if ! getent shadow root | grep -q "^root:[^\!*]"; then + customize + fi +} diff --git a/misc/ubuntu.func b/misc/ubuntu.func new file mode 100644 index 00000000..04695499 --- /dev/null +++ b/misc/ubuntu.func @@ -0,0 +1,428 @@ +variables() { + NSAPP=$(echo ${APP,,} | tr -d ' ') + var_install="${NSAPP}-install" + timezone=$(cat /etc/timezone) + INTEGER='^[0-9]+([.][0-9]+)?$' +} + +color() { + YW=$(echo "\033[33m") + BL=$(echo "\033[36m") + RD=$(echo "\033[01;31m") + BGN=$(echo "\033[4;92m") + GN=$(echo "\033[1;92m") + DGN=$(echo "\033[32m") + CL=$(echo "\033[m") + CM="${GN}✓${CL}" + CROSS="${RD}✗${CL}" + BFR="\\r\\033[K" + HOLD="-" +} + +catch_errors() { + set -Eeuo pipefail + trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +} + +error_handler() { + local exit_code="$?" + local line_number="$1" + local command="$2" + local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" + echo -e "\n$error_message\n" +} + +msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." +} + +msg_ok() { + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" +} + +msg_error() { + local msg="$1" + echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" +} + +pve_check() { + if [ $(pveversion | grep -c "pve-manager/7\.[0-9]") -eq 0 ]; then + echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" + echo -e "Requires PVE Version 7.0 or higher" + echo -e "Exiting..." + sleep 2 + exit + fi +} + +arch_check() { + if [ "$(dpkg --print-architecture)" != "amd64" ]; then + echo -e "\n ${CROSS} This script will not work with PiMox! \n" + echo -e "Exiting..." + sleep 2 + exit + fi +} + +echo_default() { + echo -e "${DGN}Using ${var_os} Version: ${BGN}${var_version}${CL}" + echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" + echo -e "${DGN}Using Container ID: ${BGN}$NEXTID${CL}" + echo -e "${DGN}Using Hostname: ${BGN}$NSAPP${CL}" + echo -e "${DGN}Using Disk Size: ${BGN}$var_disk${CL}${DGN}GB${CL}" + echo -e "${DGN}Allocated Cores ${BGN}$var_cpu${CL}" + echo -e "${DGN}Allocated Ram ${BGN}$var_ram${CL}" + echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" + echo -e "${DGN}Using Static IP Address: ${BGN}dhcp${CL}" + echo -e "${DGN}Using Gateway Address: ${BGN}Default${CL}" + echo -e "${DGN}Disable IPv6: ${BGN}No${CL}" + echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" + echo -e "${DGN}Using DNS Search Domain: ${BGN}Host${CL}" + echo -e "${DGN}Using DNS Server Address: ${BGN}Host${CL}" + echo -e "${DGN}Using MAC Address: ${BGN}Default${CL}" + echo -e "${DGN}Using VLAN Tag: ${BGN}Default${CL}" + echo -e "${DGN}Enable Root SSH Access: ${BGN}No${CL}" + echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}" + echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}" +} + +exit-script() { + clear + echo -e "⚠ User exited script \n" + exit +} + +advanced_settings() { + if var_version=$(whiptail --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 4 \ + "18.04" "Bionic" OFF \ + "20.04" "Focal" ON \ + "22.04" "Jammy" OFF \ + "22.10" "Kinetic" OFF \ + 3>&1 1>&2 2>&3); then + echo -e "${DGN}Using Ubuntu Version: ${BGN}$var_version${CL}" + else + exit-script + fi + + if CT_TYPE=$(whiptail --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ + "1" "Unprivileged" ON \ + "0" "Privileged" OFF \ + 3>&1 1>&2 2>&3); then + echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" + else + exit-script + fi + + if PW1=$(whiptail --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then + if [ -z $PW1 ]; then + PW1="Automatic Login" + PW=" " + else + PW="-password $PW1" + fi + echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" + else + exit-script + fi + + if CT_ID=$(whiptail --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then + if [ -z "$CT_ID" ]; then + CT_ID="$NEXTID" + echo -e "${DGN}Using Container ID: ${BGN}$CT_ID${CL}" + else + echo -e "${DGN}Container ID: ${BGN}$CT_ID${CL}" + fi + else + exit + fi + + if CT_NAME=$(whiptail --inputbox "Set Hostname" 8 58 $NSAPP --title "HOSTNAME" 3>&1 1>&2 2>&3); then + if [ -z "$CT_NAME" ]; then + HN="$NSAPP" + else + HN=$(echo ${CT_NAME,,} | tr -d ' ') + fi + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + else + exit-script + fi + + if DISK_SIZE=$(whiptail --inputbox "Set Disk Size in GB" 8 58 $var_disk --title "DISK SIZE" 3>&1 1>&2 2>&3); then + if [ -z "$DISK_SIZE" ]; then + DISK_SIZE="$var_disk" + echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" + else + if ! [[ $DISK_SIZE =~ $INTEGER ]]; then + echo -e "${RD}⚠ DISK SIZE MUST BE AN INTEGER NUMBER!${CL}" + advanced_settings + fi + echo -e "${DGN}Using Disk Size: ${BGN}$DISK_SIZE${CL}" + fi + else + exit-script + fi + + if CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 $var_cpu --title "CORE COUNT" 3>&1 1>&2 2>&3); then + if [ -z "$CORE_COUNT" ]; then + CORE_COUNT="$var_cpu" + echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" + else + echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" + fi + else + exit-script + fi + + if RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 $var_ram --title "RAM" 3>&1 1>&2 2>&3); then + if [ -z "$RAM_SIZE" ]; then + RAM_SIZE="$var_ram" + echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" + else + echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" + fi + else + exit-script + fi + + if BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3); then + if [ -z "$BRG" ]; then + BRG="vmbr0" + echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" + else + echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" + fi + else + exit-script + fi + + if NET=$(whiptail --inputbox "Set a Static IPv4 CIDR Address(/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3); then + if [ -z $NET ]; then + NET="dhcp" + echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" + else + echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" + fi + else + exit-script + fi + + if GATE1=$(whiptail --inputbox "Set a Gateway IP (mandatory if Static IP was used)" 8 58 --title "GATEWAY IP" 3>&1 1>&2 2>&3); then + if [ -z $GATE1 ]; then + GATE1="Default" + GATE="" + else + GATE=",gw=$GATE1" + fi + echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" + else + exit-script + fi + + if (whiptail --defaultno --title "IPv6" --yesno "Disable IPv6?" 10 58); then + DISABLEIP6="yes" + else + DISABLEIP6="no" + fi + echo -e "${DGN}Disable IPv6: ${BGN}$DISABLEIP6${CL}" + + if MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" 3>&1 1>&2 2>&3); then + if [ -z $MTU1 ]; then + MTU1="Default" + MTU="" + else + MTU=",mtu=$MTU1" + fi + echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" + else + exit-script + fi + + if SD=$(whiptail --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then + if [ -z $SD ]; then + SX=Host + SD="" + else + SX=$SD + SD="-searchdomain=$SD" + fi + echo -e "${DGN}Using DNS Search Domain: ${BGN}$SX${CL}" + else + exit-script + fi + + if NX=$(whiptail --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then + if [ -z $NX ]; then + NX=Host + NS="" + else + NS="-nameserver=$NX" + fi + echo -e "${DGN}Using DNS Server IP Address: ${BGN}$NX${CL}" + else + exit-script + fi + + if MAC1=$(whiptail --inputbox "Set a MAC Address(leave blank for default)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then + if [ -z $MAC1 ]; then + MAC1="Default" + MAC="" + else + MAC=",hwaddr=$MAC1" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" + fi + else + exit-script + fi + + if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then + if [ -z $VLAN1 ]; then + VLAN1="Default" + VLAN="" + else + VLAN=",tag=$VLAN1" + fi + echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" + else + exit-script + fi + + if (whiptail --defaultno --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58); then + SSH="yes" + else + SSH="no" + fi + echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" + + if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then + VERB="yes" + else + VERB="no" + fi + echo -e "${DGN}Enable Verbose Mode: ${BGN}$VERB${CL}" + + if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" 10 58); then + echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}" + else + clear + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi +} + +install_script() { + arch_check + pve_check + NEXTID=$(pvesh get /cluster/nextid) + header_info + if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then + header_info + echo -e "${BL}Using Default Settings${CL}" + default_settings + else + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi +} + +start() { + if command -v pveversion >/dev/null 2>&1; then + if ! (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then + clear + echo -e "⚠ User exited script \n" + exit + fi + install_script + fi + + if ! command -v pveversion >/dev/null 2>&1; then + if ! (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then + clear + echo -e "⚠ User exited script \n" + exit + fi + update_script + fi +} + +build_container() { + if [ "$VERB" == "yes" ]; then set -x; fi + if [ "$CT_TYPE" == "1" ]; then + FEATURES="nesting=1,keyctl=1" + else + FEATURES="nesting=1" + fi + TEMP_DIR=$(mktemp -d) + pushd $TEMP_DIR >/dev/null + export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/install.func)" + export tz="$timezone" + export DISABLEIPV6="$DISABLEIP6" + export APPLICATION="$APP" + export VERBOSE="$VERB" + export SSH_ROOT="${SSH}" + export CTID="$CT_ID" + export PCT_OSTYPE="$var_os" + export PCT_OSVERSION="$var_version" + export PCT_DISK_SIZE="$DISK_SIZE" + export PCT_OPTIONS=" + -features $FEATURES + -hostname $HN + $SD + $NS + -net0 name=eth0,bridge=$BRG$MAC,ip=$NET$GATE$VLAN$MTU + -onboot 1 + -cores $CORE_COUNT + -memory $RAM_SIZE + -unprivileged $CT_TYPE + $PW + " + bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit + + LXC_CONFIG=/etc/pve/lxc/${CTID}.conf + if [ "$CT_TYPE" == "0" ]; then + if [[ "$APP" != "Emby" && "$APP" != "Jellyfin" && "$APP" != "Plex" ]]; then + cat <>$LXC_CONFIG +lxc.cgroup2.devices.allow: a +lxc.cap.drop: +lxc.cgroup2.devices.allow: c 188:* rwm +lxc.cgroup2.devices.allow: c 189:* rwm +lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir +lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file +lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file +lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file +lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file +EOF + fi + fi + + if [ "$CT_TYPE" == "0" ]; then + if [[ "$APP" == "Emby" || "$APP" == "Jellyfin" || "$APP" == "Plex" ]]; then + cat <>$LXC_CONFIG +lxc.cgroup2.devices.allow: a +lxc.cap.drop: +lxc.cgroup2.devices.allow: c 226:0 rwm +lxc.cgroup2.devices.allow: c 226:128 rwm +lxc.cgroup2.devices.allow: c 29:0 rwm +lxc.mount.entry: /dev/fb0 dev/fb0 none bind,optional,create=file +lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir +lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file +EOF + fi + fi + + msg_info "Starting LXC Container" + pct start "$CTID" + msg_ok "Started LXC Container" + lxc-attach -n "$CTID" -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit + +} + +description() { + IP=$(pct exec "$CTID" ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) + pct set "$CTID" -description "# ${APP} LXC + ### https://tteck.github.io/Proxmox/ + " +} diff --git a/vm/haos-vm-v5.sh b/vm/haos-vm-v5.sh index e89c1951..5160d8be 100644 --- a/vm/haos-vm-v5.sh +++ b/vm/haos-vm-v5.sh @@ -6,10 +6,10 @@ # https://github.com/tteck/Proxmox/raw/main/LICENSE function header_info { -clear -cat <<"EOF" + clear + cat <<"EOF" __ __ ___ _ __ __ ____ _____ - / / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____v5/ /_ / __ \/ ___/ + / / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____ / /_ / __ \/ ___/ / /_/ / __ \/ __ `__ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ `/ __ \/ __/ / / / /\__ \ / __ / /_/ / / / / / / __/ / ___ |(__ |__ ) (__ ) /_/ /_/ / / / / /_ / /_/ /___/ / /_/ /_/\____/_/ /_/ /_/\___/ /_/ |_/____/____/_/____/\__/\__,_/_/ /_/\__/ \____//____/ @@ -20,18 +20,18 @@ header_info echo -e "\n Loading..." GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//') NEXTID=$(pvesh get /cluster/nextid) -VERSIONS=( stable beta dev ) +VERSIONS=(stable beta dev) for version in "${VERSIONS[@]}"; do eval "$version=$(curl -s https://raw.githubusercontent.com/home-assistant/version/master/$version.json | grep "ova" | cut -d '"' -f 4)" done -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -HA=`echo "\033[1;34m"` -RD=`echo "\033[01;31m"` -BGN=`echo "\033[4;92m"` -GN=`echo "\033[1;92m"` -DGN=`echo "\033[32m"` -CL=`echo "\033[m"` +YW=$(echo "\033[33m") +BL=$(echo "\033[36m") +HA=$(echo "\033[1;34m") +RD=$(echo "\033[01;31m") +BGN=$(echo "\033[4;92m") +GN=$(echo "\033[1;92m") +DGN=$(echo "\033[32m") +CL=$(echo "\033[m") BFR="\\r\\033[K" HOLD="-" CM="${GN}✓${CL}" @@ -67,25 +67,25 @@ else fi function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." } function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" } function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" + local msg="$1" + echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" } function PVE_CHECK() { -if [ $(pveversion | grep -c "pve-manager/7\.[2-9]") -eq 0 ]; then - echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" - echo -e "Requires PVE Version 7.2 or higher" - echo -e "Exiting..." - sleep 2 - exit -fi + if [ $(pveversion | grep -c "pve-manager/7\.[2-9]") -eq 0 ]; then + echo -e "${CROSS} This version of Proxmox Virtual Environment is not supported" + echo -e "Requires PVE Version 7.2 or higher" + echo -e "Exiting..." + sleep 2 + exit + fi } function ARCH_CHECK() { if [ "$(dpkg --print-architecture)" != "amd64" ]; then @@ -122,121 +122,138 @@ function default_settings() { echo -e "${BL}Creating a HAOS VM using the above default settings${CL}" } function advanced_settings() { -BRANCH=$(whiptail --title "HAOS VERSION" --radiolist "Choose Version" --cancel-button Exit-Script 10 58 3 \ -"$stable" "Stable " ON \ -"$beta" "Beta " OFF \ -"$dev" "Dev " OFF \ -3>&1 1>&2 2>&3) -exitstatus=$? -if [ $exitstatus = 0 ]; then echo -e "${DGN}Using HAOS Version: ${BGN}$BRANCH${CL}"; fi -while true; do - VMID=$(whiptail --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) + BRANCH=$(whiptail --title "HAOS VERSION" --radiolist "Choose Version" --cancel-button Exit-Script 10 58 3 \ + "$stable" "Stable " ON \ + "$beta" "Beta " OFF \ + "$dev" "Dev " OFF \ + 3>&1 1>&2 2>&3) exitstatus=$? - if [ -z "$VMID" ]; then - VMID="$NEXTID" - echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}" - break - else - if pct status "$VMID" &>/dev/null || qm status "$VMID" &>/dev/null; then - echo -e "${CROSS}${RD} ID $VMID is already in use${CL}" - sleep 2 - continue + if [ $exitstatus = 0 ]; then echo -e "${DGN}Using HAOS Version: ${BGN}$BRANCH${CL}"; fi + while true; do + VMID=$(whiptail --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) + exitstatus=$? + if [ -z "$VMID" ]; then + VMID="$NEXTID" + echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}" + break + else + if pct status "$VMID" &>/dev/null || qm status "$VMID" &>/dev/null; then + echo -e "${CROSS}${RD} ID $VMID is already in use${CL}" + sleep 2 + continue + fi + echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}" + break fi - echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}" - break - fi -done + done -MACH=$(whiptail --title "MACHINE TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 10 58 2 \ -"i440fx" "Machine i440fx" ON \ -"q35" "Machine q35" OFF \ -3>&1 1>&2 2>&3) -exitstatus=$? -if [ $MACH = q35 ]; then - echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}" - FORMAT="" - MACHINE=" -machine q35" + MACH=$(whiptail --title "MACHINE TYPE" --radiolist --cancel-button Exit-Script "Choose Type" 10 58 2 \ + "i440fx" "Machine i440fx" ON \ + "q35" "Machine q35" OFF \ + 3>&1 1>&2 2>&3) + exitstatus=$? + if [ $MACH = q35 ]; then + echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}" + FORMAT="" + MACHINE=" -machine q35" else - echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}" - FORMAT=",efitype=4m" - MACHINE="" -fi -VM_NAME=$(whiptail --inputbox "Set Hostname" 8 58 haos${BRANCH} --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) -exitstatus=$? -if [ -z $VM_NAME ]; then HN="haos${BRANCH}"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; -else - if [ $exitstatus = 0 ]; then HN=$(echo ${VM_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi; -fi -CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3) -exitstatus=$? -if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"; -else - if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"; fi; -fi -RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 4096 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3) -exitstatus=$? -if [ -z $RAM_SIZE ]; then RAM_SIZE="4096"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"; -else - if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"; fi; -fi -BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3) -exitstatus=$? -if [ -z $BRG ]; then BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; -else - if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi; -fi -MAC1=$(whiptail --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) -exitstatus=$? -if [ -z $MAC1 ]; then MAC="$GEN_MAC"; echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}"; -else - if [ $exitstatus = 0 ]; then MAC="$MAC1"; echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"; fi -fi -VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3) -exitstatus=$? -if [ $exitstatus = 0 ]; then - if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - VLAN=",tag=$VLAN1" - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" - fi -fi -MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3) -exitstatus=$? -if [ $exitstatus = 0 ]; then - if [ -z $MTU1 ]; then - MTU1="Default" MTU="" - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" - else - MTU=",mtu=$MTU1" - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" + echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}" + FORMAT=",efitype=4m" + MACHINE="" fi -fi -if (whiptail --title "START VIRTUAL MACHINE" --yesno "Start VM when completed?" 10 58); then + VM_NAME=$(whiptail --inputbox "Set Hostname" 8 58 haos${BRANCH} --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) + exitstatus=$? + if [ -z $VM_NAME ]; then + HN="haos${BRANCH}" + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + else + if [ $exitstatus = 0 ]; then + HN=$(echo ${VM_NAME,,} | tr -d ' ') + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + fi + fi + CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3) + exitstatus=$? + if [ -z $CORE_COUNT ]; then + CORE_COUNT="2" + echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" + else + if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"; fi + fi + RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 4096 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3) + exitstatus=$? + if [ -z $RAM_SIZE ]; then + RAM_SIZE="4096" + echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" + else + if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"; fi + fi + BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3) + exitstatus=$? + if [ -z $BRG ]; then + BRG="vmbr0" + echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" + else + if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi + fi + MAC1=$(whiptail --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) + exitstatus=$? + if [ -z $MAC1 ]; then + MAC="$GEN_MAC" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}" + else + if [ $exitstatus = 0 ]; then + MAC="$MAC1" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" + fi + fi + VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3) + exitstatus=$? + if [ $exitstatus = 0 ]; then + if [ -z $VLAN1 ]; then + VLAN1="Default" VLAN="" + echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" + else + VLAN=",tag=$VLAN1" + echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" + fi + fi + MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3) + exitstatus=$? + if [ $exitstatus = 0 ]; then + if [ -z $MTU1 ]; then + MTU1="Default" MTU="" + echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" + else + MTU=",mtu=$MTU1" + echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" + fi + fi + if (whiptail --title "START VIRTUAL MACHINE" --yesno "Start VM when completed?" 10 58); then echo -e "${DGN}Start VM when completed: ${BGN}yes${CL}" START_VM="yes" -else + else echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" START_VM="no" -fi -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create HAOS ${BRANCH} VM?" --no-button Do-Over 10 58); then + fi + if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create HAOS ${BRANCH} VM?" --no-button Do-Over 10 58); then echo -e "${RD}Creating a HAOS VM using the above advanced settings${CL}" -else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi + else + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi } function START_SCRIPT() { -if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings -else - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi + if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then + header_info + echo -e "${BL}Using Default Settings${CL}" + default_settings + else + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi } ARCH_CHECK PVE_CHECK @@ -251,29 +268,29 @@ while read -r line; do if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) fi -STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) + STORAGE_MENU+=("$TAG" "$ITEM" "OFF") done < <(pvesm status -content images | awk 'NR>1') VALID=$(pvesm status -content images | awk 'NR>1') if [ -z "$VALID" ]; then -msg_error "Unable to detect a valid storage location." + msg_error "Unable to detect a valid storage location." exit -elif [ $((${#STORAGE_MENU[@]}/3)) -eq 1 ]; then +elif [ $((${#STORAGE_MENU[@]} / 3)) -eq 1 ]; then STORAGE=${STORAGE_MENU[0]} else while [ -z "${STORAGE:+x}" ]; do STORAGE=$(whiptail --title "Storage Pools" --radiolist \ - "Which storage pool you would like to use for the HAOS VM?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit + "Which storage pool you would like to use for the HAOS VM?\n\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit done fi msg_ok "Using ${CL}${BL}$STORAGE${CL} ${GN}for Storage Location." msg_ok "Virtual Machine ID is ${CL}${BL}$VMID${CL}." msg_info "Retrieving the URL for Home Assistant ${BRANCH} Disk Image" -if [ "$BRANCH" == "$dev" ]; then -URL=https://os-builds.home-assistant.io/${BRANCH}/haos_ova-${BRANCH}.qcow2.xz +if [ "$BRANCH" == "$dev" ]; then + URL=https://os-builds.home-assistant.io/${BRANCH}/haos_ova-${BRANCH}.qcow2.xz else -URL=https://github.com/home-assistant/operating-system/releases/download/${BRANCH}/haos_ova-${BRANCH}.qcow2.xz + URL=https://github.com/home-assistant/operating-system/releases/download/${BRANCH}/haos_ova-${BRANCH}.qcow2.xz fi sleep 2 msg_ok "${CL}${BL}${URL}${CL}" @@ -285,19 +302,19 @@ msg_info "Extracting KVM Disk Image" unxz $FILE STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') case $STORAGE_TYPE in - nfs|dir) - DISK_EXT=".raw" - DISK_REF="$VMID/" - DISK_IMPORT="-format raw" - THIN="" - ;; - btrfs) - DISK_EXT=".raw" - DISK_REF="$VMID/" - DISK_IMPORT="-format raw" - FORMAT=",efitype=4m" - THIN="" - ;; +nfs | dir) + DISK_EXT=".raw" + DISK_REF="$VMID/" + DISK_IMPORT="-format raw" + THIN="" + ;; +btrfs) + DISK_EXT=".raw" + DISK_REF="$VMID/" + DISK_IMPORT="-format raw" + FORMAT=",efitype=4m" + THIN="" + ;; esac for i in {0,1}; do disk="DISK$i" @@ -319,8 +336,8 @@ qm set $VMID \ [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/D1D7EP4GF)" >/dev/null msg_ok "Created HAOS VM ${CL}${BL}(${HN})" if [ "$START_VM" == "yes" ]; then -msg_info "Starting Home Assistant OS VM" -qm start $VMID -msg_ok "Started Home Assistant OS VM" + msg_info "Starting Home Assistant OS VM" + qm start $VMID + msg_ok "Started Home Assistant OS VM" fi msg_ok "Completed Successfully!\n" diff --git a/vm/mikrotik-routeros-v5.sh b/vm/mikrotik-routeros.sh similarity index 51% rename from vm/mikrotik-routeros-v5.sh rename to vm/mikrotik-routeros.sh index 7e0bcdda..62930234 100644 --- a/vm/mikrotik-routeros-v5.sh +++ b/vm/mikrotik-routeros.sh @@ -6,9 +6,9 @@ # https://github.com/tteck/Proxmox/raw/main/LICENSE function header_info { -cat <<"EOF" + cat <<"EOF" __ ____ __ __ _ __ ____ __ ____ _____ - / |/ (_) /___________ / /_(_) /__ / __ \____v5__ __/ /____ _____/ __ \/ ___/ + / |/ (_) /___________ / /_(_) /__ / __ \____ __ __/ /____ _____/ __ \/ ___/ / /|_/ / / //_/ ___/ __ \/ __/ / //_/ / /_/ / __ \/ / / / __/ _ \/ ___/ / / /\__ \ / / / / / < / / / /_/ / /_/ / < / _ _/ /_/ / /_/ / /_/ __/ / / /_/ /___/ / /_/ /_/_/_/|_/_/ \____/\__/_/_/|_| /_/ |_|\____/\__,_/\__/\___/_/ \____//____/ @@ -20,14 +20,14 @@ header_info echo -e "Loading..." GEN_MAC=$(echo '00 60 2f'$(od -An -N3 -t xC /dev/urandom) | sed -e 's/ /:/g' | tr '[:lower:]' '[:upper:]') NEXTID=$(pvesh get /cluster/nextid) -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -HA=`echo "\033[1;34m"` -RD=`echo "\033[01;31m"` -BGN=`echo "\033[4;92m"` -GN=`echo "\033[1;92m"` -DGN=`echo "\033[32m"` -CL=`echo "\033[m"` +YW=$(echo "\033[33m") +BL=$(echo "\033[36m") +HA=$(echo "\033[1;34m") +RD=$(echo "\033[01;31m") +BGN=$(echo "\033[4;92m") +GN=$(echo "\033[1;92m") +DGN=$(echo "\033[32m") +CL=$(echo "\033[m") BFR="\\r\\033[K" HOLD="-" CM="${GN}✓${CL}" @@ -62,144 +62,145 @@ function cleanup() { } TEMP_DIR=$(mktemp -d) pushd $TEMP_DIR >/dev/null -if [ `pveversion | grep "pve-manager/7" | wc -l` -ne 1 ]; then - echo "⚠ This version of Proxmox Virtual Environment is not supported" - echo "Requires PVE Version: 7.XX" - echo "Exiting..." - sleep 3 - exit +if [ $(pveversion | grep "pve-manager/7" | wc -l) -ne 1 ]; then + echo "⚠ This version of Proxmox Virtual Environment is not supported" + echo "Requires PVE Version: 7.XX" + echo "Exiting..." + sleep 3 + exit fi if (whiptail --title "Mikrotik RouterOS VM" --yesno "This will create a New Mikrotik RouterOS VM. Proceed?" 10 58); then - echo "User selected Yes" + echo "User selected Yes" else - clear - echo -e "⚠ User exited script \n" - exit + clear + echo -e "⚠ User exited script \n" + exit fi function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." } function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" } function default_settings() { - echo -e "${DGN}Using Virtual Machine ID: ${BGN}$NEXTID${CL}" - VMID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}mikrotik-routeros${CL}" - HN=mikrotik-routeros - echo -e "${DGN}Allocated Cores: ${BGN}1${CL}" - CORE_COUNT="1" - echo -e "${DGN}Allocated RAM: ${BGN}1024${CL}" - RAM_SIZE="1024" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using MAC Address: ${BGN}$GEN_MAC${CL}" - MAC=$GEN_MAC - echo -e "${DGN}Using VLAN: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" - START_VM="no" - echo -e "${BL}Creating a Mikrotik RouterOS VM using the above default settings${CL}" + echo -e "${DGN}Using Virtual Machine ID: ${BGN}$NEXTID${CL}" + VMID=$NEXTID + echo -e "${DGN}Using Hostname: ${BGN}mikrotik-routeros${CL}" + HN=mikrotik-routeros + echo -e "${DGN}Allocated Cores: ${BGN}1${CL}" + CORE_COUNT="1" + echo -e "${DGN}Allocated RAM: ${BGN}1024${CL}" + RAM_SIZE="1024" + echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" + BRG="vmbr0" + echo -e "${DGN}Using MAC Address: ${BGN}$GEN_MAC${CL}" + MAC=$GEN_MAC + echo -e "${DGN}Using VLAN: ${BGN}Default${CL}" + VLAN="" + echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" + MTU="" + echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" + START_VM="no" + echo -e "${BL}Creating a Mikrotik RouterOS VM using the above default settings${CL}" } function advanced_settings() { -VMID=$(whiptail --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" 3>&1 1>&2 2>&3) -exitstatus=$? -if [ $exitstatus = 0 ]; then + VMID=$(whiptail --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" 3>&1 1>&2 2>&3) + exitstatus=$? + if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Virtual Machine ID: ${BGN}$VMID${CL}" -else + else exit -fi -VM_NAME=$(whiptail --inputbox "Set Hostname" 8 58 Mikrotik-RouterOS --title "HOSTNAME" 3>&1 1>&2 2>&3) -exitstatus=$? -if [ $exitstatus = 0 ]; then + fi + VM_NAME=$(whiptail --inputbox "Set Hostname" 8 58 Mikrotik-RouterOS --title "HOSTNAME" 3>&1 1>&2 2>&3) + exitstatus=$? + if [ $exitstatus = 0 ]; then HN=$(echo ${VM_NAME,,} | tr -d ' ') echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" -else + else exit -fi -CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 1 --title "CORE COUNT" 3>&1 1>&2 2>&3) -exitstatus=$? -if [ $exitstatus = 0 ]; then + fi + CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 1 --title "CORE COUNT" 3>&1 1>&2 2>&3) + exitstatus=$? + if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" -else + else exit -fi -RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 1024 --title "RAM" 3>&1 1>&2 2>&3) -exitstatus=$? -if [ $exitstatus = 0 ]; then + fi + RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 1024 --title "RAM" 3>&1 1>&2 2>&3) + exitstatus=$? + if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" -else + else exit -fi -BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3) -exitstatus=$? -if [ $exitstatus = 0 ]; then + fi + BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" 3>&1 1>&2 2>&3) + exitstatus=$? + if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" -else + else exit -fi -MAC1=$(whiptail --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" 3>&1 1>&2 2>&3) -exitstatus=$? -if [ $exitstatus = 0 ]; then + fi + MAC1=$(whiptail --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" 3>&1 1>&2 2>&3) + exitstatus=$? + if [ $exitstatus = 0 ]; then MAC="$MAC1" echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" -else - exit -fi -VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3) -exitstatus=$? -if [ $exitstatus = 0 ]; then - if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - VLAN=",tag=$VLAN1" - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" - fi -fi -MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3) -exitstatus=$? -if [ $exitstatus = 0 ]; then - if [ -z $MTU1 ]; then - MTU1="Default" MTU="" - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" else - MTU=",mtu=$MTU1" - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" + exit fi -fi -if (whiptail --title "START VIRTUAL MACHINE" --yesno "Start Mikrotik RouterOS VM when completed?" 10 58); then + VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3) + exitstatus=$? + if [ $exitstatus = 0 ]; then + if [ -z $VLAN1 ]; then + VLAN1="Default" VLAN="" + echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" + else + VLAN=",tag=$VLAN1" + echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" + fi + fi + MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3) + exitstatus=$? + if [ $exitstatus = 0 ]; then + if [ -z $MTU1 ]; then + MTU1="Default" MTU="" + echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" + else + MTU=",mtu=$MTU1" + echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" + fi + fi + if (whiptail --title "START VIRTUAL MACHINE" --yesno "Start Mikrotik RouterOS VM when completed?" 10 58); then echo -e "${DGN}Start Mikrotik RouterOS VM when completed: ${BGN}yes${CL}" START_VM="yes" -else + else echo -e "${DGN}Start Mikrotik RouterOS VM when completed: ${BGN}no${CL}" START_VM="no" -fi -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create Mikrotik RouterOS VM?" 10 58); then + fi + if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create Mikrotik RouterOS VM?" 10 58); then echo -e "${RD}Creating Mikrotik RouterOS VM using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi + else + clear + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi } function start_script() { -if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" 10 58); then - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi + if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" 10 58); then + clear + header_info + echo -e "${BL}Using Default Settings${CL}" + default_settings + else + clear + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi } start_script msg_info "Validating Storage" @@ -212,21 +213,21 @@ while read -r line; do if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) fi -STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) + STORAGE_MENU+=("$TAG" "$ITEM" "OFF") done < <(pvesm status -content images | awk 'NR>1') VALID=$(pvesm status -content images | awk 'NR>1') if [ -z "$VALID" ]; then - echo -e "\n${RD}⚠ Unable to detect a valid storage location.${CL}" - echo -e "Exiting..." - exit -elif [ $((${#STORAGE_MENU[@]}/3)) -eq 1 ]; then + echo -e "\n${RD}⚠ Unable to detect a valid storage location.${CL}" + echo -e "Exiting..." + exit +elif [ $((${#STORAGE_MENU[@]} / 3)) -eq 1 ]; then STORAGE=${STORAGE_MENU[0]} else while [ -z "${STORAGE:+x}" ]; do STORAGE=$(whiptail --title "Storage Pools" --radiolist \ - "Which storage pool you would like to use for the Mikrotik RouterOS VM?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit + "Which storage pool you would like to use for the Mikrotik RouterOS VM?\n\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit done fi msg_ok "Using ${CL}${BL}$STORAGE${CL} ${GN}for Storage Location." @@ -245,17 +246,17 @@ msg_info "Extracting Mikrotik RouterOS Disk Image" gunzip -f -S .zip $FILE STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') case $STORAGE_TYPE in - nfs|dir) - DISK_EXT=".qcow2" - DISK_REF="$VMID/" - DISK_IMPORT="-format qcow2" - ;; - btrfs) - DISK_EXT=".raw" - DISK_REF="$VMID/" - DISK_FORMAT="subvol" - DISK_IMPORT="-format raw" - ;; +nfs | dir) + DISK_EXT=".qcow2" + DISK_REF="$VMID/" + DISK_IMPORT="-format qcow2" + ;; +btrfs) + DISK_EXT=".raw" + DISK_REF="$VMID/" + DISK_FORMAT="subvol" + DISK_IMPORT="-format raw" + ;; esac for i in {0,1}; do disk="DISK$i" @@ -277,8 +278,8 @@ qm set $VMID \ [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/D1D7EP4GF)" >/dev/null msg_ok "Mikrotik RouterOS VM ${CL}${BL}(${HN})" if [ "$START_VM" == "yes" ]; then -msg_info "Starting Mikrotik RouterOS VM" -qm start $VMID -msg_ok "Started Mikrotik RouterOS VM" + msg_info "Starting Mikrotik RouterOS VM" + qm start $VMID + msg_ok "Started Mikrotik RouterOS VM" fi msg_ok "Completed Successfully!\n" diff --git a/vm/pimox-haos-vm-v5.sh b/vm/pimox-haos-vm.sh similarity index 50% rename from vm/pimox-haos-vm-v5.sh rename to vm/pimox-haos-vm.sh index c116c84a..ca69e858 100644 --- a/vm/pimox-haos-vm-v5.sh +++ b/vm/pimox-haos-vm.sh @@ -6,13 +6,13 @@ # https://github.com/tteck/Proxmox/raw/main/LICENSE function header_info { -cat <<"EOF" + cat <<"EOF" ____ _ __ ___ / __ \(_) |/ /___ _ __ / /_/ / / /|_/ / __ \| |/_/ / ____/ / / / / /_/ /> < __ __ /_/_ /_/_/ /_/\____/_/|_| __ ____ _____ - / / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____v5/ /_ / __ \/ ___/ + / / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____ / /_ / __ \/ ___/ / /_/ / __ \/ __ `__ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ `/ __ \/ __/ / / / /\__ \ / __ / /_/ / / / / / / __/ / ___ |(__ |__ ) (__ ) /_/ /_/ / / / / /_ / /_/ /___/ / /_/ /_/\____/_/ /_/ /_/\___/ /_/ |_/____/____/_/____/\__/\__,_/_/ /_/\__/ \____//____/ @@ -28,14 +28,14 @@ NEXTID=$(pvesh get /cluster/nextid) STABLE=$(curl -s https://raw.githubusercontent.com/home-assistant/version/master/stable.json | grep "ova" | awk '{print substr($2, 2, length($2)-3) }') BETA=$(curl -s https://raw.githubusercontent.com/home-assistant/version/master/beta.json | grep "ova" | awk '{print substr($2, 2, length($2)-3) }') DEV=$(curl -s https://raw.githubusercontent.com/home-assistant/version/master/dev.json | grep "ova" | awk '{print substr($2, 2, length($2)-3) }') -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -HA=`echo "\033[1;34m"` -RD=`echo "\033[01;31m"` -BGN=`echo "\033[4;92m"` -GN=`echo "\033[1;92m"` -DGN=`echo "\033[32m"` -CL=`echo "\033[m"` +YW=$(echo "\033[33m") +BL=$(echo "\033[36m") +HA=$(echo "\033[1;34m") +RD=$(echo "\033[01;31m") +BGN=$(echo "\033[4;92m") +GN=$(echo "\033[1;92m") +DGN=$(echo "\033[32m") +CL=$(echo "\033[m") BFR="\\r\\033[K" HOLD="-" CM="${GN}✓${CL}" @@ -72,20 +72,20 @@ function cleanup() { TEMP_DIR=$(mktemp -d) pushd $TEMP_DIR >/dev/null if (whiptail --title "PiMox HAOS VM" --yesno "This will create a New PiMox HAOS VM. Proceed?" 10 58); then - echo "User selected Yes" + echo "User selected Yes" else - clear - echo -e "⚠ User exited script \n" - exit + clear + echo -e "⚠ User exited script \n" + exit fi function PVE_CHECK() { -if [ `pveversion | grep "pve-manager/7.2\|7.3" | wc -l` -ne 1 ]; then - echo "⚠ This version of Proxmox Virtual Environment is not supported" - echo "Requires PVE Version: =>7.2" - echo "Exiting..." - sleep 2 - exit -fi + if [ $(pveversion | grep "pve-manager/7.2\|7.3" | wc -l) -ne 1 ]; then + echo "⚠ This version of Proxmox Virtual Environment is not supported" + echo "Requires PVE Version: =>7.2" + echo "Exiting..." + sleep 2 + exit + fi } function ARCH_CHECK() { ARCH=$(dpkg --print-architecture) @@ -97,142 +97,160 @@ function ARCH_CHECK() { fi } function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." } function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" } function msg_error() { - local msg="$1" - echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" + local msg="$1" + echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" } function default_settings() { - echo -e "${DGN}Using HAOS Version: ${BGN}${STABLE}${CL}" - BRANCH=${STABLE} - echo -e "${DGN}Using Virtual Machine ID: ${BGN}$NEXTID${CL}" - VMID=$NEXTID - echo -e "${DGN}Using Hostname: ${BGN}haos${STABLE}${CL}" - HN=haos${STABLE} - echo -e "${DGN}Allocated Cores: ${BGN}2${CL}" - CORE_COUNT="2" - echo -e "${DGN}Allocated RAM: ${BGN}4096${CL}" - RAM_SIZE="4096" - echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" - BRG="vmbr0" - echo -e "${DGN}Using MAC Address: ${BGN}$GEN_MAC${CL}" - MAC=$GEN_MAC - echo -e "${DGN}Using VLAN: ${BGN}Default${CL}" - VLAN="" - echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" - MTU="" - echo -e "${DGN}Start VM when completed: ${BGN}yes${CL}" - START_VM="yes" - echo -e "${BL}Creating a HAOS VM using the above default settings${CL}" + echo -e "${DGN}Using HAOS Version: ${BGN}${STABLE}${CL}" + BRANCH=${STABLE} + echo -e "${DGN}Using Virtual Machine ID: ${BGN}$NEXTID${CL}" + VMID=$NEXTID + echo -e "${DGN}Using Hostname: ${BGN}haos${STABLE}${CL}" + HN=haos${STABLE} + echo -e "${DGN}Allocated Cores: ${BGN}2${CL}" + CORE_COUNT="2" + echo -e "${DGN}Allocated RAM: ${BGN}4096${CL}" + RAM_SIZE="4096" + echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}" + BRG="vmbr0" + echo -e "${DGN}Using MAC Address: ${BGN}$GEN_MAC${CL}" + MAC=$GEN_MAC + echo -e "${DGN}Using VLAN: ${BGN}Default${CL}" + VLAN="" + echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" + MTU="" + echo -e "${DGN}Start VM when completed: ${BGN}yes${CL}" + START_VM="yes" + echo -e "${BL}Creating a HAOS VM using the above default settings${CL}" } function advanced_settings() { -BRANCH=$(whiptail --title "HAOS VERSION" --radiolist "Choose Version" --cancel-button Exit-Script 10 58 3 \ -"$STABLE" "Stable" ON \ -"$BETA" "Beta" OFF \ -"$DEV" "Dev" OFF \ -3>&1 1>&2 2>&3) -exitstatus=$? -if [ $exitstatus = 0 ]; then echo -e "${DGN}Using HAOS Version: ${BGN}$BRANCH${CL}"; fi -VMID=$(whiptail --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) -exitstatus=$? -if [ -z $VMID ]; then VMID="$NEXTID"; echo -e "${DGN}Virtual Machine: ${BGN}$VMID${CL}"; + BRANCH=$(whiptail --title "HAOS VERSION" --radiolist "Choose Version" --cancel-button Exit-Script 10 58 3 \ + "$STABLE" "Stable" ON \ + "$BETA" "Beta" OFF \ + "$DEV" "Dev" OFF \ + 3>&1 1>&2 2>&3) + exitstatus=$? + if [ $exitstatus = 0 ]; then echo -e "${DGN}Using HAOS Version: ${BGN}$BRANCH${CL}"; fi + VMID=$(whiptail --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3) + exitstatus=$? + if [ -z $VMID ]; then + VMID="$NEXTID" + echo -e "${DGN}Virtual Machine: ${BGN}$VMID${CL}" else - if echo "$USEDID" | egrep -q "$VMID" - then + if echo "$USEDID" | egrep -q "$VMID"; then echo -e "\n🚨 ${RD}ID $VMID is already in use${CL} \n" echo -e "Exiting Script \n" - sleep 2; + sleep 2 exit - else - if [ $exitstatus = 0 ]; then echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}"; fi; + else + if [ $exitstatus = 0 ]; then echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}"; fi fi -fi -VM_NAME=$(whiptail --inputbox "Set Hostname" 8 58 haos${BRANCH} --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) -exitstatus=$? -if [ -z $VM_NAME ]; then HN="haos${BRANCH}"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; -else - if [ $exitstatus = 0 ]; then HN=$(echo ${VM_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi; -fi -CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3) -exitstatus=$? -if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"; -else - if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"; fi; -fi -RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 4096 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3) -exitstatus=$? -if [ -z $RAM_SIZE ]; then RAM_SIZE="4096"; echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"; -else - if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"; fi; -fi -BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3) -exitstatus=$? -if [ -z $BRG ]; then BRG="vmbr0"; echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; -else - if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi; -fi -MAC1=$(whiptail --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) -exitstatus=$? -if [ -z $MAC1 ]; then MAC="$GEN_MAC"; echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}"; -else - if [ $exitstatus = 0 ]; then MAC="$MAC1"; echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}"; fi -fi -VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3) -exitstatus=$? -if [ $exitstatus = 0 ]; then - if [ -z $VLAN1 ]; then VLAN1="Default" VLAN=""; - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" -else - VLAN=",tag=$VLAN1" - echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" - fi -fi -MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3) -exitstatus=$? -if [ $exitstatus = 0 ]; then - if [ -z $MTU1 ]; then - MTU1="Default" MTU="" - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" - else - MTU=",mtu=$MTU1" - echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" fi -fi -if (whiptail --title "START VIRTUAL MACHINE" --yesno "Start VM when completed?" 10 58); then + VM_NAME=$(whiptail --inputbox "Set Hostname" 8 58 haos${BRANCH} --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) + exitstatus=$? + if [ -z $VM_NAME ]; then + HN="haos${BRANCH}" + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + else + if [ $exitstatus = 0 ]; then + HN=$(echo ${VM_NAME,,} | tr -d ' ') + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + fi + fi + CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3) + exitstatus=$? + if [ -z $CORE_COUNT ]; then + CORE_COUNT="2" + echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" + else + if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"; fi + fi + RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 4096 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3) + exitstatus=$? + if [ -z $RAM_SIZE ]; then + RAM_SIZE="4096" + echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" + else + if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"; fi + fi + BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3) + exitstatus=$? + if [ -z $BRG ]; then + BRG="vmbr0" + echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}" + else + if [ $exitstatus = 0 ]; then echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"; fi + fi + MAC1=$(whiptail --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3) + exitstatus=$? + if [ -z $MAC1 ]; then + MAC="$GEN_MAC" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}" + else + if [ $exitstatus = 0 ]; then + MAC="$MAC1" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" + fi + fi + VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3) + exitstatus=$? + if [ $exitstatus = 0 ]; then + if [ -z $VLAN1 ]; then + VLAN1="Default" VLAN="" + echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" + else + VLAN=",tag=$VLAN1" + echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}" + fi + fi + MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3) + exitstatus=$? + if [ $exitstatus = 0 ]; then + if [ -z $MTU1 ]; then + MTU1="Default" MTU="" + echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" + else + MTU=",mtu=$MTU1" + echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}" + fi + fi + if (whiptail --title "START VIRTUAL MACHINE" --yesno "Start VM when completed?" 10 58); then echo -e "${DGN}Start VM when completed: ${BGN}yes${CL}" START_VM="yes" -else + else echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" START_VM="no" -fi -if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create HAOS ${BRANCH} VM?" --no-button Do-Over 10 58); then + fi + if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create HAOS ${BRANCH} VM?" --no-button Do-Over 10 58); then echo -e "${RD}Creating a HAOS VM using the above advanced settings${CL}" -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi + else + clear + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi } function START_SCRIPT() { -if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - default_settings -else - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - advanced_settings -fi + if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then + clear + header_info + echo -e "${BL}Using Default Settings${CL}" + default_settings + else + clear + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi } ARCH_CHECK PVE_CHECK @@ -246,19 +264,19 @@ while read -r line; do if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) + STORAGE_MENU+=("$TAG" "$ITEM" "OFF") done < <(pvesm status -content images | awk 'NR>1') -if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then +if [ $((${#STORAGE_MENU[@]} / 3)) -eq 0 ]; then echo -e "'Disk image' needs to be selected for at least one storage location." die "Unable to detect valid storage location." -elif [ $((${#STORAGE_MENU[@]}/3)) -eq 1 ]; then +elif [ $((${#STORAGE_MENU[@]} / 3)) -eq 1 ]; then STORAGE=${STORAGE_MENU[0]} else while [ -z "${STORAGE:+x}" ]; do STORAGE=$(whiptail --title "Storage Pools" --radiolist \ - "Which storage pool you would like to use for the HAOS VM?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit + "Which storage pool you would like to use for the HAOS VM?\n\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit done fi msg_ok "Using ${CL}${BL}$STORAGE${CL} ${GN}for Storage Location." @@ -275,10 +293,11 @@ msg_info "Extracting Disk Image" unxz $FILE STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') case $STORAGE_TYPE in - nfs|dir) - DISK_EXT=".qcow2" - DISK_REF="$VMID/" - DISK_IMPORT="-format qcow2" +nfs | dir) + DISK_EXT=".qcow2" + DISK_REF="$VMID/" + DISK_IMPORT="-format qcow2" + ;; esac for i in {0,1}; do disk="DISK$i" @@ -301,8 +320,8 @@ qm set $VMID -description "# PiMox HAOS [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/D1D7EP4GF)" >/dev/null msg_ok "Created HAOS VM ${CL}${BL}(${HN})" if [ "$START_VM" == "yes" ]; then -msg_info "Starting Home Assistant OS VM" -qm start $VMID -msg_ok "Started Home Assistant OS VM" + msg_info "Starting Home Assistant OS VM" + qm start $VMID + msg_ok "Started Home Assistant OS VM" fi msg_ok "Completed Successfully!\n"