diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..4cf8cff5 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,132 @@ + +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available +at [https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 00000000..2b2bf02d --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,14 @@ +<div align="center"> + <a href="#"> + <img src="https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/logo.png" height="100px" /> + </a> +</div> +<h2 align="center">Contributing to Proxmox VE Helper Scripts</h2> + +Everybody is invited and welcome to contribute to Proxmox VE Helper Scripts. + +- Pull requests submitted against [**main**](https://github.com/tteck/Proxmox/tree/main) are meticulously scrutinized, so please do not take it personally if the project maintainer rejects your request. By adhering to the established patterns and conventions throughout the codebase, you greatly increase the likelihood that your changes will get merged into [**main**](https://github.com/tteck/Proxmox/tree/main). + +- It is important to stress that complaining about a decision after it has been made is not productive behavior for the pull request submitter. It is crucial for all contributors to respect the decision-making process and collaborate effectively towards achieving the best possible outcome for the project. + +- The repository will only accept Alpine applications that make use of the Alpine Package Keeper. diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..8ecf7b04 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +ko_fi: proxmoxhelperscripts diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml new file mode 100644 index 00000000..26e62e89 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -0,0 +1,65 @@ +name: Problems with a script. +description: Generate a report on an issue pertaining specifically to a script. For other inquires please share them in the Discussions section. +body: + - type: markdown + attributes: + value: | + **IMPORTANT:** Failure to comply with the following guidelines may result in immediate closure. + - Prior to submitting, kindly search the closed issues to check if the problem you are reporting has already been addressed and resolved. If you come across a closed issue that pertains to your problem, please leave a comment on that issue instead of creating a new one. + - If the default Linux distribution is not adhered to, script support will be discontinued. + - When encountering the error message `[ERROR] in line 23: exit code *: while executing command "$@" > /dev/null 2>&1`, make sure to run the script in verbose mode to accurately determine the underlying issue. + - For suggestions, questions or feature/script requests, please share them in the [Discussions section.](https://github.com/tteck/Proxmox/discussions) + - type: input + id: guidelines + attributes: + label: Please verify that you have read and understood the guidelines. + placeholder: 'yes' + validations: + required: true + - type: textarea + id: bug + attributes: + label: A clear and concise description of the issue. + validations: + required: true + - type: dropdown + id: settings + validations: + required: true + attributes: + label: What settings are you currently utilizing? + options: + - + - Default Settings + - Advanced Settings + - type: markdown + attributes: + value: (if Advanced Settings, please try Default Settings before creating an issue) + - type: dropdown + id: distribution + validations: + required: true + attributes: + label: Which Linux distribution are you employing? + options: + - + - Alpine + - Debian 11 + - Debian 12 + - Ubuntu 20.04 + - Ubuntu 22.04 + - Ubuntu 24.04 + - type: textarea + id: screenshot + attributes: + label: If relevant, including screenshots or a code block can be helpful in clarifying the issue. + placeholder: Code blocks begin and conclude by enclosing the code with three backticks (```) above and below it. + validations: + required: false + - type: textarea + id: reproduce + attributes: + label: Please provide detailed steps to reproduce the issue. + placeholder: First do this, then this ... + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..09abbdf7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Helper-Scripts Community Support + url: https://github.com/tteck/Proxmox/discussions + about: Please ask and answer questions here. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..39173ba0 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,18 @@ +## I wanted to make you aware that I am meticulous when it comes to merging code into the main branch, so please don't take it personally if I reject your request. + +## Description + +Please include a summary of the change and/or which issue is fixed. + +Fixes # (issue) + +## Type of change + +Please delete options that are not relevant. + +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [ ] New Script (Develop a new script or set of scripts that are fully functional and thoroughly tested) +- [ ] I have performed a self-review of my code, adhering to established codebase patterns and conventions. +- [ ] This change requires a documentation update diff --git a/CHANGELOG.MD b/CHANGELOG.MD deleted file mode 100644 index e6005cd1..00000000 --- a/CHANGELOG.MD +++ /dev/null @@ -1,642 +0,0 @@ -<a href="https://tteck.github.io/Proxmox/"><img src="https://github-readme-stats.vercel.app/api?username=tteck&theme=blue-green" height="130"/></a> - -# Change Log -All notable changes to this project will be documented in this file. - -## 2022-07-22 - -### Changed - -- **n8n LXC** (thanks to @cyakimov) - - NEW Script - -## 2022-07-21 - -### Changed - -- **grocy LXC** - - NEW Script - -## 2022-07-17 - -### Changed - -- **Vaultwarden LXC** - - NEW Vaultwarden Update (post 2022-05-29 installs only) Script - - NEW Web-vault Update (any) Script - -## 2022-07-14 - -### Changed - -- **MagicMirror Server LXC** - - NEW Script - -## 2022-07-13 - -### Changed - -- **Proxmox Edge Kernel Tool** - - NEW Script - -## 2022-07-11 - -### Changed - -- **Home Assistant OS VM** - - Supports lvmthin, zfspool, nfs, dir and btrfs storage types. - -## 2022-07-08 - -### Changed - -- **openHAB LXC** - - NEW Script - -## 2022-07-03 - -### Changed - -- **Tailscale** - - NEW Script - -## 2022-07-01 - -### Changed - -- **Home Assistant OS VM** - - Allow different storage types (lvmthin, nfs, dir). - -## 2022-06-30 - -### Changed - -- **Prometheus LXC** - - NEW Script - -## 2022-06-06 - -### Changed - -- **Whoogle LXC** - - NEW Script - -## 2022-05-29 - -### Changed - -- **Vaultwarden LXC** - - Code refactoring -- **CrowdSec** - - NEW Script - -## 2022-05-21 - -### Changed - -- **Home Assistant OS VM** - - Code refactoring - -## 2022-05-19 - -### Changed - -- **Keycloak LXC** - - NEW Script - -## 2022-05-18 - -### Changed - -- **File Browser** - - NEW Script - -## 2022-05-13 - -### Changed - -- **PostgreSQL LXC** - - NEW Script - -## 2022-05-10 - -### Changed - -- **deCONZ LXC** - - NEW Script - -## 2022-05-07 - -### Changed - -- **NocoDB LXC** - - ADD update script - -## 2022-05-06 - -### Changed - -- **PhotoPrism LXC** - - ADD GO Dependencies for full functionality - -## 2022-05-05 - -### Changed - -- **Ubuntu LXC** - - ADD option to define version (18.04 20.04 21.10 22.04) - -## 2022-04-28 - -### Changed - -- **v3 Script** - - Remove Internet Check - -## 2022-04-27 - -### Changed - -- **Home Assistant OS VM** - - ADD Option to set Bridge, VLAN and MAC Address -- **v3 Script** - - Improve Internet Check (prevent ‼ ERROR 4@57) - -## 2022-04-26 - -### Changed - -- **Home Assistant OS VM** - - Fixed bad path - - ADD Option to create VM using Latest or Stable image -- **UniFi Network Application LXC** - - ADD Local Controller Option - -## 2022-04-25 - -### Changed - -- **v3 Script** - - Improve Error Handling - -## 2022-04-23 - -### Changed - -- **v3 Script** - - ADD Internet Connection Check -- **Proxmox VE 7 Post Install** - - NEW v3 Script -- **Proxmox Kernel Clean** - - NEW v3 Script - -## 2022-04-22 - -### Changed - -- **Omada Controller LXC** - - Update script to install version 5.1.7 -- **Uptime Kuma LXC** - - ADD Update script - -## 2022-04-20 - -### Changed - -- **Ubuntu LXC** - - ADD option to install version 20.04 or 21.10 -- **v3 Script** - - ADD option to set Bridge - -## 2022-04-19 - -### Changed - -- **ALL LXC's** - - New [V3 Install Script](https://github.com/tteck/Proxmox/issues/162) -- **ioBroker LXC** - - New Script V3 - -## 2022-04-13 - -### Changed - -- **Uptime Kuma LXC** - - New Script V2 - -## 2022-04-11 - -### Changed - -- **Proxmox LXC Updater** - - ADD option to skip stopped containers -- **Proxmox VE 7 Post Install** - - ADD PVE 7 check - -## 2022-04-10 - -### Changed - -- **Debian 11 LXC** - - ADD An early look at the v3 install script - -## 2022-04-09 - -### Changed - -- **NocoDB LXC** - - New Script V2 - -## 2022-04-05 - -### Changed - -- **MeshCentral LXC** - - New Script V2 - -## 2022-04-01 - -### Changed - -- **Scripts** (V2) - - FIX Pressing enter without making a selection first would cause an Error - -## 2022-03-28 - -### Changed - -- **Docker LXC** - - Add Docker Compose Option (@wovalle) - -## 2022-03-27 - -### Changed - -- **Heimdall Dashboard LXC** - - New Update Script - -## 2022-03-26 - -### Changed - -- **UniFi Network Application LXC** - - New Script V2 -- **Omada Controller LXC** - - New Script V2 - -## 2022-03-25 - -### Changed - -- **Proxmox CPU Scaling Governor** - - New Script - - -## 2022-03-24 - -### Changed - -- **Plex Media Server LXC** - - Switch to Ubuntu 20.04 to support HDR tone mapping -- **Docker LXC** - - Add Portainer Option - -## 2022-03-23 - -### Changed - -- **Heimdall Dashboard LXC** - - New Script V2 - -## 2022-03-20 - -### Changed - -- **Scripts** (V2) - - ADD choose between Automatic or Manual DHCP - -## 2022-03-18 - -### Changed - -- **Technitium DNS LXC** - - New Script V2 -- **WireGuard LXC** - - Add WGDashboard - -## 2022-03-17 - -### Changed - -- **Docker LXC** - - New Script V2 - -## 2022-03-16 - -### Changed - -- **PhotoPrism LXC** - - New Update/Branch Script - -## 2022-03-15 - -### Changed - -- **Dashy LXC** - - New Update Script - -## 2022-03-14 - -### Changed - -- **Zwavejs2MQTT LXC** - - New Update Script - -## 2022-03-12 - -### Changed - -- **PhotoPrism LXC** - - New Script V2 - -## 2022-03-11 - -### Changed - -- **Vaultwarden LXC** - - New V2 Install Script - -## 2022-03-08 - -### Changed - -- **Scripts** (V2) - - Choose between Privileged or Unprivileged CT and Automatic or Password Login -- **ESPHome LXC** - - New V2 Install Script -- **Zwavejs2MQTT LXC** - - New V2 Install Script -- **Motioneye LXC** - - New V2 Install Script -- **Pihole LXC** - - New V2 Install Script -- **GamUntu LXC** - - New V2 Install Script - -## 2022-03-06 - -### Changed - -- **Zwavejs2MQTT LXC** - - New GUI script to copy data from one Zwavejs2MQTT LXC to another Zwavejs2MQTT LXC - -## 2022-03-05 - -### Changed - -- **Homebridge LXC** - - New Script V2 - -## 2022-03-04 - -### Changed - -- **Proxmox Kernel Clean** - - New Script - -## 2022-03-03 - -### Changed - -- **WireGuard LXC** - - New Script V2 - -## 2022-03-02 - -### Changed - -- **Proxmox LXC Updater** - - New Script -- **Dashy LXC** - - New Script V2 -- **Grafana LXC** - - New Script V2 -- **InfluxDB/Telegraf LXC** - - New Script V2 - -## 2022-03-01 - -### Changed - -- **Daemon Sync Server LXC** - - New Script V2 - -## 2022-02-28 - -### Changed - -- **Vaultwarden LXC** - - Add Update Script - -## 2022-02-24 - -### Changed - -- **Nginx Proxy Manager LXC** - - New V2 Install Script - -## 2022-02-23 - -### Changed - -- **Adguard Home LXC** - - New V2 Install Script -- **Zigbee2MQTT LXC** - - New V2 Install Script -- **Home Assistant Container LXC** - - Update Menu usability improvements - -## 2022-02-22 - -### Changed - -- **Home Assistant Container LXC** - - New V2 Install Script -- **Node-Red LXC** - - New V2 Install Script -- **Mariadb LXC** - - New V2 Install Script -- **MQTT LXC** - - New V2 Install Script -- **Debian 11 LXC** - - New V2 Install Script -- **Ubuntu 21.10 LXC** - - New V2 Install Script - -## 2022-02-20 - -### Changed - -- **Home Assistant Container LXC** - - New Script to migrate to the latest Update Menu - -## 2022-02-19 - -### Changed - -- **Nginx Proxy Manager LXC** - - Add Update Script -- **Vaultwarden LXC** - - Make unattended install & Cleanup Script - -## 2022-02-18 - -### Changed - -- **Node-Red LXC** - - Add Install [Themes Script](https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/node-red-themes.png) - -## 2022-02-16 - -### Changed - -- **Home Assistant Container LXC** - - Add Options to [Update Menu](https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/update-menu.png) - -## 2022-02-14 - -### Changed - -- **Home Assistant Container LXC** - - Add [Update Menu](https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/update-menu.png) - -## 2022-02-13 - -### Changed - -- **Mariadb LXC** - - Add [Adminer](https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/adminer.png) (formerly phpMinAdmin), a full-featured database management tool - -## 2022-02-12 - -### Changed - -- **Home Assistant Container LXC (Podman)** - - Add Yacht web interface for managing Podman containers - - new GUI script to copy data from a **Home Assistant LXC** to a **Podman Home Assistant LXC** - - Improve documentation for several LXC's - -## 2022-02-10 - -### Changed - -- **GamUntu LXC** - - New Script -- **Jellyfin Media Server LXC** - - new script to fix [start issue](https://github.com/tteck/Proxmox/issues/29#issue-1127457380) -- **MotionEye NVR LXC** - - New script - -## 2022-02-09 - -### Changed - -- **Zigbee2MQTT LXC** - - added USB passthrough during installation (no extra script) - - Improve documentation -- **Zwavejs2MQTT LXC** - - added USB passthrough during installation (no extra script) -- **Jellyfin Media Server LXC** - - Moved to testing due to issues. - - Changed install method. -- **Home Assistant Container LXC (Podman)** - - add script for easy Home Assistant update - -## 2022-02-06 - -### Changed - -- **Debian 11 LXC** - - Add Docker Support -- **Ubuntu 21.10 LXC** - - Add Docker Support - -## 2022-02-05 - -### Changed - -- **Vaultwarden LXC** - - New script - -## 2022-02-01 - -### Changed - -- **All Scripts** - - Fix issue where some networks were slow to assign a IP address to the container causing scripts to fail. - -## 2022-01-30 - -### Changed - -- **Zigbee2MQTT LXC** - - Clean up / Improve script - - Improve documentation - -## 2022-01-29 - -### Changed - -- **Node-Red LXC** - - Clean up / Improve script - - Improve documentation - -## 2022-01-25 - -### Changed - -- **Jellyfin Media Server LXC** - - new script - -## 2022-01-24 - -### Changed - -- **Plex Media Server LXC** - - better Hardware Acceleration Support - - `va-driver-all` is preinstalled - - now using Ubuntu 21.10 -- **misc** - - new GUI script [(Screenshot)](https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/pms-copy-data.png) to copy data from one Plex Media Server LXC to another Plex Media Server LXC - - -## Initial Catch up - 2022-01-23 - -### Changed - -- **Plex Media Server LXC** - - add Hardware Acceleration Support - - add script to install Intel Drivers -- **Zwavejs2MQTT LXC** - - new script to solve no auto start at boot -- **Nginx Proxy Manager LXC** - - new script to use Debian 11 -- **Ubuntu 21.10 LXC** - - new script -- **Mariadb LXC** - - add MariaDB Package Repository -- **MQTT LXC** - - add Eclipse Mosquitto Package Repository -- **Home Assistant Container LXC** - - change if ZFS filesystem is detected, execute automatic installation of static fuse-overlayfs - - add script for easy Home Assistant update -- **Home Assistant Container LXC (Podman)** - - change if ZFS filesystem is detected, execute automatic installation of static fuse-overlayfs -- **Home Assistant OS VM** - - change disk type from SATA to SCSI to follow Proxmox official recommendations of choosing VirtIO-SCSI with SCSI disk - - clean up -- **Proxmox VE 7 Post Install** - - new *No-Nag* method -- **misc** - - new GUI script to copy data from one Home Assistant LXC to another Home Assistant LXC - - new GUI script to copy data from one Zigbee2MQTT LXC to another Zigbee2MQTT LXC diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..fd304c7d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,2332 @@ +<div align="center"> + <a href="#"> + <img src="https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/logo.png" height="100px" /> + </a> +</div> +<h1 align="center">Changelog</h1> + +<h3 align="center">All notable changes to this project will be documented in this file.</h3> + +> [!WARNING] +Be cautious of copycat or coat-tailing sites that exploit the project's popularity with potentially malicious intent. Please only trust information from https://Helper-Scripts.com/ or https://tteck.github.io/Proxmox/. + +- All LXC instances created using this repository come pre-installed with Midnight Commander, which is a command-line tool (`mc`) that offers a user-friendly file and directory management interface for the terminal environment. + +## 2024-08-21 + +### Changed + +- **WireGuard LXC** [(Commit)](https://github.com/tteck/Proxmox/commit/723365a79df7cc0fd29b1af8f7ef200a7e0921b1) + - Refactor Code + - Breaking Change + +## 2024-08-19 + +### Changed + +- **CommaFeed LXC** [(Commit)](https://github.com/tteck/Proxmox/commit/0a33d1739ec3a49011411929bd46a260e92e99f9) + - Refactor Code + - Breaking Change + +## 2024-08-06 + +### Changed + +- **lldap LXC** [(View Source)](https://github.com/tteck/Proxmox/blob/main/install/lldap-install.sh) + - NEW Script + +## 2024-07-26 + +### Changed + +- **Gitea LXC** [(View Source)](https://github.com/tteck/Proxmox/blob/main/install/gitea-install.sh) + - NEW Script + +## 2024-06-30 + +### Changed + +- **All Scripts** [(Commit)](https://github.com/tteck/Proxmox/commit/39ea1d4a20b83c07d084ebafdc811eec3548f289) + - Requires Proxmox Virtual Environment version 8.1 or later. + +## 2024-06-27 + +### Changed + +- **Kubo LXC** [(View Source)](https://github.com/tteck/Proxmox/blob/main/install/kubo-install.sh) + - NEW Script +- **RabbitMQ LXC** [(View Source)](https://github.com/tteck/Proxmox/blob/main/install/rabbitmq-install.sh) + - NEW Script +- **Scrutiny LXC** + - Removed from website, broken. + +## 2024-06-26 + +### Changed + +- **Scrutiny LXC** + - NEW Script + +## 2024-06-14 + +### Changed + +- **MySpeed LXC** [(View Source)](https://github.com/tteck/Proxmox/blob/main/install/myspeed-install.sh) + - NEW Script + +## 2024-06-13 + +### Changed + +- **PeaNUT LXC** [(View Source)](https://github.com/tteck/Proxmox/blob/main/install/peanut-install.sh) + - NEW Script +- **Website** + - If the Changelog has changed recently, the link on the website will pulse. +- **Spoolman LXC** [(View Source)](https://github.com/tteck/Proxmox/blob/main/install/spoolman-install.sh) + - NEW Script + +## 2024-06-12 + +### Changed + +- **MeTube LXC** [(View Source)](https://github.com/tteck/Proxmox/blob/main/install/metube-install.sh) + - NEW Script +- **Matterbridge LXC** [(View Source)](https://github.com/tteck/Proxmox/blob/main/install/matterbridge-install.sh) + - NEW Script +- **Website** + - Reopen the gh-pages site (https://tteck.github.io/Proxmox/) + +## 2024-06-11 + +### Changed + +- **Zabbix LXC** [(View Source)](https://github.com/tteck/Proxmox/blob/main/install/zabbix-install.sh) + - NEW Script + +## 2024-06-06 + +### Changed + +- **Petio LXC** [(View Source)](https://github.com/tteck/Proxmox/blob/main/install/petio-install.sh) + - NEW Script +- **Website** + - Important notices will now be displayed on the landing page. + +## 2024-06-04 + +### Changed + +- **FlareSolverr LXC** [(View Source)](https://github.com/tteck/Proxmox/blob/main/install/flaresolverr-install.sh) + - NEW Script + +## 2024-05-31 + +### Changed + +- **Advanced Settings** [(Commit)](https://github.com/tteck/Proxmox/commit/fc9dff220b4ea426d3a75178ad8accacae4683ca) + - Passwords are now masked + +## 2024-05-30 + +### Changed + +- **Forgejo LXC** + - NEW Script + +## 2024-05-28 + +### Changed + +- **Notifiarr LXC** + - NEW Script + +## 2024-05-25 + +### Changed + +- **Threadfin LXC** + - NEW Script + +## 2024-05-23 + +### Changed + +- **BunkerWeb LXC** + - NEW Script + +## 2024-05-20 + +### Changed + +- **Traefik LXC** + - NEW Script + +## 2024-05-19 + +### Changed + +- **NetBird** + - NEW Script +- **Tailscale** + - Refactor Code + +## 2024-05-18 + +### Changed + +- **MongoDB LXC** + - NEW Script + +## 2024-05-17 + +### Changed + +- **New Website** + - We have officially moved to [Helper-Scripts.com](https://helper-scripts.com) + +## 2024-05-16 + +### Changed + +- **iVentoy LXC** + - NEW Script + +## 2024-05-13 + +### Changed + +- **Headscale LXC** + - NEW Script + +## 2024-05-11 + +### Changed + +- **Caddy LXC** + - NEW Script + +## 2024-05-09 + +### Changed + +- **Umami LXC** + - NEW Script + +## 2024-05-08 + +### Changed + +- **Kernel Pin** + - NEW Script +- **Home Assistant Core LXC** + - Ubuntu 24.04 ONLY + +## 2024-05-07 + +### Changed + +- **Pocketbase LXC** + - NEW Script + +## 2024-05-05 + +### Changed + +- **Fenrus LXC** + - NEW Script + +## 2024-05-02 + +### Changed + +- **OpenMediaVault LXC** + - Set Debian 12 as default + - OpenMediaVault 7 (sandworm) + +## 2024-04-30 + +### Changed + +- **Tdarr LXC** + - Default settings are now **Unprivileged** + - Unprivileged Hardware Acceleration + +## 2024-04-29 + +### Changed + +- **ErsatzTV LXC** + - NEW Script + +## 2024-04-28 + +### Changed + +- **Scrypted LXC** + - Unprivileged Hardware Acceleration +- **Emby LXC** + - Unprivileged Hardware Acceleration + +## 2024-04-27 + +### Changed + +- **Frigate LXC** + - Unprivileged Hardware Acceleration https://github.com/tteck/Proxmox/discussions/2711#discussioncomment-9244629 +- **Ubuntu 24.04 VM** + - NEW Script + +## 2024-04-26 + +### Changed + +- **Glances** + - NEW Script + +## 2024-04-25 + +### Changed + +- **Jellyfin LXC** + - Default settings are now **Unprivileged** + - Unprivileged Hardware Acceleration + - Groups are set automatically + - Checks for the existence of `/dev/dri/card0` if not found, use `/dev/dri/card1`. Set the GID to `44` + - Set the GID for `/dev/dri/renderD128` to `104` + - Not tested <8.1.11 +- **Plex LXC** + - Default settings are now **Unprivileged** + - Unprivileged Hardware Acceleration + - Groups are set automatically + - Checks for the existence of `/dev/dri/card0` if not found, use `/dev/dri/card1`. Set the GID to `44` + - Set the GID for `/dev/dri/renderD128` to `104` + - Not tested <8.1.11 + +## 2024-04-24 + +### Changed + +- **Traccar LXC** + - NEW Script +- **Calibre-Web LXC** + - NEW Script + +## 2024-04-21 + +### Changed + +- **Aria2 LXC** + - NEW Script + +## 2024-04-15 + +### Changed + +- **Homarr LXC** + - Add back to website +- **Umbrel LXC** + - Add back to website +- **OpenMediaVault LXC** + - Add back to website + +## 2024-04-12 + +### Changed + +- **OpenMediaVault LXC** + - Removed from website + +## 2024-04-09 + +### Changed + +- **PairDrop LXC** + - Add back to website + +## 2024-04-05 + +### Changed + +- **Medusa LXC** + - NEW Script +- **WatchYourLAN LXC** + - NEW Script + +## 2024-04-04 + +### Changed + +- **Actual Budget LXC** + - NEW Script + +## 2024-04-03 + +### Changed + +- **LazyLibrarian LXC** + - NEW Script + +## 2024-04-01 + +### Changed + +- **Frigate LXC** + - NEW Script + +## 2024-03-26 + +### Changed + +- **MediaMTX LXC** + - NEW Script + +## 2024-03-25 + +### Changed + +- **Proxmox VE Post Install** + - ~Requires Proxmox Virtual Environment Version 8.1.1 or later.~ + - Requires Proxmox Virtual Environment Version 8.0 or later. +- **Proxmox Backup Server LXC** + - NEW Script + +## 2024-03-24 + +### Changed + +- **SmokePing LXC** + - NEW Script + +## 2024-03-13 + +### Changed + +- **FlowiseAI LXC** + - NEW Script + +## 2024-03-11 + +### Changed + +- **Wastebin LXC** + - NEW Script + +## 2024-03-08 + +### Changed + +- **Proxmox VE Post Install** + - Requires Proxmox Virtual Environment Version 8.1.1 or later. + +## 2024-02-26 + +### Changed + +- **Mafl LXC** + - NEW Script + +## 2024-02-23 + +### Changed + +- **Tandoor Recipes LXC** + - NEW Script (Thanks @MickLesk) + +## 2024-02-21 + +### Changed + +- **All scripts** + - As of today, the scripts require the Bash shell specifically. ([more info](https://github.com/tteck/Proxmox/discussions/2536)) + +## 2024-02-19 + +### Changed + +- **PairDrop LXC** + - Removed from the website ([more info](https://github.com/tteck/Proxmox/discussions/2516)) + +## 2024-02-16 + +### Changed + +- **Proxmox VE LXC Filesystem Trim** + - NEW Script ([more info](https://github.com/tteck/Proxmox/discussions/2505#discussion-6226037)) + +## 2024-02-11 + +### Changed + +- **HiveMQ CE LXC** + - NEW Script +- **Apache-CouchDB LXC** + - NEW Script + +## 2024-02-06 + +### Changed + +- **All Scripts** + - The scripts will only work with PVE7 Version 7.4-13 or later, or PVE8 Version 8.1.1 or later. + +## 2024-02-05 + +### Changed + +- **Gokapi LXC** + - NEW Script +- **Nginx Proxy Manager LXC** + - Option to install v2.10.4 + +## 2024-02-04 + +### Changed + +- **Pi-hole LXC** + - Option to add Unbound + +## 2024-02-02 + +### Changed + +- **Readeck LXC** + - NEW Script + +## 2024-01-25 + +### Changed + +- **PairDrop LXC** + - NEW Script + +## 2024-01-20 + +### Changed + +- **Apache-Cassandra LXC** + - NEW Script +- **Redis LXC** + - NEW Script + +## 2024-01-17 + +### Changed + +- **ntfy LXC** + - NEW Script +- **HyperHDR LXC** + - NEW Script + +## 2024-01-16 + +### Changed + +- **Website Improvements** + - Refine and correct pointers. + - Change hover colors to intuitively indicate categories/items. + - Implement opening links in new tabs for better navigation. + - Enhance the Copy button to better indicate that the command has been successfully copied. + - Introduce a Clear Search button. + - While not directly related to the website, it's worth mentioning that the logo in newly created LXC notes now serves as a link to the website, conveniently opening in a new tab. + +## 2024-01-12 + +### Changed + +- **Apt-Cacher-NG LXC** + - NEW Script +- **New Feature** + - The option to utilize Apt-Cacher-NG (Advanced settings) when creating LXCs. The added functionality is expected to decrease bandwidth usage and expedite package installation and updates. https://github.com/tteck/Proxmox/discussions/2332 + +## 2024-01-09 + +### Changed + +- **Verbose mode** + - Only entries with `$STD` will be shown + +## 2024-01-07 + +### Changed + +- **Stirling-PDF LXC** + - NEW Script +- **SFTPGo LXC** + - NEW Script + +## 2024-01-04 + +### Changed + +- **CommaFeed LXC** + - NEW Script + +## 2024-01-03 + +### Changed + +- **Sonarr LXC** + - Breaking Change + - Complete recode + - https://github.com/tteck/Proxmox/discussions/1738#discussioncomment-8005107 + +## 2024-01-01 + +### Changed + +- **Gotify LXC** + - NEW Script + +## 2023-12-19 + +### Changed + +- **Proxmox VE Netdata** + - NEW Script + +## 2023-12-10 + +### Changed + +- **Homarr LXC** + - Removed, again. + +## 2023-12-02 + +### Changed + +- **Runtipi LXC** + - NEW Script + +## 2023-12-01 + +### Changed + +- **Mikrotik RouterOS VM** + - Now Mikrotik RouterOS CHR VM + - code refactoring + - update to CHR + - thanks to @NiccyB +- **Channels DVR Server LXC** + - NEW Script + +## 2023-11-19 + +### Changed + +- **Dockge LXC** + - NEW Script + +## 2023-11-18 + +### Changed + +- **Ubuntu 22.04 VM** + - NEW Script + +## 2023-11-14 + +### Changed + +- **TurnKey Nextcloud VM** + - NEW Script +- **TurnKey ownCloud VM** + - NEW Script + +## 2023-11-11 + +### Changed + +- **Homarr LXC** + - Returns with v0.14.0 (The authentication update). + +## 2023-11-9 + +### Changed + +- **AgentDVR LXC** + - NEW Script + +## 2023-11-8 + +### Changed + +- **Linkwarden LXC** + - NEW Script + +## 2023-11-2 + +### Changed + +- **PhotoPrism LXC** + - Transitioned to PhotoPrism's latest installation package, featuring Linux binaries. + +## 2023-11-1 + +### Changed + +- **Owncast LXC** + - NEW Script + +## 2023-10-31 + +### Changed + +- **Debian 12 VM** + - NEW Script + +## 2023-10-29 + +### Changed + +- **Unmanic LXC** + - NEW Script + +## 2023-10-27 + +### Changed + +- **Webmin** + - A full code overhaul. + +## 2023-10-15 + +### Changed + +- **TasmoAdmin LXC** + - NEW Script + +## 2023-10-14 + +### Changed + +- **Sonarr LXC** + - Include an option to install v4 (experimental) + +## 2023-10-11 + +### Changed + +- **Proxmox VE CPU Scaling Governor** + - A full code overhaul. + - Include an option to configure a crontab for ensuring that the CPU Scaling Governor configuration persists across reboots. + +## 2023-10-08 + +### Changed + +- **Proxmox VE LXC Updater** + - Now displays which containers require a reboot. +- **File Browser** + - Uninstall by re-executing the script + - Option to use No Authentication + +## 2023-10-05 + +### Changed + +- **Pingvin Share LXC** + - NEW Script + +## 2023-09-30 + +### Changed + +- **All Templates** + - NEW Script + +## 2023-09-28 + +### Changed + +- **Alpine Nextcloud Hub LXC** + - NEW Script (Thanks to @nicedevil007) + +## 2023-09-14 + +### Changed + +- **Proxmox VE Processor Microcode** + - Allow users to select available microcode packages. + +## 2023-09-13 + +### Changed + +- **Pi.Alert LXC** + - NEW Script +- **Proxmox VE Kernel Clean** + - Code overhaul with a fresh start. This script offers the flexibility to select specific kernels for removal, unlike the previous version, which was an all-or-nothing approach. + +## 2023-09-11 + +### Changed + +- **Paperless-ngx LXC** + - Modify the script to incorporate Redis and PostgreSQL, while also introducing an option to include Adminer during installation. + +## 2023-09-10 + +### Changed + +- **TurnKey Game Server LXC** + - NEW Script + +## 2023-09-09 + +### Changed + +- **Proxmox VE Host Backup** + - Users are now able to specify both the backup path and the directory in which they wish to work. + +## 2023-09-07 + +### Changed + +- **Proxmox VE Host Backup** + - NEW Script + +## 2023-09-06 + +### Changed + +- **Proxmox VE LXC Cleaner** + - Added a new menu that allows you to choose which containers you want to exclude from the clean process. +- **Tailscale** + - Added a menu that enables you to choose the specific container where you want to install Tailscale. + +## 2023-09-05 + +### Changed + +- **Proxmox VE LXC Updater** + - Added a new menu that allows you to choose which containers you want to exclude from the update process. + +## 2023-09-01 + +### Changed + +- **TurnKey Media Server LXC** + - NEW Script + +## 2023-08-31 + +### Changed + +- **TurnKey ZoneMinder LXC** + - NEW Script +- **TurnKey OpenVPN LXC** + - NEW Script + +## 2023-08-30 + +### Changed + +- **TurnKey** + - Introducing a **NEW** Category on the Site. + - My intention is to maintain the TurnKey scripts in their simplest form, contained within a single file, and with minimal options, if any. +- **TurnKey Core LXC** + - NEW Script +- **TurnKey File Server LXC** + - NEW Script +- **TurnKey Gitea LXC** + - NEW Script +- **TurnKey GitLab LXC** + - NEW Script +- **TurnKey Nextcloud LXC** + - NEW Script +- **TurnKey Observium LXC** + - NEW Script +- **TurnKey ownCloud LXC** + - NEW Script +- **TurnKey Torrent Server LXC** + - NEW Script +- **TurnKey Wordpress LXC** + - NEW Script + +## 2023-08-24 + +### Changed + +- **qBittorrent LXC** + - Added back to repository with UPnP disabled and password changed. + +## 2023-08-24 + +### Changed + +- **qBittorrent LXC** + - Removed from this repository for potential malicious hidden code https://github.com/tteck/Proxmox/discussions/1725 + +## 2023-08-16 + +### Changed + +- **Homarr LXC** + - NEW Script + +## 2023-08-10 + +### Changed + +- **Proxmox VE Processor Microcode** + - AMD microcode-20230808 Release + +## 2023-08-09 + +### Changed + +- **Omada Controller LXC** + - Update via script +- **Proxmox VE Processor Microcode** + - [Intel microcode-20230808 Release](https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files/releases/tag/microcode-20230808) + +## 2023-08-01 + +### Changed + +- **Overseerr LXC** + - NEW Script +- **Jellyseerr LXC** + - NEW Script + +## 2023-07-24 + +### Changed + +- **Ombi LXC** + - NEW Script + +## 2023-07-23 + +### Changed + +- **Zoraxy LXC** + - NEW Script + +## 2023-07-18 + +### Changed + +- **Proxmox VE Cron LXC Updater** + - NEW Script + +## 2023-07-11 + +### Changed + +- **Scrypted LXC** + - Add VAAPI hardware transcoding + +## 2023-07-07 + +### Changed + +- **Real-Debrid Torrent Client LXC** + - NEW Script + +## 2023-07-05 + +### Changed + +- There have been more than 110 commits since June 18th, although not all of them are significant, with a majority focused on ensuring compatibility with Proxmox VE 8 and Debian 12. + +## 2023-06-18 + +### Changed + +- **OpenObserve LXC** + - NEW Script + +## 2023-06-17 + +### Changed + +- **UniFi Network Application LXC** + - Now distribution agnostic. +- **Omada Controller LXC** + - Now distribution agnostic. +## 2023-06-16 + +### Changed + +- **Proxmox VE Monitor-All** + - Skip instances based on onboot and templates. [8c2a3cc](https://github.com/tteck/Proxmox/commit/8c2a3cc4d774fa13d17f695d6bdf9a4deedb1372). + +## 2023-06-12 + +### Changed + +- **Proxmox VE Edge Kernel** + - Removed, with the Proxmox opt-in kernels and the upcoming Proxmox Virtual Environment 8, edge kernels are no longer needed. +- **Proxmox VE Kernel Clean** + - Now compatible with PVE8. + +## 2023-06-11 + +### Changed + +- **Proxmox VE Post Install** + - Now compatible with both Proxmox Virtual Environment 7 (PVE7) and Proxmox Virtual Environment 8 (PVE8). + +## 2023-06-02 + +### Changed + +- **Proxmox VE 7 Post Install** + - In a non-clustered environment, you can choose to disable high availability, which helps save system resources. + +## 2023-05-27 + +### Changed + +- **Proxmox VE 7 Post Install** + - If an Intel N-series processor is detected, ~the script provides options to install both the Proxmox 6.2 kernel and the Intel microcode.~ and using PVE7, recommend using PVE8 + +## 2023-05-23 + +### Changed + +- **OpenWrt VM** + - NEW Script + +## 2023-05-17 + +### Changed + +- **Alpine-AdGuard Home LXC** + - Removed, it wasn't installed through the Alpine package manager. +- **Alpine-Whoogle LXC** + - Removed, it wasn't installed through the Alpine package manager. + +## 2023-05-16 + +### Changed + +- **Proxmox VE LXC Updater** + - Add information about the boot disk, which provides an easy way to determine if you need to expand the disk. +- **Proxmox VE Processor Microcode** + - [Intel microcode-20230512 Release](https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files/releases/tag/microcode-20230512) + +## 2023-05-13 + +### Changed + +- **Tautulli LXC** + - NEW Script + +## 2023-05-12 + +### Changed + +- **Bazarr LXC** + - NEW Script + +## 2023-05-08 + +### Changed + +- **Proxmox VE Intel Processor Microcode** + - Renamed to **Proxmox VE Processor Microcode** + - Automatically identifies the processor vendor (Intel/AMD) and installs the appropriate microcode. + +## 2023-05-07 + +### Changed + +- **FHEM LXC** + - NEW Script + +## 2023-05-01 + +### Changed + +- **OctoPrint LXC** + - NEW Script +- **Proxmox VE Intel Processor Microcode** + - NEW Script + +## 2023-04-30 + +### Changed + +- **Proxmox VE Monitor-All** + - NEW Script + - Replaces Proxmox VE LXC Monitor + +## 2023-04-28 + +### Changed + +- **Proxmox VE LXC Monitor** + - NEW Script + +## 2023-04-26 + +### Changed + +- **The site can now be accessed through a more memorable URL, which is [helper-scripts.com](http://helper-scripts.com).** + +## 2023-04-23 + +### Changed + +- **Non-Alpine LXC's** + - Advanced settings provide the option for users to switch between Debian and Ubuntu distributions. However, some applications or services, such as Deconz, grocy or Omada, may not be compatible with the selected distribution due to dependencies. + +## 2023-04-16 + +### Changed + +- **Home Assistant Core LXC** + - Python 3.11.2 + +## 2023-04-15 + +### Changed + +- **InfluxDB LXC** + - Choosing InfluxDB v1 will result in Chronograf being installed automatically. +- **[User Submitted Guides](https://github.com/tteck/Proxmox/blob/main/USER_SUBMITTED_GUIDES.md)** + - Informative guides that demonstrate how to install various software packages using Proxmox VE Helper Scripts. + +## 2023-04-14 + +### Changed + +- **Cloudflared LXC** + - NEW Script + +## 2023-04-05 + +### Changed + +- **Jellyfin LXC** + - Set Ubuntu 22.04 as default + - Use the Deb822 format jellyfin.sources configuration (jellyfin.list configuration has been obsoleted) + +## 2023-04-02 + +### Changed + +- **Home Assistant OS VM** + - Include a choice within the "Advanced" settings to configure the CPU model between kvm64 (default) or host. + +## 2023-03-31 + +### Changed + +- **Home Assistant OS VM** + - Include a choice within the "Advanced" settings to configure the disk cache between none (default) or Write Through. + +## 2023-03-27 + +### Changed + +- **Removed Alpine-ESPHome LXC** + - Nonoperational +- **All Scripts** + - Incorporate code that examines whether SSH is being used and, if yes, offers a suggestion against it without restricting or blocking its usage. + +## 2023-03-25 + +### Changed + +- **Alpine-ESPHome LXC** + - NEW Script +- **Alpine-Whoogle LXC** + - NEW Script + +## 2023-03-22 + +### Changed + +- **The latest iteration of the scripts** + - Going forward, versioning will no longer be utilized in order to avoid breaking web-links in blogs and YouTube videos. + - The scripts have been made more legible as the repetitive code has been moved to function files, making it simpler to share among the scripts and hopefully easier to maintain. This also makes it simpler to contribute to the project. + - When a container is created with privileged mode enabled, the USB passthrough feature is automatically activated. + +## 2023-03-18 + +### Changed + +- **Alpine-AdGuard Home LXC** (Thanks @nicedevil007) + - NEW Script +- **Alpine-Docker LXC** + - NEW Script +- **Alpine-Zigbee2MQTT LXC** + - NEW Script + +## 2023-03-15 + +### Changed + +- **Alpine-Grafana LXC** (Thanks @nicedevil007) + - NEW Script + +## 2023-03-10 + +### Changed + +- **Proxmox LXC Updater** + - You can use the command line to exclude multiple containers simultaneously. + +## 2023-03-08 + +### Changed + +- **Proxmox CPU Scaling Governor** + - Menu options dynamically based on the available scaling governors. + +## 2023-03-07 + +### Changed + +- **Alpine-Vaultwarden LXC** + - NEW Script +- **All LXC Scripts** + - Retrieve the time zone from Proxmox and configure the container to use the same time zone + +## 2023-02-24 + +### Changed + +- **qBittorrent LXC** (Thanks @romka777) + - NEW Script +- **Jackett LXC** (Thanks @romka777) + - NEW Script + +## 2023-02-23 + +### Changed + +- **Proxmox LXC Updater** + - Skip all templates, allowing for the starting, updating, and shutting down of containers to be resumed automatically. + - Exclude an additional container by adding the CTID at the end of the shell command ( -s 103). + +## 2023-02-16 + +### Changed + +- **RSTPtoWEB LXC** + - NEW Script +- **go2rtc LXC** + - NEW Script + +## 2023-02-12 + +### Changed + +- **OliveTin** + - NEW Script + +## 2023-02-10 + +### Changed + +- **Home Assistant OS VM** + - Code Refactoring + +## 2023-02-05 + +### Changed + +- **Devuan LXC** + - NEW Script + +## 2023-02-02 + +### Changed + +- **Audiobookshelf LXC** + - NEW Script +- **Rocky Linux LXC** + - NEW Script + +## 2023-01-28 + +### Changed + +- **LXC Cleaner** + - Code refactoring to give the user the option to choose whether cache or logs will be deleted for each app/service. + - Leaves directory structure intact + +## 2023-01-27 + +### Changed + +- **LXC Cleaner** + - NEW Script + +## 2023-01-26 + +### Changed + +- **ALL LXC's** + - Add an option to disable IPv6 (Advanced) + +## 2023-01-25 + +### Changed + +- **Home Assistant OS VM** + - switch to v5 + - add an option to set MTU size (Advanced) + - add arch check (no ARM64) (issue from community.home-assistant.io) + - add check to insure VMID isn't already used before VM creation (Advanced) (issue from forum.proxmox.com) + - code refactoring +- **PiMox Home Assistant OS VM** + - switch to v5 + - add an option to set MTU size (Advanced) + - add arch check (no AMD64) + - add pve check (=>7.2) + - add check to insure VMID isn't already used before VM creation (Advanced) + - code refactoring +- **All LXC's** + - add arch check (no ARM64) (issue from forum.proxmox.com) + +## 2023-01-24 + +### Changed + +- **Transmission LXC** + - NEW Script + +## 2023-01-23 + +### Changed + +- **ALL LXC's** + - Add [Midnight Commander (mc)](https://www.linuxcommand.org/lc3_adv_mc.php) + +## 2023-01-22 + +### Changed + +- **Autobrr LXC** + - NEW Script + +## 2023-01-21 + +### Changed + +- **Kavita LXC** + - NEW Script + +## 2023-01-19 + +### Changed + +- **SABnzbd LXC** + - NEW Script + +## 2023-01-17 + +### Changed + +- **Homer LXC** + - NEW Script + +## 2023-01-14 + +### Changed + +- **Tdarr LXC** + - NEW Script +- **Deluge LXC** + - NEW Script + +## 2023-01-13 + +### Changed + +- **Lidarr LXC** + - NEW Script +- **Prowlarr LXC** + - NEW Script +- **Radarr LXC** + - NEW Script +- **Readarr LXC** + - NEW Script +- **Sonarr LXC** + - NEW Script +- **Whisparr LXC** + - NEW Script + +## 2023-01-12 + +### Changed + +- **ALL LXC's** + - Add an option to set MTU size (Advanced) + +## 2023-01-11 + +### Changed + +- **Home Assistant Core LXC** + - Auto Initialize +- **Cronicle Primary/Worker LXC** + - NEW Script + +## 2023-01-09 + +### Changed + +- **ALL LXC's** + - v5 +- **k0s Kubernetes LXC** + - NEW Script +- **Podman LXC** + - NEW Script + +## 2023-01-04 + +### Changed + +- **YunoHost LXC** + - NEW Script + +## 2022-12-31 + +### Changed + +- **v5 Scripts** (Testing before moving forward https://github.com/tteck/Proxmox/discussions/881) + - Adguard Home LXC + - Docker LXC + - Home Assistant Core LXC + - PhotoPrism LXC + - Shinobi NVR LXC + - Vaultwarden LXC + +## 2022-12-27 + +### Changed + +- **Home Assistant Container LXC** + - Add an option to use Fuse Overlayfs (ZFS) (Advanced) + +- **Docker LXC** + - Add an option to use Fuse Overlayfs (ZFS) (Advanced) + - If the LXC is created Privileged, the script will automatically set up USB passthrough. + +## 2022-12-22 + +### Changed + +- **All LXC's** + - Add an option to run the script in Verbose Mode (Advanced) + +## 2022-12-20 + +### Changed + +- **Hyperion LXC** + - NEW Script + +## 2022-12-17 + +### Changed + +- **Home Assistant Core LXC** + - Linux D-Bus Message Broker + - Mariadb & PostgreSQL Ready + - Bluetooth Ready + - Fix for Inconsistent Dependency Versions (dbus-fast & bleak) + +## 2022-12-16 + +### Changed + +- **Home Assistant Core LXC** + - Python 3.10.8 + +## 2022-12-09 + +### Changed + +- **Change Detection LXC** + - NEW Script + +## 2022-12-03 + +### Changed + +- **All LXC's** + - Add options to set DNS Server IP Address and DNS Search Domain (Advanced) + +## 2022-11-27 + +### Changed + +- **Shinobi LXC** + - NEW Script + +## 2022-11-24 + +### Changed + +- **Home Assistant OS VM** + - Add option to set machine type during VM creation (Advanced) + +## 2022-11-23 + +### Changed + +- **All LXC's** + - Add option to enable root ssh access during LXC creation (Advanced) + +## 2022-11-21 + +### Changed + +- **Proxmox LXC Updater** + - Now updates Ubuntu, Debian, Devuan, Alpine Linux, CentOS-Rocky-Alma, Fedora, ArchLinux [(@Uruknara)](https://github.com/tteck/Proxmox/commits?author=Uruknara) + +## 2022-11-13 + +### Changed + +- **All LXC's** + - Add option to continue upon Internet NOT Connected + +## 2022-11-11 + +### Changed + +- **HA Bluetooth Integration Preparation** + - [NEW Script](https://github.com/tteck/Proxmox/discussions/719) + +## 2022-11-04 + +### Changed + +- **Scrypted LXC** + - NEW Script + +## 2022-11-01 + +### Changed + +- **Alpine LXC** + - NEW Script +- **Arch LXC** + - NEW Script + +## 2022-10-27 + +### Changed + +- **Container & Core Restore from Backup** + - [NEW Scripts](https://github.com/tteck/Proxmox/discussions/674) + +## 2022-10-07 + +### Changed + +- **Home Assistant OS VM** + - Add "Latest" Image + +## 2022-10-05 + +### Changed + +- **Umbrel LXC** + - NEW Script (Docker) +- **Blocky LXC** + - NEW Script (Adblocker - DNS) + +## 2022-09-29 + +### Changed + +- **Home Assistant Container LXC** + - If the LXC is created Privileged, the script will automatically set up USB passthrough. +- **Home Assistant Core LXC** + - NEW Script +- **PiMox HAOS VM** + - NEW Script + +## 2022-09-23 + +### Changed + +- **EMQX LXC** + - NEW Script + +## 2022-09-22 + +### Changed + +- **NextCloudPi LXC** + - NEW Script + +## 2022-09-21 + +### Changed + +- **Proxmox Backup Server Post Install** + - NEW Script +- **Z-wave JS UI LXC** + - NEW Script (and all sub scripts 🤞) +- **Zwave2MQTT LXC** + - Bye Bye Script + +## 2022-09-20 + +### Changed + +- **OpenMediaVault LXC** + - NEW Script + +## 2022-09-16 + +### Changed + +- **Paperless-ngx LXC** + - NEW Script (Thanks @Donkeykong307) + +## 2022-09-11 + +### Changed + +- **Trilium LXC** + - NEW Script + +## 2022-09-10 + +### Changed + +- **Syncthing LXC** + - NEW Script + +## 2022-09-09 + +### Changed + +- **CasaOS LXC** + - NEW Script +- **Proxmox Kernel Clean** + - Now works with Proxmox Backup Server + +## 2022-09-08 + +### Changed + +- **Navidrome LXC** + - NEW Script +- **Homepage LXC** + - NEW Script + +## 2022-08-31 + +### Changed + +- **All LXC's** + - Add Internet & DNS Check + +## 2022-08-22 + +### Changed + +- **Wiki.js LXC** + - NEW Script +- **Emby Media Server LXC** + - NEW Script + +## 2022-08-20 + +### Changed + +- **Mikrotik RouterOS VM** + - NEW Script + +## 2022-08-19 + +### Changed + +- **PhotoPrism LXC** + - Fixed .env bug (Thanks @cklam2) + +## 2022-08-13 + +### Changed + +- **Home Assistant OS VM** + - Option to create VM using Stable, Beta or Dev Image + +## 2022-08-11 + +### Changed + +- **Home Assistant OS VM** + - Validate Storage + +## 2022-08-04 + +### Changed + +- **VS Code Server** + - NEW Script + +## 2022-08-02 + +### Changed + +- **All LXC/VM** + - v4 Script - Whiptail menu's + +## 2022-07-26 + +### Changed + +- **Home Assistant OS VM** + - Set the real time clock (RTC) to local time. + - Disable the USB tablet device (save resources / not needed). + +## 2022-07-24 + +### Changed + +- **Home Assistant OS VM** + - Present the drive to the guest as a solid-state drive rather than a rotational hard disk. There is no requirement that the underlying storage actually be backed by SSD's. + - When the VM’s filesystem marks blocks as unused after deleting files, the SCSI controller will relay this information to the storage, which will then shrink the disk image accordingly. + - 👉 [more info](https://github.com/tteck/Proxmox/discussions/378) + +## 2022-07-22 + +### Changed + +- **n8n LXC** (thanks to @cyakimov) + - NEW Script + +## 2022-07-21 + +### Changed + +- **grocy LXC** + - NEW Script + +## 2022-07-17 + +### Changed + +- **Vaultwarden LXC** + - NEW Vaultwarden Update (post 2022-05-29 installs only) Script + - NEW Web-vault Update (any) Script + +## 2022-07-14 + +### Changed + +- **MagicMirror Server LXC** + - NEW Script + +## 2022-07-13 + +### Changed + +- **Proxmox Edge Kernel Tool** + - NEW Script + +## 2022-07-11 + +### Changed + +- **Home Assistant OS VM** + - Supports lvmthin, zfspool, nfs, dir and btrfs storage types. + +## 2022-07-08 + +### Changed + +- **openHAB LXC** + - NEW Script + +## 2022-07-03 + +### Changed + +- **Tailscale** + - NEW Script + +## 2022-07-01 + +### Changed + +- **Home Assistant OS VM** + - Allow different storage types (lvmthin, nfs, dir). + +## 2022-06-30 + +### Changed + +- **Prometheus LXC** + - NEW Script + +## 2022-06-06 + +### Changed + +- **Whoogle LXC** + - NEW Script + +## 2022-05-29 + +### Changed + +- **Vaultwarden LXC** + - Code refactoring +- **CrowdSec** + - NEW Script + +## 2022-05-21 + +### Changed + +- **Home Assistant OS VM** + - Code refactoring + +## 2022-05-19 + +### Changed + +- **Keycloak LXC** + - NEW Script + +## 2022-05-18 + +### Changed + +- **File Browser** + - NEW Script + +## 2022-05-13 + +### Changed + +- **PostgreSQL LXC** + - NEW Script + +## 2022-05-10 + +### Changed + +- **deCONZ LXC** + - NEW Script + +## 2022-05-07 + +### Changed + +- **NocoDB LXC** + - ADD update script + +## 2022-05-06 + +### Changed + +- **PhotoPrism LXC** + - ADD GO Dependencies for full functionality + +## 2022-05-05 + +### Changed + +- **Ubuntu LXC** + - ADD option to define version (18.04 20.04 21.10 22.04) + +## 2022-04-28 + +### Changed + +- **v3 Script** + - Remove Internet Check + +## 2022-04-27 + +### Changed + +- **Home Assistant OS VM** + - ADD Option to set Bridge, VLAN and MAC Address +- **v3 Script** + - Improve Internet Check (prevent ‼ ERROR 4@57) + +## 2022-04-26 + +### Changed + +- **Home Assistant OS VM** + - Fixed bad path + - ADD Option to create VM using Latest or Stable image +- **UniFi Network Application LXC** + - ADD Local Controller Option + +## 2022-04-25 + +### Changed + +- **v3 Script** + - Improve Error Handling + +## 2022-04-23 + +### Changed + +- **v3 Script** + - ADD Internet Connection Check +- **Proxmox VE 7 Post Install** + - NEW v3 Script +- **Proxmox Kernel Clean** + - NEW v3 Script + +## 2022-04-22 + +### Changed + +- **Omada Controller LXC** + - Update script to install version 5.1.7 +- **Uptime Kuma LXC** + - ADD Update script + +## 2022-04-20 + +### Changed + +- **Ubuntu LXC** + - ADD option to install version 20.04 or 21.10 +- **v3 Script** + - ADD option to set Bridge + +## 2022-04-19 + +### Changed + +- **ALL LXC's** + - New [V3 Install Script](https://github.com/tteck/Proxmox/issues/162) +- **ioBroker LXC** + - New Script V3 + +## 2022-04-13 + +### Changed + +- **Uptime Kuma LXC** + - New Script V2 + +## 2022-04-11 + +### Changed + +- **Proxmox LXC Updater** + - ADD option to skip stopped containers +- **Proxmox VE 7 Post Install** + - ADD PVE 7 check + +## 2022-04-10 + +### Changed + +- **Debian 11 LXC** + - ADD An early look at the v3 install script + +## 2022-04-09 + +### Changed + +- **NocoDB LXC** + - New Script V2 + +## 2022-04-05 + +### Changed + +- **MeshCentral LXC** + - New Script V2 + +## 2022-04-01 + +### Changed + +- **Scripts** (V2) + - FIX Pressing enter without making a selection first would cause an Error + +## 2022-03-28 + +### Changed + +- **Docker LXC** + - Add Docker Compose Option (@wovalle) + +## 2022-03-27 + +### Changed + +- **Heimdall Dashboard LXC** + - New Update Script + +## 2022-03-26 + +### Changed + +- **UniFi Network Application LXC** + - New Script V2 +- **Omada Controller LXC** + - New Script V2 + +## 2022-03-25 + +### Changed + +- **Proxmox CPU Scaling Governor** + - New Script + + +## 2022-03-24 + +### Changed + +- **Plex Media Server LXC** + - Switch to Ubuntu 20.04 to support HDR tone mapping +- **Docker LXC** + - Add Portainer Option + +## 2022-03-23 + +### Changed + +- **Heimdall Dashboard LXC** + - New Script V2 + +## 2022-03-20 + +### Changed + +- **Scripts** (V2) + - ADD choose between Automatic or Manual DHCP + +## 2022-03-18 + +### Changed + +- **Technitium DNS LXC** + - New Script V2 +- **WireGuard LXC** + - Add WGDashboard + +## 2022-03-17 + +### Changed + +- **Docker LXC** + - New Script V2 + +## 2022-03-16 + +### Changed + +- **PhotoPrism LXC** + - New Update/Branch Script + +## 2022-03-15 + +### Changed + +- **Dashy LXC** + - New Update Script + +## 2022-03-14 + +### Changed + +- **Zwavejs2MQTT LXC** + - New Update Script + +## 2022-03-12 + +### Changed + +- **PhotoPrism LXC** + - New Script V2 + +## 2022-03-11 + +### Changed + +- **Vaultwarden LXC** + - New V2 Install Script + +## 2022-03-08 + +### Changed + +- **Scripts** (V2) + - Choose between Privileged or Unprivileged CT and Automatic or Password Login +- **ESPHome LXC** + - New V2 Install Script +- **Zwavejs2MQTT LXC** + - New V2 Install Script +- **Motioneye LXC** + - New V2 Install Script +- **Pihole LXC** + - New V2 Install Script +- **GamUntu LXC** + - New V2 Install Script + +## 2022-03-06 + +### Changed + +- **Zwavejs2MQTT LXC** + - New GUI script to copy data from one Zwavejs2MQTT LXC to another Zwavejs2MQTT LXC + +## 2022-03-05 + +### Changed + +- **Homebridge LXC** + - New Script V2 + +## 2022-03-04 + +### Changed + +- **Proxmox Kernel Clean** + - New Script + +## 2022-03-03 + +### Changed + +- **WireGuard LXC** + - New Script V2 + +## 2022-03-02 + +### Changed + +- **Proxmox LXC Updater** + - New Script +- **Dashy LXC** + - New Script V2 +- **Grafana LXC** + - New Script V2 +- **InfluxDB/Telegraf LXC** + - New Script V2 + +## 2022-03-01 + +### Changed + +- **Daemon Sync Server LXC** + - New Script V2 + +## 2022-02-28 + +### Changed + +- **Vaultwarden LXC** + - Add Update Script + +## 2022-02-24 + +### Changed + +- **Nginx Proxy Manager LXC** + - New V2 Install Script + +## 2022-02-23 + +### Changed + +- **Adguard Home LXC** + - New V2 Install Script +- **Zigbee2MQTT LXC** + - New V2 Install Script +- **Home Assistant Container LXC** + - Update Menu usability improvements + +## 2022-02-22 + +### Changed + +- **Home Assistant Container LXC** + - New V2 Install Script +- **Node-Red LXC** + - New V2 Install Script +- **Mariadb LXC** + - New V2 Install Script +- **MQTT LXC** + - New V2 Install Script +- **Debian 11 LXC** + - New V2 Install Script +- **Ubuntu 21.10 LXC** + - New V2 Install Script + +## 2022-02-20 + +### Changed + +- **Home Assistant Container LXC** + - New Script to migrate to the latest Update Menu + +## 2022-02-19 + +### Changed + +- **Nginx Proxy Manager LXC** + - Add Update Script +- **Vaultwarden LXC** + - Make unattended install & Cleanup Script + +## 2022-02-18 + +### Changed + +- **Node-Red LXC** + - Add Install [Themes Script](https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/node-red-themes.png) + +## 2022-02-16 + +### Changed + +- **Home Assistant Container LXC** + - Add Options to [Update Menu](https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/update-menu.png) + +## 2022-02-14 + +### Changed + +- **Home Assistant Container LXC** + - Add [Update Menu](https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/update-menu.png) + +## 2022-02-13 + +### Changed + +- **Mariadb LXC** + - Add [Adminer](https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/adminer.png) (formerly phpMinAdmin), a full-featured database management tool + +## 2022-02-12 + +### Changed + +- **Home Assistant Container LXC (Podman)** + - Add Yacht web interface for managing Podman containers + - new GUI script to copy data from a **Home Assistant LXC** to a **Podman Home Assistant LXC** + - Improve documentation for several LXC's + +## 2022-02-10 + +### Changed + +- **GamUntu LXC** + - New Script +- **Jellyfin Media Server LXC** + - new script to fix [start issue](https://github.com/tteck/Proxmox/issues/29#issue-1127457380) +- **MotionEye NVR LXC** + - New script + +## 2022-02-09 + +### Changed + +- **Zigbee2MQTT LXC** + - added USB passthrough during installation (no extra script) + - Improve documentation +- **Zwavejs2MQTT LXC** + - added USB passthrough during installation (no extra script) +- **Jellyfin Media Server LXC** + - Moved to testing due to issues. + - Changed install method. +- **Home Assistant Container LXC (Podman)** + - add script for easy Home Assistant update + +## 2022-02-06 + +### Changed + +- **Debian 11 LXC** + - Add Docker Support +- **Ubuntu 21.10 LXC** + - Add Docker Support + +## 2022-02-05 + +### Changed + +- **Vaultwarden LXC** + - New script + +## 2022-02-01 + +### Changed + +- **All Scripts** + - Fix issue where some networks were slow to assign a IP address to the container causing scripts to fail. + +## 2022-01-30 + +### Changed + +- **Zigbee2MQTT LXC** + - Clean up / Improve script + - Improve documentation + +## 2022-01-29 + +### Changed + +- **Node-Red LXC** + - Clean up / Improve script + - Improve documentation + +## 2022-01-25 + +### Changed + +- **Jellyfin Media Server LXC** + - new script + +## 2022-01-24 + +### Changed + +- **Plex Media Server LXC** + - better Hardware Acceleration Support + - `va-driver-all` is preinstalled + - now using Ubuntu 21.10 +- **misc** + - new GUI script [(Screenshot)](https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/pms-copy-data.png) to copy data from one Plex Media Server LXC to another Plex Media Server LXC + + +## Initial Catch up - 2022-01-23 + +### Changed + +- **Plex Media Server LXC** + - add Hardware Acceleration Support + - add script to install Intel Drivers +- **Zwavejs2MQTT LXC** + - new script to solve no auto start at boot +- **Nginx Proxy Manager LXC** + - new script to use Debian 11 +- **Ubuntu 21.10 LXC** + - new script +- **Mariadb LXC** + - add MariaDB Package Repository +- **MQTT LXC** + - add Eclipse Mosquitto Package Repository +- **Home Assistant Container LXC** + - change if ZFS filesystem is detected, execute automatic installation of static fuse-overlayfs + - add script for easy Home Assistant update +- **Home Assistant Container LXC (Podman)** + - change if ZFS filesystem is detected, execute automatic installation of static fuse-overlayfs +- **Home Assistant OS VM** + - change disk type from SATA to SCSI to follow Proxmox official recommendations of choosing VirtIO-SCSI with SCSI disk + - clean up +- **Proxmox VE 7 Post Install** + - new *No-Nag* method +- **misc** + - new GUI script to copy data from one Home Assistant LXC to another Home Assistant LXC + - new GUI script to copy data from one Zigbee2MQTT LXC to another Zigbee2MQTT LXC diff --git a/CODE-AUDIT.md b/CODE-AUDIT.md new file mode 100644 index 00000000..46db7c9c --- /dev/null +++ b/CODE-AUDIT.md @@ -0,0 +1,14 @@ +<div align="center"> +<img src="https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/logo.png" height="100px" /> +</div> +<h2><div align="center">Exploring the Scripts and Steps Involved in an Application LXC Installation</div></h2> + +1) [adguard.sh](https://github.com/tteck/Proxmox/blob/main/ct/adguard.sh): This script collects system parameters. (Also holds the function to update the application.) +2) [build.func](https://github.com/tteck/Proxmox/blob/main/misc/build.func): Adds user settings and integrates collected information. +3) [create_lxc.sh](https://github.com/tteck/Proxmox/blob/main/ct/create_lxc.sh): Constructs the LXC container. +4) [adguard-install.sh](https://github.com/tteck/Proxmox/blob/main/install/adguard-install.sh): Executes functions from [install.func](https://github.com/tteck/Proxmox/blob/main/misc/install.func), and installs the application. +5) [adguard.sh](https://github.com/tteck/Proxmox/blob/main/ct/adguard.sh) (again): To display the completion message. + +The installation process uses reusable scripts: [build.func](https://github.com/tteck/Proxmox/blob/main/misc/build.func), [create_lxc.sh](https://github.com/tteck/Proxmox/blob/main/ct/create_lxc.sh), and [install.func](https://github.com/tteck/Proxmox/blob/main/misc/install.func), which are not specific to any particular application. + +To gain a better understanding, focus on reviewing [adguard-install.sh](https://github.com/tteck/Proxmox/blob/main/install/adguard-install.sh). This script contains the commands and configurations for installing and configuring AdGuard Home within the LXC container. diff --git a/LICENSE b/LICENSE index b3b9c59c..86316b3f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 tteck +Copyright (c) 2021-2024 tteck Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 777b338d..27957012 100644 --- a/README.md +++ b/README.md @@ -1,2026 +1,27 @@ -<h1 align="center" id="heading"> Select a Proxmox Helper </h1> - -<p align="center"><sub> Always remember to use due diligence when sourcing scripts and automation tasks from third-party sites. </sub></p> - -<a href="https://github.com/tteck/Proxmox/blob/main/LICENSE"><img src="https://badgen.net/github/license/tteck/Proxmox" ></a> <a href="https://tteck.github.io/Proxmox/"><img src="https://badgen.net/github/checks/tteck/Proxmox/main/"></a> <a href="https://github.com/tteck/Proxmox/discussions"><img src="https://github.com/tteck/Proxmox/blob/main/misc/images/discussions.png?raw=true" height="21" /></a> <a href="https://github.com/tteck/Proxmox/blob/main/CHANGELOG.MD"><img src="https://github.com/tteck/Proxmox/blob/main/misc/images/change.png?raw=true" height="21" /></a>🔸 - -<details> -<summary markdown="span"> Proxmox VE 7 Post Install</summary> - -<p align="center"><img src="https://github.com/home-assistant/brands/blob/master/core_integrations/proxmoxve/icon.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> Proxmox VE 7 Post Install </h1> - -The script will give options to Disable the Enterprise Repo, Add/Correct PVE7 Sources, Enable the No-Subscription Repo, Add Test Repo, Disable Subscription Nag and Update Proxmox VE. - -Run the following in the Proxmox Shell. ⚠️ **PVE7 ONLY** - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/post-install-v3.sh)" -``` - -It's recommended to answer `y` to all options. - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Proxmox Kernel Clean</summary> - -<p align="center"><img src="https://github.com/home-assistant/brands/blob/master/core_integrations/proxmoxve/icon.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading">Proxmox Kernel Clean </h1> - -Cleaning unused kernel images is not only good because of a reduced grub menu, but also gains some disk space. - -Run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/kernel-clean-v3.sh)" -``` -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Proxmox Edge Kernel Tool</summary> - -<p align="center"><img src="https://github.com/home-assistant/brands/blob/master/core_integrations/proxmoxve/icon.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading">Proxmox Edge Kernel Tool </h1> - -Proxmox [Edge Kernels](https://github.com/fabianishere/pve-edge-kernel) are custom Linux Kernels for Proxmox VE 7. Keeping up with new Kernel releases instead of LTS - -Run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/edge-kernel.sh)" -``` -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Proxmox CPU Scaling Governor</summary> - -<p align="center"><img src="https://github.com/tteck/Proxmox/blob/main/misc/images/cpu.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading">Proxmox CPU Scaling Governor </h1> - -CPU Scaling Governor enables the operating system to scale the CPU frequency up or down in order to save power or improve performance. - -[Generic Scaling Governors](https://www.kernel.org/doc/html/latest/admin-guide/pm/cpufreq.html?#generic-scaling-governors) - -Run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/scaling-governor.sh)" -``` -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Proxmox LXC Updater</summary> - -<p align="center"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Felpuig.xeill.net%2FMembers%2Fvcarceler%2Farticulos%2Fcontenedores-con-lxd-lxc%2Fcontainers.png&f=1&nofb=1" height="100"/></p> - -<h1 align="center" id="heading">Proxmox LXC Updater </h1> - -Update All LXC's Fast & Easy - -Run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/update-lxcs.sh)" -``` -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Proxmox Dark Theme</summary> - -<p align="center"><img src="https://camo.githubusercontent.com/f6f33a09f8c1207dfb3dc1cbd754c2f3393562c11b1c999751ad9a91a656834a/68747470733a2f2f692e696d6775722e636f6d2f536e6c437948462e706e67" height="100"/></p> - -<h1 align="center" id="heading"> Proxmox Discord Dark Theme </h1> - -A dark theme for the Proxmox Web UI by [Weilbyte](https://github.com/Weilbyte/PVEDiscordDark) - -Run the following in the Proxmox Shell. - -```yaml -bash <(curl -s https://raw.githubusercontent.com/Weilbyte/PVEDiscordDark/master/PVEDiscordDark.sh ) install -``` - -To uninstall the theme, simply run the script with the `uninstall` command. - -____________________________________________________________________________________________ - -</details> - - -<details> -<summary markdown="span"> Home Assistant OS VM</summary> - -<p align="center"><img src="https://github.com/tteck/Proxmox/blob/main/misc/images/haos.png?raw=true"/></p> - -<h1 align="center" id="heading"> Home Assistant OS VM </h1> -<h3 align="center"> Option to create VM using the Latest or Stable Image </h3> - -The script automates the manual process of finding, downloading and extracting the Official KVM (qcow2) disk image provided by the Home Assistant Team, creating a VM with user defined settings, importing and attaching the disk, setting the boot order and starting the VM. No hidden (kpartx, unzip, ect...) installs of any kind. Supports lvmthin, zfspool, nfs, dir and btrfs storage types. - -To create a new Proxmox Home Assistant OS VM, run the following in the Proxmox Shell - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/vm/haos-vm-v3.sh)" -``` -<h3 align="center" id="heading">⚡ Default Settings: 4GB RAM - 32GB Storage - 2vCPU - Stable Image⚡</h3> - -After the script completes, click on the VM, then on the **_Summary_** tab to find the VM IP. - -**Home Assistant Interface - IP:8123** - -____________________________________________________________________________________________ - -</details> - - -<details> -<summary markdown="span"> Home Assistant Container LXC </summary> - -<p align="center"><img src="https://www.docker.com/sites/default/files/d8/2019-07/vertical-logo-monochromatic.png" alt="Docker Logos | Docker" width="100" height="100"/> -<img src="https://avatars.githubusercontent.com/u/13844975?s=200&v=4" alt="@home-assistant" width="100" height="100"/><img src="https://avatars1.githubusercontent.com/u/22225832?s=400&v=4" alt="GitHub - portainer/portainer-docs: Portainer documentation" width="100" height="100"/></p> - -<h1 align="center" id="heading"> Home Assistant Container LXC </h1> - -A standalone container-based installation of Home Assistant Core - -To create a new Proxmox Home Assistant Container LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/homeassistant-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 2GB RAM - 16GB Storage - 2vCPU ⚡</h3> - -**Home Assistant Interface - IP:8123** - -**Portainer Interface - IP:9000** - -⚙️ **Path to HA /config** -```yaml -/var/lib/docker/volumes/hass_config/_data - ``` -⚙️ **To Edit the HA configuration.yaml** (Recommend Using File Browser) - -Run in the LXC console -```yaml -nano /var/lib/docker/volumes/hass_config/_data/configuration.yaml -``` -Save and exit the editor with “Ctrl+O”, “Enter” and “Ctrl+X” - -⚙️ **Copy Data From a Existing Home Assistant LXC to another Home Assistant LXC** - -Run in the Proxmox Shell -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/ha-copy-data.sh)" - ``` - -⚙️ **To Allow USB Device Passthrough:** - -Run in the Proxmox Shell. (**replace `106` with your LXC ID**) -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/usb-passthrough.sh)" -s 106 -``` - -Reboot the LXC to apply the changes - - -⚙️ **To Install HACS:** - -Run in the LXC console -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/hacs.sh)" -``` -After install, reboot Home Assistant and **clear browser cache** then Add HACS integration. - - -⚙️ [**Update Menu**](https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/update-menu.png) - -Run in the LXC console -```yaml -./update -``` -____________________________________________________________________________________________ -</details> - -<details> -<summary markdown="span"> Podman Home Assistant Container LXC </summary> - -<p align="center"><img src="https://heise.cloudimg.io/width/223/q50.png-lossy-50.webp-lossy-50.foil1/_www-heise-de_/imgs/18/2/5/8/2/8/1/0/podman_logo-670078d7ea1d15a6.png" width="100" height="100"/> -<img src="https://avatars.githubusercontent.com/u/13844975?s=200&v=4" alt="@home-assistant" width="100" height="100"/><img/><img src="https://raw.githubusercontent.com/SelfhostedPro/Yacht/master/readme_media/Yacht_logo_1_dark.png" height="80"/><img/></p> - -<h1 align="center" id="heading"> Podman Home Assistant Container LXC </h1> -A standalone container-based installation of Home Assistant Core - -⚠️ Podman seems to need a privileged LXC - -To create a new Proxmox Podman Home Assistant Container LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/podman-homeassistant-v3.sh)" -``` -<h3 align="center" id="heading">⚡ Default Settings: 2GB RAM - 16GB Storage - 2vCPU ⚡</h3> - -**Home Assistant Interface - IP:8123** - -**Yacht Interface - IP:8000** - -⚙️ **Path to HA /config** -```yaml -/var/lib/containers/storage/volumes/hass_config/_data - ``` -⚙️ **To edit the HA configuration.yaml** - -Run in the LXC console -```yaml -nano /var/lib/containers/storage/volumes/hass_config/_data/configuration.yaml -``` -Save and exit the editor with “Ctrl+O”, “Enter” and “Ctrl+X” - -⚙️ **Copy Data From a Existing Home Assistant LXC to a Podman Home Assistant LXC** - -Run in the Proxmox Shell -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/ha-copy-data-podman.sh)" - ``` - -⚙️ **To allow USB device passthrough:** - -Run in the Proxmox Shell. (**replace `106` with your LXC ID**) -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/usb-passthrough.sh)" -s 106 -``` - -Reboot the LXC to apply the changes - -⚙️ **To Install HACS:** - -Run in the LXC console -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/podman_hacs.sh)" -``` -After install, reboot Home Assistant and **clear browser cache** then Add HACS integration. - -⚙️ **Initial Yacht Login** - -**username** - ```yaml - admin@yacht.local - ``` - **password** - ```yaml - pass - ``` - -____________________________________________________________________________________________ -</details> - -<details> -<summary markdown="span"> ioBroker LXC</summary> - -<p align="center"><img src="https://github.com/ioBroker/ioBroker/blob/master/img/logos/ioBroker_Logo_256px.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> ioBroker LXC </h1> - -[ioBroker](https://www.iobroker.net/#en/intro) is an open source automation platform. - -To create a new Proxmox ioBroker LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/iobroker-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 2GB RAM - 8GB Storage - 2vCPU ⚡</h3> - -**ioBroker Interface - IP:8081** - -⚙️ **To Update ioBroker** - -```yaml -update from the ioBroker UI -``` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> openHAB LXC</summary> - -<p align="center"><img src="https://www.openhab.org/openhab-logo-square.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> openHAB LXC </h1> - -[openHAB](https://www.openhab.org/), a vendor and technology agnostic open source automation software for your home. - -To create a new Proxmox openHAB LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/openhab-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 2GB RAM - 8GB Storage - 2vCPU ⚡</h3> - -**openHAB Interface - IP:8080** - -⚙️ **To Update openHAB** - -```yaml -apt update && apt upgrade -y -``` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Homebridge LXC</summary> - -<p align="center"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.dingz.ch%2Fadmin%2Fdata%2Ffiles%2Fintegration%2Flogo%2F20%2F200514-em-logo-homebridge_logo.png%3Flm%3D1589459081&f=1&nofb=1" height="100"/></p> - -<h1 align="center" id="heading"> Homebridge LXC </h1> - -[Homebridge](https://homebridge.io/) allows you to integrate with smart home devices that do not natively support HomeKit - -To create a new Proxmox Homebridge LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/homebridge-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 1GB RAM - 4GB Storage - 1vCPU ⚡</h3> - -**Homebridge Interface - IP:8581** - -⚙️ **Initial Login** - -**username** - ```yaml - admin - ``` - **password** - ```yaml - admin - ``` -Config File Path `/var/lib/homebridge/config.json` - -Storage Path `/var/lib/homebridge` - -Restart Command `sudo hb-service restart` - -Stop Command `sudo hb-service stop` - -Start Command `sudo hb-service start` - -View Logs Command `sudo hb-service logs` - -Systemd Service File `/etc/systemd/system/homebridge.service` - -Systemd Env File `/etc/default/homebridge` - -⚙️ **To Update Homebridge** - -```yaml -Update from the Homebridge UI -``` - - ___________________________________________________________________________________________ - -</details> - - - -<details> -<summary markdown="span"> ESPHome LXC</summary> - -<p align="center"><img src="https://github.com/home-assistant/brands/blob/master/core_integrations/esphome/dark_icon@2x.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> ESPHome LXC </h1> - -[ESPHome](https://esphome.io/) is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems. - -To create a new Proxmox ESPHome LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/esphome-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 1GB RAM - 4GB Storage - 2vCPU ⚡</h3> - -**ESPHome Interface - IP:6052** - -⚙️ **To Update ESPHome** - -Run in the LXC console -```yaml -pip3 install esphome --upgrade -``` - -____________________________________________________________________________________________ - -</details> - - - -<details> -<summary markdown="span"> Nginx Proxy Manager LXC </summary> - -<p align="center"><img src="https://nginxproxymanager.com/logo.png" alt="hero" height="100"/></p> - - -<h1 align="center" id="heading"> Nginx Proxy Manager LXC </h1> - -[Nginx Proxy Manager](https://nginxproxymanager.com/) Expose your services easily and securely - -To create a new Proxmox Nginx Proxy Manager LXC Container, run the following in the Proxmox Shell. - -```yaml - bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/nginx-proxy-manager-v3.sh)" -``` -<h3 align="center" id="heading">⚡ Default Settings: 1GB RAM - 3GB Storage - 1vCPU ⚡</h3> - -____________________________________________________________________________________ - -Forward port `80` and `443` from your router to your Nginx Proxy Manager LXC IP. - -Add the following to your `configuration.yaml` in Home Assistant. -```yaml - http: - use_x_forwarded_for: true - trusted_proxies: - - 192.168.100.27 ###(Nginx Proxy Manager LXC IP)### -``` - -**Nginx Proxy Manager Interface - IP:81** - -⚙️ **Initial Login** - -**username** - ```yaml - admin@example.com - ``` - **password** - ```yaml - changeme - ``` -⚙️ **To Update Nginx Proxy Manager** - -Run in the LXC console -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/npm_update.sh)" -``` - - ____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> MQTT LXC</summary> - -<p align="center"><img src="https://mosquitto.org/images/mosquitto-text-side-28.png" height="75"/></p> - -<h1 align="center" id="heading"> MQTT LXC </h1> - -[Eclipse Mosquitto](https://mosquitto.org/) is an open source message broker that implements the MQTT protocol - -To create a new Proxmox MQTT LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/mqtt-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 512MiB RAM - 2GB Storage - 1vCPU ⚡</h3> - -Mosquitto comes with a password file generating utility called mosquitto_passwd. -```yaml -sudo mosquitto_passwd -c /etc/mosquitto/passwd <usr> -``` -Password: < password > - -Create a configuration file for Mosquitto pointing to the password file we have just created. -```yaml -sudo nano /etc/mosquitto/conf.d/default.conf -``` -This will open an empty file. Paste the following into it. -```yaml -allow_anonymous false -persistence true -password_file /etc/mosquitto/passwd -listener 1883 -``` -Save and exit the text editor with "Ctrl+O", "Enter" and "Ctrl+X". - -Now restart Mosquitto server. -```yaml -sudo systemctl restart mosquitto -``` - -⚙️ **To Update MQTT:** - -Run in the LXC console -```yaml -apt update && apt upgrade -y -``` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Node-Red LXC </summary> - -<p align="center"><img src="https://github.com/home-assistant/brands/blob/master/custom_integrations/nodered/icon.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> Node-Red LXC </h1> - -[Node-RED](https://nodered.org/) is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. - -To create a new Proxmox Node-RED LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/node-red-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 1GB RAM - 4GB Storage - 1vCPU ⚡</h3> - -**Node-Red Interface - IP:1880** - -⚙️ **To Restart Node-Red:** - -Run in the LXC console -```yaml -node-red-restart -``` - -⚙️ **To Update Node-Red:** - -Run in the LXC console (Restart after update) -```yaml -npm install -g --unsafe-perm node-red -``` - -⚙️ **To Install Node-Red Themes** ⚠️ **Backup your flows before running this script!!** - -Run in the LXC console -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/node-red-themes.sh)" -``` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> 🔸n8n LXC</summary> - -<p align="center"><img src="https://docs.n8n.io/_images/n8n-docs-icon.svg" height="100"/></p> - -<h1 align="center" id="heading"> n8n LXC </h1> - -[n8n](https://n8n.io/) is a workflow automation platform that doesn't box you in, that you never outgrow - -To create a new Proxmox n8n LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/n8n-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 2GB RAM - 3GB Storage - 2vCPU ⚡</h3> - -**n8n Interface: IP:5678** - -⚙️ **To Update n8n** - -```yaml -npm update -g n8n -``` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Mariadb LXC </summary> - -<p align="center"><img src="https://mariadb.com/wp-content/webp-express/webp-images/doc-root/wp-content/themes/sage/dist/images/mariadb-logo-white.png.webp" alt="MariaDB"/><img src="https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/adminer_logo-cl.png" height="60"></p> - -<h1 align="center" id="heading"> Mariadb LXC </h1> - -[MariaDB](https://mariadb.org/) is a community-developed, commercially supported fork of the MySQL relational database management system. - -To create a new Proxmox Mariadb LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/mariadb-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 1GB RAM - 4GB Storage - 1vCPU ⚡</h3> - -To enable MariaDB to listen to remote connections, you need to edit your defaults file. To do this, open the console in your MariaDB lxc: -```yaml -nano /etc/mysql/my.cnf -``` -Un-comment `port =3306` -Save and exit the editor with "Ctrl+O", "Enter" and "Ctrl+X". - -```yaml -nano /etc/mysql/mariadb.conf.d/50-server.cnf -``` -Comment `bind-address = 127.0.0.1` -Save and exit the editor with "Ctrl+O", "Enter" and "Ctrl+X". - -For new MariaDB installations, the next step is to run the included security script. This script changes some of the less secure default options. We will use it to block remote root logins and to remove unused database users. - -Run the security script: -```yaml -sudo mysql_secure_installation -``` -Enter current password for root (enter for none): `enter` - -Switch to unix_socket authentication [Y/n] `y` - -Change the root password? [Y/n] `n` - -Remove anonymous users? [Y/n] `y` - -Disallow root login remotely? [Y/n] `y` - -Remove test database and access to it? [Y/n] `y` - -Reload privilege tables now? [Y/n] `y` - -We will create a new account called admin with the same capabilities as the root account, but configured for password authentication. -```yaml -sudo mysql -``` -Prompt will change to ```MariaDB [(none)]>``` - -Create a new local admin (Change the username and password to match your preferences) -```yaml -CREATE USER 'admin'@'localhost' IDENTIFIED BY 'password'; -``` -Give local admin root privileges (Change the username and password to match above) -```yaml -GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION; -``` - -Now, we'll give the user admin root privileges and password-based access that can connect from anywhere on your local area network (LAN), which has addresses in the subnet 192.168.100.0/24. This is an improvement because opening a MariaDB server up to the Internet and granting access to all hosts is bad practice.. Change the **_username_**, **_password_** and **_subnet_** to match your preferences: -```yaml -GRANT ALL ON *.* TO 'admin'@'192.168.100.%' IDENTIFIED BY 'password' WITH GRANT OPTION; -``` -Flush the privileges to ensure that they are saved and available in the current session: -```yaml -FLUSH PRIVILEGES; -``` -Following this, exit the MariaDB shell: -```yaml -exit -``` -Log in as the new database user you just created: -```yaml -mysql -u admin -p -``` -Create a new database: -```yaml -CREATE DATABASE homeassistant; -``` -Following this, exit the MariaDB shell: -```yaml -exit -``` -⚠️ Reboot the lxc - -Checking status. -```yaml -sudo systemctl status mariadb -``` -Change the recorder: `db_url:` in your HA configuration.yaml - -Example: -```yaml -recorder: - db_url: mysql://admin:password@192.168.100.26:3306/homeassistant?charset=utf8mb4 -``` - -⚙️ **To Update Mariadb:** - -Run in the LXC console -```yaml -apt update && apt upgrade -y -``` -⚙️ [**Adminer**](https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/adminer.png) (formerly phpMinAdmin) is a full-featured database management tool - - `http://your-mariadb-lxc-ip/adminer/` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> PostgreSQL LXC </summary> - -<p align="center"><img src="https://wiki.postgresql.org/images/3/30/PostgreSQL_logo.3colors.120x120.png" height="100"/><img src="https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/adminer_logo-cl.png" height="60"></p> - -<h1 align="center" id="heading"> PostgreSQL LXC </h1> - -[PostgreSQL](https://www.postgresql.org/), also known as Postgres, is a free and open-source relational database management system emphasizing extensibility and SQL compliance. - -To create a new Proxmox PostgreSQL LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/postgresql-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 1GB RAM - 4GB Storage - 1vCPU ⚡</h3> - -To make sure our PostgreSQL is secured with a strong password, set a password for its system user and then change the default database admin user account - -Change user password -```yaml -passwd postgres -``` -Login using Postgres system account - -```yaml -su - postgres -``` -Now, change the Admin database password -```yaml -psql -c "ALTER USER postgres WITH PASSWORD 'your-password';" -``` -Create a new user. -```yaml -psql -``` -```yaml -CREATE USER admin WITH PASSWORD 'your-password'; -``` -Create a new database: -```yaml -CREATE DATABASE homeassistant; -``` -Grant all rights or privileges on created database to the user -```yaml -GRANT ALL ON DATABASE homeassistant TO admin; -``` -To exit psql -```yaml -\q -``` -Then type exit to get back to root - -Change the recorder: `db_url:` in your HA configuration.yaml - -Example: -```yaml -recorder: - db_url: postgresql://admin:your-password@192.168.100.20:5432/homeassistant?client_encoding=utf8 -``` -⚙️ **To Update PostgreSQL** - -Run in the LXC console -```yaml -apt update && apt upgrade -y -``` -⚙️ [**Adminer**](https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/adminer.png) (formerly phpMinAdmin) is a full-featured database management tool - - `http://your-PostgreSQL-lxc-ip/adminer/` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Zigbee2MQTT LXC </summary> - -<p align="center"><img src="https://github.com/Koenkk/zigbee2mqtt/blob/master/images/logo_bee_only.png?raw=true" height="100"/></p> - - -<h1 align="center" id="heading">Zigbee2MQTT LXC </h1> - -[Zigbee2MQTT](https://www.zigbee2mqtt.io/) is a standalone nodejs application that connects a zigbee network to MQTT - -To create a new Proxmox Zigbee2MQTT LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/zigbee2mqtt-v3.sh)" -``` -<h3 align="center" id="heading">⚡ Default Settings: 1GB RAM - 4GB Storage - 2vCPU ⚡</h3> - - -⚙️ **Determine the location of your adapter** - -Run in the LXC console -```yaml -ls -l /dev/serial/by-id -``` -Example Output: ```lrwxrwxrwx 1 root root 13 Jun 19 17:30 usb-1a86_USB_Serial-if00-port0 -> ../../ttyUSB0``` - - -⚙️ ⚠️ **Before you start Zigbee2MQTT you need to edit the [configuration.yaml](https://www.zigbee2mqtt.io/guide/configuration/)** - -Run in the LXC console -```yaml -nano /opt/zigbee2mqtt/data/configuration.yaml -``` - -Save and exit the editor with “Ctrl+O”, “Enter” and “Ctrl+X” - -Example: -```yaml -frontend: - port: 9442 -homeassistant: true -permit_join: false -mqtt: - base_topic: zigbee2mqtt - server: 'mqtt://192.168.86.224:1883' - user: usr - password: pwd - keepalive: 60 - reject_unauthorized: true - version: 4 -serial: - port: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 - #adapter: deconz #(uncomment for ConBee II) -advanced: - pan_id: GENERATE - network_key: GENERATE - channel: 20 -``` -⚙️ **Zigbee2MQTT can be started after completing the configuration** - -Run in the LXC console -```yaml -cd /opt/zigbee2mqtt -npm start -``` -⚙️ **To update Zigbee2MQTT** - -Run in the LXC console - ```yaml -cd /opt/zigbee2mqtt && bash update.sh - ``` -⚙️ **Copy Data From a Existing Zigbee2MQTT LXC to another Zigbee2MQTT LXC** - -Run in the Proxmox Shell -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/z2m-copy-data.sh)" - ``` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> deCONZ LXC </summary> - -<p align="center"><img src="https://phoscon.de/img/phoscon-logo128x.svg" height="100"/></p> - -<h1 align="center" id="heading"> deCONZ LXC </h1> - -[deCONZ](https://www.phoscon.de/en/conbee2/software#deconz) is used to configure, control and display Zigbee networks. - -To create a new Proxmox deCONZ LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/deconz-v3.sh)" -``` -<h3 align="center" id="heading">⚡ Default Settings: 1GB RAM - 4GB Storage - 2vCPU ⚡</h3> - -**deCONZ Interface - IP:80** - -⚙️ **To Update deCONZ** - -Run in the LXC Console -```yaml -apt update && apt upgrade -y -``` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Zwavejs2MQTT LXC </summary> - -<p align="center"><img src="https://github.com/zwave-js/zwavejs2mqtt/raw/master/docs/_images/zwavejs_logo.svg" height="100"/></p> - -<h1 align="center" id="heading"> Zwavejs2MQTT LXC </h1> - -[Zwavejs2MQTT](https://zwave-js.github.io/zwavejs2mqtt/#/) is a fully configurable Z-Wave to MQTT Gateway and Control Panel. - -To create a new Proxmox Zwavejs2MQTT LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/zwavejs2mqtt-v3.sh)" -``` -<h3 align="center" id="heading">⚡ Default Settings: 1GB RAM - 4GB Storage - 2vCPU ⚡</h3> - -**Zwavejs2MQTT Interface - IP:8091** - -⚙️ **Copy Data From a Existing Zwavejs2MQTT LXC to another Zwavejs2MQTT LXC** - -Run in the Proxmox Shell -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/zwave-copy-data.sh)" - ``` -⚙️ **To Update Zwavejs2MQTT** - -Run in the LXC Console -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/zwavejs2mqtt-update.sh)" -``` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> NocoDB LXC </summary> - -<p align="center"><img src="https://github.com/tteck/Proxmox/blob/main/misc/images/nocodb.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> NocoDB LXC </h1> - -[NocoDB](https://www.nocodb.com/) is an open source #NoCode platform that turns any database into a smart spreadsheet. Airtable Alternative. - -To create a new Proxmox NocoDB LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/nocodb-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 1GB RAM - 4GB Storage - 1vCPU ⚡</h3> - -**NocoDB Interface - IP:8080/dashboard** - -⚙️ **To Update NocoDB** - -Run in the LXC console -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/nocodb-update.sh)" -``` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Prometheus LXC </summary> - -<p align="center"><img src="https://github.com/tteck/Proxmox/blob/main/misc/images/prome.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> Prometheus LXC </h1> - -[Prometheus](https://prometheus.io/) is an open-source systems monitoring and alerting toolkit - -To create a new Proxmox Prometheus LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/prometheus-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 2GB RAM - 4GB Storage - 1vCPU ⚡</h3> - -**Prometheus Interface - IP:9090** - -⚙️ **To Update Prometheus** - -```yaml -Working On -``` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> InfluxDB/Telegraf LXC </summary> - -<p align="center"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.hopisystems.com%2Fassets%2Fimages%2Fintegrations%2Finfluxdb.png&f=1&nofb=1" height="150"/></p> - -<h1 align="center" id="heading"> InfluxDB/Telegraf LXC </h1> - -[InfluxDB](https://www.influxdata.com/) is an open-source time series database developed by the company InfluxData. - -[Telegraf](https://www.influxdata.com/time-series-platform/telegraf/) is an open source plugin-driven server agent for collecting and reporting metrics. - -To create a new Proxmox InfluxDB LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/influxdb-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 2GB RAM - 8GB Storage - 2vCPU ⚡</h3> - -⚙️ **InfluxDB Configuration** - -Run in the LXC console -```yaml -nano /etc/influxdb/influxdb.conf -``` - -⚙️ **Telegraf Configuration** - -Run in the LXC console -```yaml -nano /etc/telegraf/telegraf.conf -``` - -⚙️ **To Update InfluxDB/Telegraf** - -Run in the LXC console -```yaml -apt update && apt upgrade -y -``` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Grafana LXC </summary> - -<p align="center"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fdocs.checkmk.com%2Flatest%2Fimages%2Fgrafana_logo.png&f=1&nofb=1" height="100"/></p> - -<h1 align="center" id="heading"> Grafana LXC </h1> - -[Grafana](https://grafana.com/) is a multi-platform open source analytics and interactive visualization web application. - -To create a new Proxmox Grafana LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/grafana-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 512MiB RAM - 2GB Storage - 1vCPU ⚡</h3> - -**Grafana Interface - IP:3000** - -⚙️ **Initial Login** - -**username** - ```yaml - admin - ``` - **password** - ```yaml - admin - ``` - -⚙️ **To Update Grafana** - -Run in the LXC console -```yaml -apt update && apt upgrade -y -``` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Docker LXC </summary> - -<p align="center"><img src="https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/docker.png" height="100"/></p> - -<h1 align="center" id="heading"> Docker LXC </h1> -<h3 align="center"> Options to Install Portainer and/or Docker Compose V2</h3> - -[Docker](https://www.docker.com/) is an open-source project for automating the deployment of applications as portable, self-sufficient containers. - -To create a new Proxmox Docker LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/docker-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 2GB RAM - 4GB Storage - 2vCPU ⚡</h3> - -**⚠ Run Compose V2 by replacing the hyphen (-) with a space, using docker compose, instead of docker-compose.** - -**Portainer Interface - IP:9000** - -⚙️ **To Update** - -Run in the LXC console -```yaml -apt update && apt upgrade -y -``` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Debian 11 LXC </summary> - -<p align="center"><img src="https://www.debian.org/Pics/debian-logo-1024x576.png" alt="Debian" height="100"/></p> - -<h1 align="center" id="heading"> Debian 11 LXC </h1> - -To create a new Proxmox Debian 11 (curl. sudo) LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/debian-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 512MiB RAM - 2GB Storage - 1vCPU ⚡</h3> - -⚙️ **To Update Debian 11** - -Run in the LXC console -```yaml -apt update && apt upgrade -y -``` - -____________________________________________________________________________________________ - -</details> - - -<details> -<summary markdown="span"> Ubuntu LXC </summary> - -<p align="center"><img src="https://assets.ubuntu.com/v1/29985a98-ubuntu-logo32.png" alt="Ubuntu" height="100"/></p> - -<h1 align="center" id="heading"> Ubuntu LXC </h1> -<h3 align="center" id="heading"> Option to define version 18.04, 20.04, 21.10 or 22.04</h3> - -To create a new Proxmox Ubuntu (curl. sudo) LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/ubuntu-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 512MiB RAM - 2GB Storage - 1vCPU - 22.04 ⚡</h3> - -⚙️ **To Update Ubuntu** - -Run in the LXC console -```yaml -apt update && apt upgrade -y -``` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> UniFi Network Application LXC</summary> - -<p align="center"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fblog.ui.com%2Fwp-content%2Fuploads%2F2016%2F10%2Funifi-app-logo-300x108.png&f=1&nofb=1" height="100"/></p> - -<h1 align="center" id="heading"> UniFi Network Application LXC </h1> - -<h3 align="center"> With Local Controller Option </h3> - -An application designed to optimize UniFi home and business networks with ease. - -To create a new Proxmox UniFi Network Application LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/unifi-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 2GB RAM - 8GB Storage - 2vCPU ⚡</h3> - -**UniFi Interface - https:// IP:8443** - -⚙️ **To Update UniFi** - -Run in the LXC console -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/unifi-update.sh)" -``` -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Omada Controller LXC</summary> - -<p align="center"><img src="https://www.enterpriseitpro.net/wp-content/uploads/2020/12/logo-omada.png" height="100"/></p> - -<h1 align="center" id="heading"> Omada Controller LXC </h1> - -Omada Controller is software which is used to manage the EAP - -To create a new Proxmox Omada Controller LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/omada-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 2GB RAM - 8GB Storage - 2vCPU ⚡</h3> - -**Omada Interface - https:// IP:8043** - -`tpeap status` show status of Omada Controller - -`tpeap start` start Omada Controller - -`tpeap stop` stop Omada Controller - -⚙️ **To Update Omada** - -```yaml -Working On -``` -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> MeshCentral LXC</summary> - -<p align="center"><img src="https://github.com/Ylianst/MeshCentral/blob/master/public/favicon-303x303.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> MeshCentral LXC </h1> - -MeshCentral is a full computer management web site. With MeshCentral, you can run your own web server to remotely manage and control computers on a local network or anywhere on the internet. - -To create a new Proxmox MeshCentral LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/meshcentral-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 512MiB RAM - 2GB Storage - 1vCPU ⚡</h3> - -**MeshCentral Interface - http:// IP** - -⚙️ **To Update MeshCentral** - -```yaml -Update from the MeshCentral UI -``` -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Plex Media Server LXC </summary> - -<p align="center"><img src="https://github.com/home-assistant/brands/blob/master/core_integrations/plex/icon.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> Plex Media Server LXC </h1> -<h3 align="center" id="heading"> With Hardware Acceleration Support </h3> -To create a new Proxmox Plex Media Server LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/plex-v3.sh)" -``` -<h3 align="center" id="heading">⚡ Default Settings: 2GB RAM - 8GB Storage - 2vCPU ⚡</h3> - -**Plex Media Server Interface - IP:32400/web** - -⚙️ **To Update Plex Media Server:** - -Run in the LXC console -```yaml -apt update && apt upgrade -y -``` -⚙️ **Copy Data From a Existing Plex Media Server LXC to another Plex Media Server LXC** - -Run in the Proxmox Shell -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/pms-copy-data.sh)" - ``` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Jellyfin Media Server LXC </summary> -<p align="center"><img src="https://github.com/home-assistant/brands/blob/master/core_integrations/jellyfin/icon.png?raw=true" height="100"/></p> -<h1 align="center" id="heading"> Jellyfin Media Server LXC </h1> - -[TurnKey has a LXC CT for Jellyfin](https://www.turnkeylinux.org/mediaserver) - -To create a new Proxmox Jellyfin Media Server LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/jellyfin-v3.sh)" -``` -<h3 align="center" id="heading">⚡ Default Settings: 2GB RAM - 8GB Storage - 2vCPU ⚡</h3> - -**Jellyfin Media Server Interface - IP:8096** - -FFmpeg path: `/usr/lib/jellyfin-ffmpeg/ffmpeg` - -⚙️ **To Update Jellyfin Media Server** - -Run in the LXC console -```yaml -apt update && apt upgrade -y -``` -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Pi-hole LXC</summary> - -<p align="center"><img src="https://github.com/home-assistant/brands/blob/master/core_integrations/pi_hole/icon.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> Pi-hole LXC </h1> - -[Pi-hole](https://pi-hole.net/) is a Linux network-level advertisement and Internet tracker blocking application which acts as a DNS sinkhole and optionally a DHCP server. - -To create a new Proxmox Pi-hole LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/pihole-v3.sh)" -``` -<h3 align="center" id="heading">⚡ Default Settings: 512MiB RAM - 2GB Storage - 1vCPU ⚡</h3> - -⚙️ **To set your password:** - -Run in the LXC console - -```yaml -pihole -a -p -``` -⚙️ **To Update Pi-hole:** - -```yaml -Update from the Pi-hole UI -``` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Technitium DNS LXC</summary> - -<p align="center"><img src="https://avatars.githubusercontent.com/u/12230362?s=100&v=4" height="100"/></p> - -<h1 align="center" id="heading"> Technitium DNS LXC </h1> -An open source authoritative as well as recursive DNS server - -To create a new Proxmox Technitium DNS LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/technitiumdns-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 512MiB RAM - 2GB Storage - 1vCPU ⚡</h3> - -**Technitium DNS Interface - IP:5380** - -⚙️ **To Update Technitium DNS** - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/technitiumdns-update.sh)" -``` -__________________________________________________________________________________________ - -</details> - - -<details> -<summary markdown="span"> AdGuard Home LXC</summary> - -<p align="center"><img src="https://github.com/home-assistant/brands/blob/master/core_integrations/adguard/icon.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> AdGuard Home LXC </h1> - -To create a new Proxmox AdGuard Home LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/adguard-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 512MiB RAM - 2GB Storage - 1vCPU ⚡</h3> - -**AdGuard Home Setup Interface - IP:3000 (After Setup use only IP)** - - <sub>(For the Home Assistant Integration, use port `80` not `3000`)</sub> - -⚙️ **To Update Adguard** - -```yaml -Update from the Adguard UI -``` -__________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Uptime Kuma LXC </summary> - -<p align="center"><img src="https://github.com/louislam/uptime-kuma/blob/master/public/icon.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> Uptime Kuma LXC </h1> - -Uptime Kuma is a self-hosted, open source, fancy uptime monitoring and alerting system. It can monitor HTTP(s) / TCP / HTTP(s) Keyword / Ping / DNS Record / Push / Steam Game Server. - -To create a new Proxmox Uptime Kuma LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/uptimekuma-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 1GB RAM - 2GB Storage - 1vCPU ⚡</h3> - -**Uptime Kuma Interface - IP:3001** - -⚙️ **To Update Uptime Kuma** - -Run in the LXC console -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/uptimekuma-update.sh)" -``` -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Whoogle LXC </summary> - -<p align="center"><img src="https://github.com/tteck/Proxmox/blob/main/misc/images/whoogle.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> Whoogle LXC </h1> - -Get Google search results, but without any ads, javascript, AMP links, cookies, or IP address tracking. - -To create a new Proxmox Whoogle LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/whoogle-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 512MiB RAM - 2GB Storage - 1vCPU ⚡</h3> - -**Whoogle Interface - IP:5000** - -⚙️ **To Update Whoogle** - -Run in the LXC console -```yaml -pip3 install whoogle-search --upgrade -``` -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Heimdall Dashboard LXC</summary> - -<p align="center"><img src="https://github.com/tteck/Proxmox/blob/main/misc/images/heimdall.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> Heimdall Dashboard LXC </h1> - -[Heimdall Application Dashboard](https://camo.githubusercontent.com/bcfd4f74c93b25bea7b14eacbafd649206bf754a3d4b596329968f0ee569cf3c/68747470733a2f2f692e696d6775722e636f6d2f4d72433451704e2e676966) is a dashboard for all your web applications. It doesn't need to be limited to applications though, you can add links to anything you like. - -To create a new Proxmox Heimdall Dashboard LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/heimdalldashboard-v3.sh)" -``` -<h3 align="center" id="heading">⚡ Default Settings: 512MiB RAM - 2GB Storage - 1vCPU ⚡</h3> - -**Heimdall Dashboard Interface - IP:7990** - -⚙️ **To Update Heimdall Dashboard** - -Run in the LXC console -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/heimdalldashboard-all-update.sh)" -``` - -__________________________________________________________________________________________ - -</details> - - -<details> -<summary markdown="span"> Dashy LXC</summary> - -<p align="center"><img src="https://github.com/Lissy93/dashy/raw/master/public/web-icons/dashy-logo.png" height="100"/></p> - -<h1 align="center" id="heading"> Dashy LXC </h1> - -Dashy helps you organize your self-hosted services by making them accessible from a single place - -To create a new Proxmox Dashy LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/dashy-v3.sh)" -``` -<h3 align="center" id="heading">⚡ Default Settings: 2GB RAM - 3GB Storage - 2vCPU ⚡</h3> - -**Dashy Interface - IP:4000** - -After getting everything setup the way you want in interactive mode and saved to disk, you have to go into update configuration and rebuild application. - -⚙️ **To Update Dashy** - -Run in the LXC Console -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/dashy-update.sh)" -``` - -__________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> 🔸grocy LXC </summary> - -<p align="center"><img src="https://grocy.info/img/grocy_logo.svg" height="100"/></p> - -<h1 align="center" id="heading"> grocy LXC </h1> - -[grocy](https://grocy.info/) is a web-based self-hosted groceries & household management solution for your home. - -To create a new Proxmox grocy LXC, run the following in the Proxmox Shell. - -``` -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/grocy-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 512MiB RAM - 2GB Storage - 1vCPU ⚡</h3> - -**grocy Interface: http:// IP** - -⚙️ **Initial Login** - -**username** - ```yaml - admin - ``` - **password** - ```yaml - admin - ``` - -⚙️ **To Update grocy** - -Run in the LXC console - ```yaml -bash /var/www/html/update.sh -``` -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> MagicMirror Server LXC </summary> - -<p align="center"><img src="https://github.com/MichMich/MagicMirror/raw/master/.github/header.png" height="100"/></p> - -<h1 align="center" id="heading"> MagicMirror Server LXC </h1> - -[MagicMirror²](https://docs.magicmirror.builders/) is an open source modular smart mirror platform. - -To create a new MagicMirror Server LXC, run the following in the Proxmox Shell. - -``` -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/magicmirror-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 512MiB RAM - 3GB Storage - 1vCPU ⚡</h3> - -**MagicMirror Interface - IP:8080** - -⚙️ **[Configuration](https://docs.magicmirror.builders/configuration/introduction.html#configuring-your-magicmirror)** -```yaml -/opt/magicmirror/config/config.js -``` -⚙️ **[Update MagicMirror](https://docs.magicmirror.builders/getting-started/upgrade-guide.html#upgrade-guide)** - -Run in the LXC Console -```yaml -cd /opt/magicmirror && git pull && npm install --only=prod --omit=dev -``` - - -____________________________________________________________________________________________ - -</details> - - -<details> -<summary markdown="span"> PhotoPrism LXC </summary> - -<p align="center"><img src="https://github.com/tteck/Proxmox/blob/main/misc/images/photoprism.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> PhotoPrism LXC </h1> - -PhotoPrism® is an AI-powered app for browsing, organizing & sharing your photo collection. - -To create a new Proxmox PhotoPrism LXC, run the following in the Proxmox Shell. - -``` -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/photoprism-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 2GB RAM - 8GB Storage - 2vCPU ⚡</h3> - -**PhotoPrism Interface - IP:2342** - -⚙️ **Initial Login** - -**username** - ```yaml - admin - ``` - **password** - ```yaml - admin - ``` -[PhotoSync](https://www.photosync-app.com/home.html) - -⚙️ **To Update PhotoPrism** - -Run in the LXC Console -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/photoprism-update.sh)" -``` - - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Daemon Sync Server LXC</summary> - -<p align="center"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fimg.informer.com%2Ficons_mac%2Fpng%2F128%2F350%2F350335.png&f=1&nofb=1" height="100"/></p> - -<h1 align="center" id="heading"> Daemon Sync Server LXC </h1> - -Sync files from app to server, share photos & videos, back up your data and stay secure inside local network. - -To create a new Proxmox Daemon Sync Server LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/daemonsync-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 512MiB RAM - 8GB Storage - 1vCPU ⚡</h3> - -**Daemon Sync Server Interface - IP:8084** - -Search: `DAEMON Sync` in your favorite app store - -__________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> MotionEye VMS LXC </summary> - -<p align="center"><img src="https://github.com/home-assistant/brands/blob/master/core_integrations/motioneye/icon.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> MotionEye VMS LXC </h1> - -To create a new Proxmox MotionEye VMS LXC, run the following in the Proxmox Shell. - -``` -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/motioneye-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 2GB RAM - 8GB Storage - 2vCPU ⚡</h3> - -**MotionEye Interface - IP:8765** - -⚙️ **Initial Login** - -**username** - ```yaml - admin - ``` - **password** - ```yaml - - ``` - -⚙️ **To Update MotionEye** - -Run in the LXC console - ```yaml -pip install motioneye --upgrade -``` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> File Browser</summary> - -<p align="center"><img src="https://github.com/tteck/Proxmox/blob/main/misc/images/filebrowser.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> File Browser </h1> - -To Install File Browser, ⚠️ run the following in the LXC console. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/filebrowser-v3.sh)" -``` - -[File Browser](https://filebrowser.org/features) is a create-your-own-cloud-kind of software where you can install it on a server, direct it to a path and then access your files through a nice web interface. Many available features! - - - -**File Browser Interface - http:// IP:8080** - -⚙️ **Initial Login** - -**username** - ```yaml - admin - ``` - **password** - ```yaml - changeme - ``` - -⚙️ **To Update File Browser** - -```yaml -curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash -``` -___________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Webmin System Administration</summary> - -<p align="center"><img src="https://github.com/webmin/webmin/blob/master/images/webmin-blue.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> Webmin System Administration </h1> - -To Install Webmin System Administration [(Screenshot)](https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/file-manager.png), ⚠️ run the following in the LXC console. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/webmin.sh)" -``` - -If you prefer to manage all aspects of your Proxmox LXC from a graphical interface instead of the command line interface, Webmin might be right for you. - -Benefits include automatic daily security updates, backup and restore, file manager with editor, web control panel, and preconfigured system monitoring with optional email alerts. - - - -**Webmin Interface - https:// IP:10000 (https)** - -⚙️ **Initial Login** - -**username** - ```yaml - root - ``` - **password** - ```yaml - root - ``` - -⚙️ **To Update Webmin** - -```yaml -Update from the Webmin UI -``` -⚙️ **To Uninstall Webmin** - -Run in the LXC console -```yaml -bash /etc/webmin/uninstall.sh -``` -___________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> WireGuard LXC </summary> - -<p align="center"><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fcdn.icon-icons.com%2Ficons2%2F2699%2FPNG%2F512%2Fwireguard_logo_icon_168760.png&f=1&nofb=1" height="100"/></p> - -<h1 align="center" id="heading"> WireGuard LXC </h1> -<h3 align="center"> With WGDashboard </h3> - -To create a new Proxmox WireGuard LXC, run the following in the Proxmox Shell. - -``` -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/wireguard-v3.sh)" -``` - -<h3 align="center" id="heading">⚡ Default Settings: 512MiB RAM - 2GB Storage - 1vCPU ⚡</h3> - -**WGDashboard Interface - http:// IP:10086** - -⚙️ **Initial Login** - -**username** - ```yaml - admin - ``` - **password** - ```yaml - admin - ``` - -⚙️ **Host Configuration** - -Run in the LXC console - ```yaml - nano /etc/pivpn/wireguard/setupVars.conf - ``` - ⚙️**Add Clients** - - Run in the LXC console - ```yaml - pivpn add - ``` -⚙️ **To Update WireGuard** - -Run in the LXC console - ```yaml -apt update && apt upgrade -y -``` -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Tailscale</summary> - -<p align="center"><img src="https://avatars.githubusercontent.com/u/48932923?v=4&s=100"/></p> - -<h1 align="center" id="heading"> Tailscale</h1> - -[Tailscale](https://tailscale.com/) Creates a secure network between your servers, computers, and cloud instances. Even when separated by firewalls or subnets, Tailscale just works. - -To Install Talescale on an existing LXC, run the following in the Proxmox Shell (replace `106` with your LXC ID). - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/add-tailscale-lxc.sh)" -s 106 -``` -After the script finishes, reboot the LXC then run `tailscale up` in the LXC console - -[**Tailscale Login**](https://login.tailscale.com/start) - -⚙️ **To Update Tailscale** - -Run in the LXC console - ```yaml -apt update && apt upgrade -y -``` - -___________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> CrowdSec</summary> - -<p align="center"><img src="https://raw.githubusercontent.com/crowdsecurity/crowdsec-docs/main/crowdsec-docs/static/img/crowdsec_no_txt.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> CrowdSec</h1> - -To Install CrowdSec, ⚠️ run the following in the LXC console. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/crowdsec-v3.sh)" -``` - -[CrowdSec](https://crowdsec.net/) is a free, open-source and collaborative IPS. Analyze behaviors, respond to attacks & share signals across the community. - -[**Control center for your CrowdSec machines.**](https://app.crowdsec.net/product-tour) - -___________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> Keycloak LXC</summary> - -<p align="center"><img src="https://www.keycloak.org/resources/images/keycloak_icon_512px.svg?raw=true" height="100"/></p> - -<h1 align="center" id="heading"> Keycloak LXC</h1> - -To create a new Proxmox Keycloak LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/keycloak-v3.sh)" -``` - -[Keycloak](https://www.keycloak.org/) is an Open Source Identity and Access Management solution for modern Applications and Services. - -**Keycloak Interface - http:// IP:8080** (First start can take a few minutes) - -⚙️ **Initial Login** - -The initial admin user can be added manually using the web frontend when accessed from localhost or automatically using environment variables. - -To add the initial admin user using environment variables, set `KEYCLOAK_ADMIN` for the initial admin username and `KEYCLOAK_ADMIN_PASSWORD` for the initial admin password. - -First, stop Keycloak -```yaml -systemctl stop keycloak.service -``` -then start Keycloak by coping & pasting the following (only needed once) -```yaml -cd /opt/keycloak -export KEYCLOAK_ADMIN=admin -export KEYCLOAK_ADMIN_PASSWORD=changeme - -bin/kc.sh start-dev -``` -⚙️ **To Update Keycloak** - -```yaml -working On -``` -___________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span"> 🔸Vaultwarden LXC</summary> - -<p align="center"><img src="https://raw.githubusercontent.com/dani-garcia/vaultwarden/main/resources/vaultwarden-icon-white.svg" width="100" height="100"/></p> - -<h1 align="center" id="heading"> Vaultwarden LXC </h1> - -Alternative implementation of the Bitwarden server API written in Rust and compatible with upstream [Bitwarden clients](https://bitwarden.com/download/), perfect for self-hosted deployment where running the official resource-heavy service might not be ideal. - -To create a new Proxmox Vaultwarden LXC, run the following in the Proxmox Shell. - -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/vaultwarden-v3.sh)" -``` -⚠️ Vaultwarden needs to be behind a proxy (Nginx Proxy Manager) to obtain HTTPS and to allow clients to connect. - -The script builds from source, which takes time and resources. After the build, the script will automatically set resources to Normal Settings. - -Expect 30+ minute install time. -<h3 align="center" id="heading">⚡ Build Settings: 2048Mib RAM - 6GB Storage - 2vCPU ⚡</h3> -<h3 align="center" id="heading">⚡ Normal Settings: 512Mib RAM - 6GB Storage - 1vCPU ⚡</h3> - -**Vaultwarden Interface: CTIP:8000** - -⚙️ **Path to Vaultwarden .env file** (to enable `ADMIN_TOKEN`) -```yaml -/opt/vaultwarden/.env -``` - -⚙️ **To Update Vaultwarden (post 2022-05-29 installs only)** - -Run in the LXC console -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/vaultwarden-update.sh)" -``` -⚙️ **To Update Web-vault (any)** - -Run in the LXC console -```yaml -bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/web-vault-update.sh)" -``` - -____________________________________________________________________________________________ - -</details> - -<details> -<summary markdown="span">Ombi</summary> - -<p align="center"><img src="https://github.com/Ombi-app/Ombi/blob/develop/src/Ombi/wwwroot/images/favicon/apple-touch-icon.png?raw=true" height="100"/></p> - -<h1 align="center" id="heading">Ombi</h1> - -To Install Ombi, ⚠️ run the following in the LXC console. - -```yaml -bash -c "$(wget -qLO - https://github.com/Kickbut101/Proxmox/raw/main/ct/ombi.sh)" -``` -<h3 align="center" id="heading">⚡ Build Settings: 2048Mib RAM - 5GB Storage - 1vCPU ⚡</h3> - -**Webmin Interface - http:// IP:5000 (http)** - -[Ombi](https://ombi.io/) Ombi is your friendly media request tool, automatically syncs with your media servers! Don't worry, it's grandma friendly, and more importantly; has wife approval certification 😂. - - -___________________________________________________________________________________________ - -</details> \ No newline at end of file +<div align="center"> + <a href="#"> + <img src="https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/logo.png" height="100px" /> + </a> +</div> +<h1 align="center">Proxmox VE Helper-Scripts</h1> + +<p align="center"> + <a href="https://helper-scripts.com">Website</a> | + <a href="https://github.com/tteck/Proxmox/blob/main/.github/CONTRIBUTING.md">Contribute</a> | + <a href="https://github.com/tteck/Proxmox/blob/main/USER_SUBMITTED_GUIDES.md">Guides</a> | + <a href="https://github.com/tteck/Proxmox/blob/main/CHANGELOG.md">Changelog</a> | + <a href="https://ko-fi.com/D1D7EP4GF">Support</a> +</p> + +--- + +> [!WARNING] +Be cautious of copycat or coat-tailing sites that exploit the project's popularity with potentially malicious intent. Please only trust information from https://Helper-Scripts.com/ or https://tteck.github.io/Proxmox/. + +These scripts empower users to create a Linux container or virtual machine interactively, providing choices for both simple and advanced configurations. The basic setup adheres to default settings, while the advanced setup gives users the ability to customize these defaults. + +Options are displayed to users in a dialog box format. Once the user makes their selections, the script collects and validates their input to generate the final configuration for the container or virtual machine. +<p align="center"> +Be cautious and thoroughly evaluate scripts and automation tasks obtained from external sources. <a href="https://github.com/tteck/Proxmox/blob/main/CODE-AUDIT.md">Read more</a> +</p> +<sub><div align="center"> Proxmox® is a registered trademark of Proxmox Server Solutions GmbH. </div></sub> diff --git a/USER_SUBMITTED_GUIDES.md b/USER_SUBMITTED_GUIDES.md new file mode 100644 index 00000000..e3c8ffdd --- /dev/null +++ b/USER_SUBMITTED_GUIDES.md @@ -0,0 +1,40 @@ +<div align="center"> + <a href="#"> + <img src="https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/logo.png" height="100px" /> + </a> +</div> +<h2 align="center">User Submitted Guides </h2> + +<sub> In order to contribute a guide on installing with Proxmox VE Helper Scripts, you should open a pull request that adds the guide to the `USER_SUBMITTED_GUIDES.md` file. </sub> + +[Proxmox Automation with Proxmox Helper Scripts!](https://www.youtube.com/watch?v=kcpu4z5eSEU) + +[Installing Home Assistant OS using Proxmox 8](https://community.home-assistant.io/t/installing-home-assistant-os-using-proxmox-8/201835) + +[How To Separate Zigbee2MQTT From Home Assistant In Proxmox](https://smarthomescene.com/guides/how-to-separate-zigbee2mqtt-from-home-assistant-in-proxmox/) + +[How To Install Home Assistant On Proxmox: The Easy Way](https://smarthomescene.com/guides/how-to-install-home-assistant-on-proxmox-the-easy-way/) + +[Home Assistant: Installing InfluxDB (LXC)](https://www.derekseaman.com/2023/04/home-assistant-installing-influxdb-lxc.html) + +[Home Assistant: Proxmox Quick Start Guide](https://www.derekseaman.com/2023/10/home-assistant-proxmox-ve-8-0-quick-start-guide-2.html) + +[Home Assistant: Installing Grafana (LXC) with Let’s Encrypt SSL](https://www.derekseaman.com/2023/04/home-assistant-installing-grafana-lxc.html) + +[Proxmox: Plex LXC with Alder Lake Transcoding](https://www.derekseaman.com/2023/04/proxmox-plex-lxc-with-alder-lake-transcoding.html) + +[How To Backup Home Assistant In Proxmox](https://smarthomescene.com/guides/how-to-backup-home-assistant-in-proxmox/) + +[Running Frigate on Proxmox](https://www.homeautomationguy.io/blog/running-frigate-on-proxmox) + +[Frigate VM on Proxmox with PCIe Coral TPU](https://www.derekseaman.com/2023/06/home-assistant-frigate-vm-on-proxmox-with-pcie-coral-tpu.html) + +[Moving Home Assistant’s Database To MariaDB On Proxmox](https://smarthomescene.com/guides/moving-home-assistants-database-to-mariadb-on-proxmox/) + +[How-to: Proxmox VE 7.4 to 8.0 Upgrade](https://www.derekseaman.com/2023/06/how-to-proxmox-7-4-to-8-0-upgrade.html) + +[iGPU Transcoding In Proxmox with Jellyfin](https://www.youtube.com/watch?v=XAa_qpNmzZs) + +[Proxmox + NetData](<https://dbt3ch.com/books/proxmox-netdata-for-better-insights-and-notifications/page/proxmox-netdata-for-better-insights-and-notifications>) + +[Proxmox Homelab Series](<https://blog.kye.dev/proxmox-series>) diff --git a/_config.yml b/_config.yml deleted file mode 100644 index 6979f9d8..00000000 --- a/_config.yml +++ /dev/null @@ -1,6 +0,0 @@ -theme: jekyll-theme-hacker -title: Proxmox Helper Scripts -description: Proxmox Scripts For Home Automation -markdown: kramdown -kramdown: - parse_block_html: true diff --git a/ct/actualbudget.sh b/ct/actualbudget.sh new file mode 100644 index 00000000..1f1e201d --- /dev/null +++ b/ct/actualbudget.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Actual Budget" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/actualbudget ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP}" +systemctl stop actualbudget.service +cd /opt/actualbudget +git pull &>/dev/null +yarn install &>/dev/null +systemctl start actualbudget.service +msg_ok "Successfully Updated ${APP}" +exit +} + +start +build_container +description +msg_info "Setting Container to Normal Resources" +pct set $CTID -memory 1024 +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}:5006${CL} \n" diff --git a/ct/adguard-v1.sh b/ct/adguard-v1.sh deleted file mode 100644 index daada894..00000000 --- a/ct/adguard-v1.sh +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/env bash - -while true; do - read -p "This will create a New AdGuard Home LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if [ ! -z ${MOUNT+x} ]; then - pct unmount $CTID - fi - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} -function load_module() { - if ! $(lsmod | grep -Fq $1); then - modprobe $1 &>/dev/null || \ - die "Failed to load '$1' module." - fi - MODULES_PATH=/etc/modules - if ! $(grep -Fxq "$1" $MODULES_PATH); then - echo "$1" >> $MODULES_PATH || \ - die "Failed to add '$1' module to load at boot." - fi -} -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/adguard_setup.sh - -load_module overlay - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content rootdir | awk 'NR>1') -if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then - warn "'Container' needs to be selected for at least one storage location." - die "Unable to detect valid storage location." -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 container?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit - done -fi -info "Using '$STORAGE' for storage location." - -CTID=$(pvesh get /cluster/nextid) -info "LXC ID is $CTID." - -echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m" -pveam update >/dev/null - -echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m" -OSTYPE=debian -OSVERSION=${OSTYPE}-11 -mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V) -TEMPLATE="${TEMPLATES[-1]}" -pveam download local $TEMPLATE >/dev/null || - die "A problem occured while downloading the LXC template." - -STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') -case $STORAGE_TYPE in - dir|nfs) - DISK_EXT=".raw" - DISK_REF="$CTID/" - ;; - zfspool) - DISK_PREFIX="subvol" - DISK_FORMAT="subvol" - ;; -esac -DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-} -ROOTFS=${STORAGE}:${DISK_REF-}${DISK} - -echo -e "${CHECKMARK} \e[1;92m Creating LXC... \e[0m" -DISK_SIZE=2G -pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -else - mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null -fi -ARCH=$(dpkg --print-architecture) -HOSTNAME=adguard -TEMPLATE_STRING="local:vztmpl/${TEMPLATE}" -pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \ - -hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 1 -memory 512 \ - -ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null - -MOUNT=$(pct mount $CTID | cut -d"'" -f 2) -ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime -pct unmount $CTID && unset MOUNT - -echo -e "${CHECKMARK} \e[1;92m Starting LXC... \e[0m" -pct start $CTID -pct push $CTID adguard_setup.sh /adguard_setup.sh -perms 755 -pct exec $CTID /adguard_setup.sh - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') -info "Successfully created a AdGuard Home LXC to $CTID" -echo -e "\e[1;92m AdGuard Home Setup should be reachable by going to the following URL. - http://${IP}:3000 -\e[0m" diff --git a/ct/adguard-v2.sh b/ct/adguard-v2.sh deleted file mode 100644 index 9838585b..00000000 --- a/ct/adguard-v2.sh +++ /dev/null @@ -1,256 +0,0 @@ -#!/usr/bin/env bash - -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will create a New Adguard Home LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${GN} - _ _ - /\ | | | | - / \ __| | __ _ _ _ __ _ _ __ __| | - / /\ \ / _ |/ _ | | | |/ _ | __/ _ | - / ____ \ (_| | (_| | |_| | (_| | | | (_| | - /_/ \_\__,_|\__, |\__,_|\__,_|_| \__,_| - __/ | - |___/ - -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=2 -export PCT_OPTIONS=" - -features $FEATURES - -hostname adguard - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 1 - -memory 512 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/adguard-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created Adguard Home LXC to${CL} ${BL}$CTID${CL}. -${GN}Adguard${CL} Setup should be reachable by going to the following URL. - ${BL}http://${IP}:3000${CL} \n" - diff --git a/ct/adguard-v3.sh b/ct/adguard-v3.sh deleted file mode 100644 index 26955d34..00000000 --- a/ct/adguard-v3.sh +++ /dev/null @@ -1,358 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Adguard" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${GN} - _ _ - /\ | | | | - / \ __| | __ _ _ _ __ _ _ __ __| | - / /\ \ / _ |/ _ | | | |/ _ | __/ _ | - / ____ \ (_| | (_| | |_| | (_| | | | (_| | - /_/ \_\__,_|\__, |\__,_|\__,_|_| \__,_| - v3__/ | - |___/ -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}2${CL}${DGN}GB${CL}" - DISK_SIZE="2" - echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}" - CORE_COUNT="1" - echo -e "${DGN}Using ${BGN}512${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="512" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 2 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="2"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 512 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="512"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/adguard-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# AdGuard Home LXC -### https://github.com/tteck/Proxmox" - -msg_ok "Completed Successfully!\n" -echo -e "Adguard 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..b7a8fdd5 --- /dev/null +++ b/ct/adguard.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 +if (( $(df /boot | awk 'NR==2{gsub("%","",$5); print $5}') > 80 )); then + read -r -p "Warning: Storage is dangerously low, continue anyway? <y/N> " prompt + [[ ${prompt,,} =~ ^(y|yes)$ ]] || exit +fi +wget -qL https://static.adguard.com/adguardhome/release/AdGuardHome_linux_amd64.tar.gz +msg_info "Stopping AdguardHome" +systemctl stop AdGuardHome +msg_ok "Stopped AdguardHome" + +msg_info "Updating AdguardHome" +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 "Updated Successfully" +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/agentdvr.sh b/ct/agentdvr.sh new file mode 100644 index 00000000..d77921bf --- /dev/null +++ b/ct/agentdvr.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="AgentDVR" +var_disk="8" +var_cpu="2" +var_ram="2048" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/agentdvr ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_error "There is currently no update path available." +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP}${CL} should be reachable by going to the following URL. + ${BL}http://${IP}:8090${CL} \n" diff --git a/ct/alpine-docker.sh b/ct/alpine-docker.sh new file mode 100644 index 00000000..6fe0c3bf --- /dev/null +++ b/ct/alpine-docker.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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.19" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + if ! apk -e info newt >/dev/null 2>&1; then + apk add -q newt + fi + while true; do + CHOICE=$( + whiptail --backtitle "Proxmox VE Helper Scripts" --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.sh b/ct/alpine-grafana.sh new file mode 100644 index 00000000..97e5ebde --- /dev/null +++ b/ct/alpine-grafana.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="1" +var_cpu="1" +var_ram="256" +var_os="alpine" +var_version="3.19" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + if ! apk -e info newt >/dev/null 2>&1; then + apk add -q newt + fi + LXCIP=$(ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) + while true; do + CHOICE=$( + whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUPPORT" --menu "Select option" 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-nextcloud.sh b/ct/alpine-nextcloud.sh new file mode 100644 index 00000000..c683cfe2 --- /dev/null +++ b/ct/alpine-nextcloud.sh @@ -0,0 +1,94 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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-Nextcloud" +var_disk="2" +var_cpu="2" +var_ram="1024" +var_os="alpine" +var_version="3.19" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + if [[ ! -d /usr/share/webapps/nextcloud ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + if ! apk -e info newt >/dev/null 2>&1; then + apk add -q newt + fi + while true; do + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 3 \ + "1" "Nextcloud Login Credentials" ON \ + "2" "Renew Self-signed Certificate" OFF \ + 3>&1 1>&2 2>&3) + exit_status=$? + if [ $exit_status == 1 ]; then + clear + exit-script + fi + header_info + case $CHOICE in + 1) + cat nextcloud.creds + exit + ;; + 2) + openssl req -x509 -nodes -days 365 -newkey rsa:4096 -keyout /etc/ssl/private/nextcloud-selfsigned.key -out /etc/ssl/certs/nextcloud-selfsigned.crt -subj "/C=US/O=Nextcloud/OU=Domain Control Validated/CN=nextcloud.local" > /dev/null 2>&1 + rc-service nginx 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}https://${IP}${CL} \n" diff --git a/ct/alpine-vaultwarden.sh b/ct/alpine-vaultwarden.sh new file mode 100644 index 00000000..9b06d51d --- /dev/null +++ b/ct/alpine-vaultwarden.sh @@ -0,0 +1,102 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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.19" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + if ! apk -e info newt >/dev/null 2>&1; then + apk add -q newt + fi + while true; do + CHOICE=$( + whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUPPORT" --menu "Select option" 11 58 2 \ + "1" "Update Vaultwarden" \ + "2" "Reset 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 && rc-service vaultwarden restart -q + exit + ;; + 2) + if NEWTOKEN=$(whiptail --backtitle "Proxmox VE Helper Scripts" --passwordbox "Setup your ADMIN_TOKEN (make it strong)" 10 58 3>&1 1>&2 2>&3); then + if [[ -z "$NEWTOKEN" ]]; then exit-script; fi + if ! command -v argon2 >/dev/null 2>&1; then apk add argon2 &>/dev/null; fi + TOKEN=$(echo -n ${NEWTOKEN} | argon2 "$(openssl rand -base64 32)" -e -id -k 19456 -t 2 -p 1) + if [[ ! -f /var/lib/vaultwarden/config.json ]]; then + sed -i "s|export ADMIN_TOKEN=.*|export ADMIN_TOKEN='${TOKEN}'|" /etc/conf.d/vaultwarden + else + sed -i "s|\"admin_token\": .*|\"admin_token\": \"${TOKEN}\",|" /var/lib/vaultwarden/config.json + fi + rc-service vaultwarden restart -q + fi + 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.sh b/ct/alpine-zigbee2mqtt.sh new file mode 100644 index 00000000..eb98903a --- /dev/null +++ b/ct/alpine-zigbee2mqtt.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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.19" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + if ! apk -e info newt >/dev/null 2>&1; then + apk add -q newt + fi + while true; do + CHOICE=$( + whiptail --backtitle "Proxmox VE Helper Scripts" --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..8a651555 --- /dev/null +++ b/ct/alpine.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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.19" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --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/apache-cassandra.sh b/ct/apache-cassandra.sh new file mode 100644 index 00000000..35f83dff --- /dev/null +++ b/ct/apache-cassandra.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Apache-Cassandra" +var_disk="4" +var_cpu="1" +var_ram="2048" +var_os="debian" +var_version="12" +VERBOSE="yes" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/systemd/system/cassandra.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_error "There is currently no update path available." +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/apache-couchdb.sh b/ct/apache-couchdb.sh new file mode 100644 index 00000000..cd2c00af --- /dev/null +++ b/ct/apache-couchdb.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Apache-CouchDB" +var_disk="10" +var_cpu="2" +var_ram="4096" +var_os="debian" +var_version="12" +VERBOSE="yes" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/systemd/system/couchdb.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_error "There is currently no update path available." +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}:5984/_utils/${CL} \n" diff --git a/ct/apt-cacher-ng.sh b/ct/apt-cacher-ng.sh new file mode 100644 index 00000000..8d8235a3 --- /dev/null +++ b/ct/apt-cacher-ng.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Apt-Cacher-NG" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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} maintenance page should be reachable by going to the following URL. + ${BL}http://${IP}:3142/acng-report.html${CL} \n" diff --git a/ct/aria2.sh b/ct/aria2.sh new file mode 100644 index 00000000..7fc96b97 --- /dev/null +++ b/ct/aria2.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Aria2" +var_disk="8" +var_cpu="2" +var_ram="1028" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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}:6880${CL}" diff --git a/ct/audiobookshelf.sh b/ct/audiobookshelf.sh new file mode 100644 index 00000000..4d360634 --- /dev/null +++ b/ct/audiobookshelf.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/audiobookshelf-ppa.asc ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +echo "This application receives updates through the APT package manager." +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.sh b/ct/autobrr.sh new file mode 100644 index 00000000..8cfc2f3e --- /dev/null +++ b/ct/autobrr.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 "Updated Successfully" +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/bazarr.sh b/ct/bazarr.sh new file mode 100755 index 00000000..d94543e5 --- /dev/null +++ b/ct/bazarr.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Bazarr" +var_disk="4" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /var/lib/bazarr/ ]]; 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}:6767${CL} \n" diff --git a/ct/blocky.sh b/ct/blocky.sh new file mode 100644 index 00000000..a9c74c4d --- /dev/null +++ b/ct/blocky.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/bunkerweb.sh b/ct/bunkerweb.sh new file mode 100644 index 00000000..42f0e50f --- /dev/null +++ b/ct/bunkerweb.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="BunkerWeb" +var_disk="4" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /etc/bunkerweb ]]; then msg_error "No ${APP} Installation Found!"; exit; fi + +RELEASE=$(curl -s https://api.github.com/repos/bunkerity/bunkerweb/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + + msg_info "Updating ${APP} to ${RELEASE}" + cat <<EOF >/etc/apt/preferences.d/bunkerweb +Package: bunkerweb +Pin: version ${RELEASE} +Pin-Priority: 1001 +EOF + apt-get update + apt-get install -y nginx=1.26.1* + apt-get install -y bunkerweb=${RELEASE} + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated ${APP} to ${RELEASE}" + +else + msg_ok "No update required. ${APP} is already at ${RELEASE}" +fi +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}/setup${CL} \n" diff --git a/ct/caddy.sh b/ct/caddy.sh new file mode 100644 index 00000000..6df98d39 --- /dev/null +++ b/ct/caddy.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Caddy" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /etc/caddy ]]; 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/calibre-web.sh b/ct/calibre-web.sh new file mode 100644 index 00000000..d7b53adc --- /dev/null +++ b/ct/calibre-web.sh @@ -0,0 +1,164 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Co-Author: remz1337 +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ______ ___ __ _ __ __ + / ____/___ _/ (_) /_ ________ | | / /__ / /_ + / / / __ `/ / / __ \/ ___/ _ \___| | /| / / _ \/ __ \ +/ /___/ /_/ / / / /_/ / / / __/___/ |/ |/ / __/ /_/ / +\____/\__,_/_/_/_.___/_/ \___/ |__/|__/\___/_.___/ + +EOF +} +header_info +echo -e "Loading..." +APP="Calibre-Web" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + if [[ ! -f /etc/systemd/system/cps.service ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + header_info + msg_info "Updating $APP LXC" + systemctl stop cps + cd /opt/kepubify + rm kepubify-linux-64bit + curl -fsSLO https://github.com/pgaskin/kepubify/releases/latest/download/kepubify-linux-64bit &>/dev/null + chmod +x kepubify-linux-64bit + menu_array=("1" "Enables gdrive as storage backend for your ebooks" OFF \ + "2" "Enables sending emails via a googlemail account without enabling insecure apps" OFF \ + "3" "Enables displaying of additional author infos on the authors page" OFF \ + "4" "Enables login via LDAP server" OFF \ + "5" "Enables login via google or github oauth" OFF \ + "6" "Enables extracting of metadata from epub, fb2, pdf files, and also extraction of covers from cbr, cbz, cbt files" OFF \ + "7" "Enables extracting of metadata from cbr, cbz, cbt files" OFF \ + "8" "Enables syncing with your kobo reader" OFF ) + if [ -f "/opt/calibre-web/options.txt" ]; then + cps_options="$(cat /opt/calibre-web/options.txt)" + IFS=',' read -ra ADDR <<< "$cps_options" + for i in "${ADDR[@]}"; do + if [ $i == "gdrive" ]; then + line=0 + elif [ $i == "gmail" ]; then + line=1 + elif [ $i == "goodreads" ]; then + line=2 + elif [ $i == "ldap" ]; then + line=3 + elif [ $i == "oauth" ]; then + line=4 + elif [ $i == "metadata" ]; then + line=5 + elif [ $i == "comics" ]; then + line=6 + elif [ $i == "kobo" ]; then + line=7 + fi + array_index=$(( 3*line + 2 )) + menu_array[$array_index]=ON + done + fi + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi + CHOICES=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "CALIBRE-WEB OPTIONS" --separate-output --checklist "Choose Additional Options" 15 125 8 "${menu_array[@]}" 3>&1 1>&2 2>&3) + spinner & + SPINNER_PID=$! + options=() + if [ ! -z "$CHOICES" ]; then + for CHOICE in $CHOICES; do + case "$CHOICE" in + "1") + options+=( gdrive ) + ;; + "2") + options+=( gmail ) + ;; + "3") + options+=( goodreads ) + ;; + "4") + options+=( ldap ) + apt-get install -qqy libldap2-dev libsasl2-dev + ;; + "5") + options+=( oauth ) + ;; + "6") + options+=( metadata ) + ;; + "7") + options+=( comics ) + ;; + "8") + options+=( kobo ) + ;; + *) + echo "Unsupported item $CHOICE!" >&2 + exit 1 + ;; + esac + done + fi + if [ ! -z "$options" ] && [ ${#options[@]} -gt 0 ]; then + cps_options=$(IFS=, ; echo "${options[*]}") + echo $cps_options > /opt/calibre-web/options.txt + pip install --upgrade calibreweb[$cps_options] + else + rm /opt/calibre-web/options.txt 2> /dev/null + pip install --upgrade calibreweb + fi + systemctl start cps + msg_ok "Updated $APP LXC" + exit +} + +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}:8083${CL} \n" diff --git a/ct/casaos.sh b/ct/casaos.sh new file mode 100644 index 00000000..85cc0510 --- /dev/null +++ b/ct/casaos.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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} ${CL} \n" diff --git a/ct/changedetection.sh b/ct/changedetection.sh new file mode 100644 index 00000000..b6f42369 --- /dev/null +++ b/ct/changedetection.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="8" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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" +if ! dpkg -s libjpeg-dev >/dev/null 2>&1; then + apt-get update + apt-get install -y libjpeg-dev +fi +pip3 install changedetection.io --upgrade &>/dev/null +pip3 install playwright --upgrade &>/dev/null +systemctl restart changedetection +msg_ok "Updated Successfully" +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/channels.sh b/ct/channels.sh new file mode 100644 index 00000000..7e8b0140 --- /dev/null +++ b/ct/channels.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Channels" +var_disk="8" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/channels-dvr ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_error "There is currently no update path available." +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}:8089 ${CL} \n" diff --git a/ct/cloudflared.sh b/ct/cloudflared.sh new file mode 100644 index 00000000..c4f9631c --- /dev/null +++ b/ct/cloudflared.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Cloudflared" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/commafeed.sh b/ct/commafeed.sh new file mode 100644 index 00000000..7b8b16b6 --- /dev/null +++ b/ct/commafeed.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="CommaFeed" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/commafeed ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +RELEASE=$(curl -sL https://api.github.com/repos/Athou/commafeed/releases/latest | grep '"tag_name":' | cut -d'"' -f4) +if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + msg_info "Stopping ${APP}" + systemctl stop commafeed + msg_ok "Stopped ${APP}" + + msg_info "Updating ${APP} to ${RELEASE}" + wget -q https://github.com/Athou/commafeed/releases/download/${RELEASE}/commafeed-${RELEASE}-h2-jvm.zip + unzip -q commafeed-${RELEASE}-h2-jvm.zip + rsync -a --exclude 'data/' commafeed-${RELEASE}-h2/ /opt/commafeed/ + rm -rf commafeed-${RELEASE}-h2 commafeed-${RELEASE}-h2-jvm.zip + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated ${APP} to ${RELEASE}" + + msg_info "Starting ${APP}" + systemctl start commafeed + msg_ok "Started ${APP}" + msg_ok "Updated Successfully" +else + msg_ok "No update required. ${APP} is already at ${RELEASE}" +fi +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}:8082${CL} \n" diff --git a/ct/create_lxc.sh b/ct/create_lxc.sh index 4cb7864e..f5218600 100644 --- a/ct/create_lxc.sh +++ b/ct/create_lxc.sh @@ -1,49 +1,105 @@ #!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +# This sets verbose mode if the global variable is set to "yes" +# if [ "$VERBOSE" == "yes" ]; then set -x; fi + +# This function sets color variables for formatting output in the terminal +YW=$(echo "\033[33m") +BL=$(echo "\033[36m") +RD=$(echo "\033[01;31m") +GN=$(echo "\033[1;92m") +CL=$(echo "\033[m") CM="${GN}✓${CL}" +CROSS="${RD}✗${CL}" BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR +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 +# This sets error handling options and defines the error_handler function to handle errors +set -Eeuo pipefail +trap 'error_handler $LINENO "$BASH_COMMAND"' ERR + +# This function handles errors +function error_handler() { + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi + printf "\e[?25h" + 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" } +# This function displays a spinner. +function spinner() { + local chars="/-\|" + local spin_i=0 + printf "\e[?25l" + while true; do + printf "\r \e[36m%s\e[0m" "${chars:spin_i++%${#chars}:1}" + sleep 0.1 + done +} + +# This function displays an informational message with a yellow color. function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg} " + spinner & + SPINNER_PID=$! } +# This function displays a success message with a green color. function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi + printf "\e[?25h" + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" } +# This function displays a error message with a red color. +function msg_error() { + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi + printf "\e[?25h" + local msg="$1" + echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" +} + +# This checks for the presence of valid Container Storage and Template Storage locations +msg_info "Validating Storage" +VALIDCT=$(pvesm status -content rootdir | awk 'NR>1') +if [ -z "$VALIDCT" ]; then + msg_error "Unable to detect a valid Container Storage location." + exit 1 +fi +VALIDTMP=$(pvesm status -content vztmpl | awk 'NR>1') +if [ -z "$VALIDTMP" ]; then + msg_error "Unable to detect a valid Template Storage location." + exit 1 +fi + +# This function is used to select the storage class and determine the corresponding storage content type and label. function select_storage() { local CLASS=$1 local CONTENT local CONTENT_LABEL case $CLASS in - container) CONTENT='rootdir'; CONTENT_LABEL='Container';; - template) CONTENT='vztmpl'; CONTENT_LABEL='Container template';; - *) false || die "Invalid storage class.";; + container) + CONTENT='rootdir' + CONTENT_LABEL='Container' + ;; + template) + CONTENT='vztmpl' + CONTENT_LABEL='Container template' + ;; + *) false || exit "Invalid storage class." ;; esac - + + # This Queries all storage locations local -a MENU while read -r line; do local TAG=$(echo $line | awk '{print $1}') @@ -54,67 +110,74 @@ function select_storage() { if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) fi - MENU+=( "$TAG" "$ITEM" "OFF" ) + MENU+=("$TAG" "$ITEM" "OFF") done < <(pvesm status -content $CONTENT | awk 'NR>1') - - if [ $((${#MENU[@]}/3)) -eq 0 ]; then - echo -e "'$CONTENT_LABEL' needs to be selected for at least one storage location." - die "Unable to detect valid storage location." - elif [ $((${#MENU[@]}/3)) -eq 1 ]; then + + # Select storage location + if [ $((${#MENU[@]}/3)) -eq 1 ]; then printf ${MENU[0]} - else + else local STORAGE - while [ -z "${STORAGE:+x}" ]; do - STORAGE=$(whiptail --title "Storage Pools" --radiolist \ - "Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \ + while [ -z "${STORAGE:+x}" ]; do + STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Storage Pools" --radiolist \ + "Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\nTo make a selection, use the Spacebar.\n" \ 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${MENU[@]}" 3>&1 1>&2 2>&3) || die "Menu aborted." + "${MENU[@]}" 3>&1 1>&2 2>&3) || exit "Menu aborted." done printf $STORAGE fi } -[[ "${CTID:-}" ]] || die "You need to set 'CTID' variable." -[[ "${PCT_OSTYPE:-}" ]] || die "You need to set 'PCT_OSTYPE' variable." +# Test if required variables are set +[[ "${CTID:-}" ]] || exit "You need to set 'CTID' variable." +[[ "${PCT_OSTYPE:-}" ]] || exit "You need to set 'PCT_OSTYPE' variable." -[ "$CTID" -ge "100" ] || die "ID cannot be less than 100." +# Test if ID is valid +[ "$CTID" -ge "100" ] || exit "ID cannot be less than 100." +# Test if ID is in use if pct status $CTID &>/dev/null; then echo -e "ID '$CTID' is already in use." unset CTID - die "Cannot use ID that is already in use." + exit "Cannot use ID that is already in use." fi +# Get template storage TEMPLATE_STORAGE=$(select_storage template) || exit msg_ok "Using ${BL}$TEMPLATE_STORAGE${CL} ${GN}for Template Storage." +# Get container storage CONTAINER_STORAGE=$(select_storage container) || exit msg_ok "Using ${BL}$CONTAINER_STORAGE${CL} ${GN}for Container Storage." +# Update LXC template list msg_info "Updating LXC Template List" pveam update >/dev/null msg_ok "Updated LXC Template List" +# Get LXC template string TEMPLATE_SEARCH=${PCT_OSTYPE}-${PCT_OSVERSION:-} mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($TEMPLATE_SEARCH.*\)/\1/p" | sort -t - -k 2 -V) -[ ${#TEMPLATES[@]} -gt 0 ] || die "Unable to find a template when searching for '$TEMPLATE_SEARCH'." +[ ${#TEMPLATES[@]} -gt 0 ] || exit "Unable to find a template when searching for '$TEMPLATE_SEARCH'." TEMPLATE="${TEMPLATES[-1]}" +# Download LXC template if needed if ! pveam list $TEMPLATE_STORAGE | grep -q $TEMPLATE; then msg_info "Downloading LXC Template" pveam download $TEMPLATE_STORAGE $TEMPLATE >/dev/null || - die "A problem occured while downloading the LXC template." + exit "A problem occured while downloading the LXC template." msg_ok "Downloaded LXC Template" fi +# Combine all options DEFAULT_PCT_OPTIONS=( -arch $(dpkg --print-architecture)) - -PCT_OPTIONS=( ${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}} ) -[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=( -rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8} ) +PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}}) +[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=(-rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8}) + +# Create container msg_info "Creating LXC Container" pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null || - die "A problem occured while trying to create container." + exit "A problem occured while trying to create container." msg_ok "LXC Container ${BL}$CTID${CL} ${GN}was successfully created." - diff --git a/ct/cronicle.sh b/ct/cronicle.sh new file mode 100644 index 00000000..946101f3 --- /dev/null +++ b/ct/cronicle.sh @@ -0,0 +1,130 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --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) + +if [ "$UPD" == "1" ]; then +header_info +if [[ ! -d /opt/cronicle ]]; then msg_error "No ${APP} Installation Found!"; exit; fi + if [[ "$(node -v | cut -d 'v' -f 2)" == "18."* ]]; then + if ! command -v npm >/dev/null 2>&1; then + echo "Installing NPM..." + apt-get install -y npm >/dev/null 2>&1 + echo "Installed NPM..." + fi + fi +msg_info "Updating ${APP}" +/opt/cronicle/bin/control.sh upgrade &>/dev/null +msg_ok "Updated ${APP}" +exit +fi +if [ "$UPD" == "2" ]; then + if [[ "$(node -v | cut -d 'v' -f 2)" == "18."* ]]; then + if ! command -v npm >/dev/null 2>&1; then + echo "Installing NPM..." + apt-get install -y npm >/dev/null 2>&1 + echo "Installed NPM..." + fi + fi +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 +apt-get install -y ca-certificates &>/dev/null +apt-get install -y gnupg &>/dev/null +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +apt-get update &>/dev/null +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" +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} \n" diff --git a/ct/daemonsync-v2.sh b/ct/daemonsync-v2.sh deleted file mode 100644 index 5b47dfa6..00000000 --- a/ct/daemonsync-v2.sh +++ /dev/null @@ -1,253 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will create a New Daemon Sync Server LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - _____ _____ - | __ \ / ____| - | | | | __ _ ___ _ __ ___ ___ _ __ | (___ _ _ _ __ ___ - | | | |/ _ |/ _ \ _ _ \ / _ \| _ \ \___ \| | | | _ \ / __| - | |__| | (_| | __/ | | | | | (_) | | | | ____) | |_| | | | | (__ - |_____/ \__,_|\___|_| |_| |_|\___/|_| |_| |_____/ \__, |_| |_|\___| - __/ | - |___/ -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=8 -export PCT_OPTIONS=" - -features $FEATURES - -hostname daemonsync - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 1 - -memory 512 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/daemonsync-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created Daemon Sync Server LXC to${CL} ${BL}$CTID${CL}. - Daemon Sync should be reachable by going to the following URL. - ${BL}http://${IP}:8084${CL} \n" diff --git a/ct/daemonsync-v3.sh b/ct/daemonsync-v3.sh deleted file mode 100644 index df44541e..00000000 --- a/ct/daemonsync-v3.sh +++ /dev/null @@ -1,358 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Daemon Sync" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - _____ _____ - | __ \ / ____| - | | | | __ _v3___ _ __ ___ ___ _ __ | (___ _ _ _ __ ___ - | | | |/ _ |/ _ \ _ _ \ / _ \| _ \ \___ \| | | | _ \ / __| - | |__| | (_| | __/ | | | | | (_) | | | | ____) | |_| | | | | (__ - |_____/ \__,_|\___|_| |_| |_|\___/|_| |_| |_____/ \__, |_| |_|\___| - __/ | - |___/ -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}8${CL}${DGN}GB${CL}" - DISK_SIZE="8" - echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}" - CORE_COUNT="1" - echo -e "${DGN}Using ${BGN}512${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="512" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 8 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="8"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 512 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="512"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/daemonsync-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..01ffa4a7 --- /dev/null +++ b/ct/daemonsync.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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-v2.sh b/ct/dashy-v2.sh deleted file mode 100644 index 49e63390..00000000 --- a/ct/dashy-v2.sh +++ /dev/null @@ -1,254 +0,0 @@ -#!/usr/bin/env bash -clear -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will create a New Dashy LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - _____ _ - | __ \ | | - | | | | __ _ ___| |__ _ _ - | | | |/ _ / __| _ \| | | | - | |__| | (_| \__ \ | | | |_| | - |_____/ \__,_|___/_| |_|\__, | - __/ | - |___/ -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=3 -export PCT_OPTIONS=" - -features $FEATURES - -hostname dashy - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 2 - -memory 2048 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/dashy-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created Dashy LXC to${CL} ${BL}$CTID${CL}. -${BL}Dashy${CL} should be reachable by going to the following URL. - ${BL}http://${IP}:4000${CL} \n" diff --git a/ct/dashy-v3.sh b/ct/dashy-v3.sh deleted file mode 100644 index b7e795d2..00000000 --- a/ct/dashy-v3.sh +++ /dev/null @@ -1,358 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Dashy" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - _____ _ - | __ \ | | - | | | | __ _ ___| |__ _ _ - | | | |/ _ / __| _ \| | | | - | |__| | (_| \__ \ | | | |_| | - |_____/ \__,_|___/_| |_|\__, | - v3__/ | - |___/ -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}3${CL}${DGN}GB${CL}" - DISK_SIZE="3" - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="2048" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 3 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="3"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/dashy-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..60ea57db --- /dev/null +++ b/ct/dashy.sh @@ -0,0 +1,109 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/dashy/public/ ]]; then msg_error "No ${APP} Installation Found!"; exit; fi + +RELEASE=$(curl -sL https://api.github.com/repos/Lissy93/dashy/releases/latest | grep '"tag_name":' | cut -d'"' -f4) +if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + msg_info "Stopping ${APP}" + systemctl stop dashy + msg_ok "Stopped ${APP}" + + msg_info "Backing up conf.yml" + cd ~ + if [[ -f /opt/dashy/public/conf.yml ]]; then + cp -R /opt/dashy/public/conf.yml conf.yml + else + cp -R /opt/dashy/user-data/conf.yml conf.yml + fi + msg_ok "Backed up conf.yml" + + msg_info "Updating ${APP} to ${RELEASE}" + rm -rf /opt/dashy + mkdir -p /opt/dashy + wget -qO- https://github.com/Lissy93/dashy/archive/refs/tags/${RELEASE}.tar.gz | tar -xz -C /opt/dashy --strip-components=1 + cd /opt/dashy + npm install &>/dev/null + npm run build &>/dev/null + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated ${APP} to ${RELEASE}" + + msg_info "Restoring conf.yml" + cd ~ + cp -R conf.yml /opt/dashy/user-data + msg_ok "Restored conf.yml" + + msg_info "Cleaning" + rm -rf conf.yml /opt/dashy/public/conf.yml + msg_ok "Cleaned" + + msg_info "Starting Dashy" + systemctl start dashy + msg_ok "Started Dashy" + msg_ok "Updated Successfully" +else + msg_ok "No update required. ${APP} is already at ${RELEASE}" +fi +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-v1.sh b/ct/debian-v1.sh deleted file mode 100644 index c002b0c6..00000000 --- a/ct/debian-v1.sh +++ /dev/null @@ -1,165 +0,0 @@ -#!/usr/bin/env bash - -while true; do - read -p "This will create a New Debian 11 LXC Container. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if [ ! -z ${MOUNT+x} ]; then - pct unmount $CTID - fi - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} -function load_module() { - if ! $(lsmod | grep -Fq $1); then - modprobe $1 &>/dev/null || \ - die "Failed to load '$1' module." - fi - MODULES_PATH=/etc/modules - if ! $(grep -Fxq "$1" $MODULES_PATH); then - echo "$1" >> $MODULES_PATH || \ - die "Failed to add '$1' module to load at boot." - fi -} -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/debian11_setup.sh - -load_module overlay - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content rootdir | awk 'NR>1') -if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then - warn "'Container' needs to be selected for at least one storage location." - die "Unable to detect valid storage location." -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 container?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit - done -fi -info "Using '$STORAGE' for storage location." - -CTID=$(pvesh get /cluster/nextid) -info "Container ID is $CTID." - -echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m" -pveam update >/dev/null - -echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m" -OSTYPE=debian -OSVERSION=${OSTYPE}-11 -mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V) -TEMPLATE="${TEMPLATES[-1]}" -pveam download local $TEMPLATE >/dev/null || - die "A problem occured while downloading the LXC template." - -STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') -case $STORAGE_TYPE in - dir|nfs) - DISK_EXT=".raw" - DISK_REF="$CTID/" - ;; - zfspool) - DISK_PREFIX="subvol" - DISK_FORMAT="subvol" - ;; -esac -DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-} -ROOTFS=${STORAGE}:${DISK_REF-}${DISK} - -echo -e "${CHECKMARK} \e[1;92m Creating LXC Container... \e[0m" -DISK_SIZE=2G -pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -else - mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null -fi -ARCH=$(dpkg --print-architecture) -HOSTNAME=debian11 -TEMPLATE_STRING="local:vztmpl/${TEMPLATE}" -pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \ - -hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 1 -memory 512\ - -ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null - -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF - -MOUNT=$(pct mount $CTID | cut -d"'" -f 2) -ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime -pct unmount $CTID && unset MOUNT - -echo -e "${CHECKMARK} \e[1;92m Starting LXC Container... \e[0m" -pct start $CTID -pct push $CTID debian11_setup.sh /debian11_setup.sh -perms 755 -pct exec $CTID /debian11_setup.sh - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') -info "Successfully created a Debian 11 LXC Container to $CTID at IP Address ${IP}" diff --git a/ct/debian-v2.sh b/ct/debian-v2.sh deleted file mode 100644 index 36ed693b..00000000 --- a/ct/debian-v2.sh +++ /dev/null @@ -1,257 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[32m"` -CL=`echo "\033[m"` -APP="Debian" -HN=$(echo ${APP,,} | tr -d ' ') -while true; do - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - _____ _ _ - | __ \ | | (_) - | | | | ___| |__ _ __ _ _ __ - | | | |/ _ \ _ \| |/ _ | _ \ - | |__| | __/ |_) | | (_| | | | | - |_____/ \___|_.__/|_|\__,_|_| |_| - -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=2 -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 1 - -memory 512 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some applications may not work properly due to ZFS not supporting 'fallocate'." -fi -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}. \n" diff --git a/ct/debian-v3.sh b/ct/debian-v3.sh deleted file mode 100644 index 79c9bdd1..00000000 --- a/ct/debian-v3.sh +++ /dev/null @@ -1,357 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -APP="Debian" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[0-9]+$' -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-install" -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}" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - _____ _ _ - | __ \ | | (_) - | | | | ___| |__ _ __ _ _ __ - | | | |/ _ \ _ \| |/ _ | _ \ - | |__| | __/ |_) | | (_| | | | | - |_${YW}v3${RD}__/ \___|_.__/|_|\__,_|_| |_| -${CL}" -} - -header_info - -function PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${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}Using ${BGN}$var_cpu${CL}${DGN}vCPU${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Using ${BGN}$var_ram${CL}${DGN}MiB 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: $var_disk " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: $var_cpu " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: $var_ram " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -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 - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/$var_install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/Proxmox" - -msg_ok "Completed Successfully!\n" diff --git a/ct/debian.sh b/ct/debian.sh new file mode 100644 index 00000000..2472b0ac --- /dev/null +++ b/ct/debian.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/deconz-v3.sh b/ct/deconz-v3.sh deleted file mode 100644 index 3679fb6c..00000000 --- a/ct/deconz-v3.sh +++ /dev/null @@ -1,371 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -APP="deCONZ" -var_disk="4" -var_cpu="2" -var_ram="1024" -var_os="ubuntu" -var_version="20.04" -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[0-9]+$' -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-install" -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}" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${YW} - _ _____ - | | / ____| - __| | v3_| | ___ _ __ ____ - / _ |/ _ \ | / _ \| _ \|_ / - | (_| | __/ |___| (_) | | | |/ / - \__,_|\___|\_____\___/|_| |_/___| -${CL}" -} - -header_info - -function PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Privileged${CL}" - CT_TYPE="0" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${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}Using ${BGN}$var_cpu${CL}${DGN}vCPU${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Using ${BGN}$var_ram${CL}${DGN}MiB 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Unprivileged, or Press [ENTER] for Default: Privileged" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Privileged" CT_TYPE="0"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Unprivileged" - CT_TYPE="1" - echo -en "${DGN}Set CT Type ${BL}Unprivileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: $var_disk " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: $var_cpu " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: $var_ram " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -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 - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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 <<EOF >> $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 -lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 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/setup/$var_install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..bf42af0c --- /dev/null +++ b/ct/deconz.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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.sh b/ct/deluge.sh new file mode 100644 index 00000000..897a3bf8 --- /dev/null +++ b/ct/deluge.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/docker-v2.sh b/ct/docker-v2.sh deleted file mode 100644 index 43ceb81b..00000000 --- a/ct/docker-v2.sh +++ /dev/null @@ -1,312 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will create a New Docker LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - _____ _ - | __ \ | | - | | | | ___ ___| | _____ _ __ - | | | |/ _ \ / __| |/ / _ \ __| - | |__| | (_) | (__| < __/ | - |_____/ \___/ \___|_|\_\___|_| -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${RD} If Using ZFS, You Have Storage Driver Options${CL}\n" - printf " ${RD} Non ZFS, Select Standard overlay2 Storage Driver${CL}\n" - printf " ${YW} 1)${GN} Use fuse-overlayfs Storage Driver${CL}\n" - printf " ${YW} 2)${GN} Use Standard overlay2 Storage Driver${CL}\n" - - printf "Please choose a Storage Driver and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using fuse-overlayfs Storage Driver"; - STORAGE_DRIVER="fuse" - break; - ;; - 2) clear; - header_info; - option_picked "Using overlay2 Storage Driver"; - STORAGE_DRIVER=" " - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Storage Driver from the menu"; - show_menu3; - ;; - esac - done -show_menu4(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message4=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" - printf " ${YW}${message4}${CL}\n" -} -show_menu4 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu4; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ] && [ "$STORAGE_DRIVER" == " " ]; then - FEATURES="nesting=1,keyctl=1" - elif - [ "$IM" == "1" ] && [ "$STORAGE_DRIVER" == "fuse" ]; then - FEATURES="nesting=1,keyctl=1,fuse=1" - elif - [ "$IM" == "0" ] && [ "$STORAGE_DRIVER" == "fuse" ]; then - FEATURES="nesting=1,fuse=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=4 -export PCT_OPTIONS=" - -features $FEATURES - -hostname docker - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 2 - -memory 2048 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - wget -qL -O fuse-overlayfs https://github.com/containers/fuse-overlayfs/releases/download/v1.8.2/fuse-overlayfs-x86_64 - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -fi -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - - if [ "$STORAGE_TYPE" == "zfspool" ] && [ "$STORAGE_DRIVER" == "fuse" ]; then - pct push $CTID fuse-overlayfs /usr/local/bin/fuse-overlayfs -perms 755 - info "Using ${BL}fuse-overlayfs${CL} Storage Driver." - else - info "Using ${BL}overlay2${CL} Storage Driver." - fi - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/docker-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created Docker LXC to${CL} ${BL}$CTID${CL}. \n" diff --git a/ct/docker-v3.sh b/ct/docker-v3.sh deleted file mode 100644 index 3c2c71a4..00000000 --- a/ct/docker-v3.sh +++ /dev/null @@ -1,361 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Docker" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - _____ _ - | __ \ | | - | | | | ___ ___| | _____ _ __ - | |v3| |/ _ \ / __| |/ / _ \ __| - | |__| | (_) | (__| < __/ | - |_____/ \___/ \___|_|\_\___|_| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}4${CL}${DGN}GB${CL}" - DISK_SIZE="4" - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="2048" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 4 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="4"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -PVE_CHECK -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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 <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -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/setup/docker-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/Proxmox" - -msg_ok "Completed Successfully!\n" diff --git a/ct/docker.sh b/ct/docker.sh new file mode 100644 index 00000000..ce263f9b --- /dev/null +++ b/ct/docker.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/dockge.sh b/ct/dockge.sh new file mode 100644 index 00000000..b1d943a4 --- /dev/null +++ b/ct/dockge.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Dockge" +var_disk="18" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/dockge ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP}" +cd /opt/dockge +docker compose pull +docker compose up -d +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}:5001${CL} \n" diff --git a/ct/emby.sh b/ct/emby.sh new file mode 100644 index 00000000..092a44a4 --- /dev/null +++ b/ct/emby.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="22.04" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 "Updated Successfully" +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.sh b/ct/emqx.sh new file mode 100644 index 00000000..6ec3cab7 --- /dev/null +++ b/ct/emqx.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/ersatztv.sh b/ct/ersatztv.sh new file mode 100644 index 00000000..81ea5b7b --- /dev/null +++ b/ct/ersatztv.sh @@ -0,0 +1,89 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: tteck +# Co-Author: MickLesk (Canbiz) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +# Source: https://github.com/ErsatzTV/ErsatzTV/ + + +function header_info { +clear +cat <<"EOF" + ______ __ _______ __ + / ____/_____________ _/ /_____/_ __/ | / / + / __/ / ___/ ___/ __ `/ __/_ / / / | | / / + / /___/ / (__ ) /_/ / /_ / /_/ / | |/ / +/_____/_/ /____/\__,_/\__/ /___/_/ |___/ + +EOF +} +header_info +echo -e "Loading..." +APP="ErsatzTV" +var_disk="5" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} +function update_script() { +header_info +if [[ ! -d /opt/ErsatzTV ]]; then msg_error "No ${APP} Installation Found!"; exit; fi + +msg_info "Stopping ErsatzTV" +systemctl stop ersatzTV +msg_ok "Stopped ErsatzTV" + +msg_info "Updating ErsatzTV" +RELEASE=$(curl -s https://api.github.com/repos/ErsatzTV/ErsatzTV/releases | grep -oP '"tag_name": "\K[^"]+' | head -n 1) +cp -R /opt/ErsatzTV/ ErsatzTV-backup +rm ErsatzTV-backup/ErsatzTV +rm -rf /opt/ErsatzTV +wget -qO- "https://github.com/ErsatzTV/ErsatzTV/releases/download/${RELEASE}/ErsatzTV-${RELEASE}-linux-x64.tar.gz" | tar -xz -C /opt +mv "/opt/ErsatzTV-${RELEASE}-linux-x64" /opt/ErsatzTV +cp -R ErsatzTV-backup/* /opt/ErsatzTV/ +rm -rf ErsatzTV-backup +msg_ok "Updated ErsatzTV" + +msg_info "Starting ErsatzTV" +systemctl start ersatzTV +msg_ok "Started ErsatzTV" +msg_ok "Updated Successfully" +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}:8409${CL} \n" diff --git a/ct/esphome-v1.sh b/ct/esphome-v1.sh deleted file mode 100644 index 902c9969..00000000 --- a/ct/esphome-v1.sh +++ /dev/null @@ -1,188 +0,0 @@ -#!/usr/bin/env bash - -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` - -while true; do - read -p "This will create a New ESPHome LXC Container. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${CL} - ______ _____ _____ _ _ ____ __ __ ______ - | ____|/ ____| __ \| | | |/ __ \| \/ | ____| - | |__ | (___ | |__) | |__| | | | | \ / | |__ - | __| \___ \| ___/| __ | | | | |\/| | __| - | |____ ____) | | | | | | |__| | | | | |____ - |______|_____/|_| |_| |_|\____/|_| |_|______| - -${CL}" -} - -header_info - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if [ ! -z ${MOUNT+x} ]; then - pct unmount $CTID - fi - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} -function load_module() { - if ! $(lsmod | grep -Fq $1); then - modprobe $1 &>/dev/null || \ - die "Failed to load '$1' module." - fi - MODULES_PATH=/etc/modules - if ! $(grep -Fxq "$1" $MODULES_PATH); then - echo "$1" >> $MODULES_PATH || \ - die "Failed to add '$1' module to load at boot." - fi -} -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/esphome_setup.sh - -load_module overlay - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content rootdir | awk 'NR>1') -if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then - warn "'Container' needs to be selected for at least one storage location." - die "Unable to detect valid storage location." -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 container?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit - done -fi -info "Using ${BL}$STORAGE${CL} for storage location." - -CTID=$(pvesh get /cluster/nextid) -info "Container ID is ${BL}$CTID.${CL}" - -echo -en "${GN} Updating LXC Template List... " -pveam update >/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Downloading LXC Template... " -OSTYPE=debian -OSVERSION=${OSTYPE}-11 -mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V) -TEMPLATE="${TEMPLATES[-1]}" -pveam download local $TEMPLATE >/dev/null || - die "A problem occured while downloading the LXC template." - -STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') -case $STORAGE_TYPE in - dir|nfs) - DISK_EXT=".raw" - DISK_REF="$CTID/" - ;; - zfspool) - DISK_PREFIX="subvol" - DISK_FORMAT="subvol" - ;; -esac -DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-} -ROOTFS=${STORAGE}:${DISK_REF-}${DISK} -echo -e "${CM}${CL} \r" - -echo -en "${GN} Creating LXC Container... " -DISK_SIZE=4G -pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -else - mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null -fi -ARCH=$(dpkg --print-architecture) -HOSTNAME=esphome -TEMPLATE_STRING="local:vztmpl/${TEMPLATE}" -pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \ - -hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 2 -memory 1024 \ - -ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null - -MOUNT=$(pct mount $CTID | cut -d"'" -f 2) -ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime -pct unmount $CTID && unset MOUNT -echo -e "${CM}${CL} \r" - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -pct push $CTID esphome_setup.sh /esphome_setup.sh -perms 755 -echo -e "${CM}${CL} \r" -pct exec $CTID /esphome_setup.sh - - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') -info "Successfully created ESPHome LXC Container to ${BL}$CTID${CL}" -echo -e "${CL} ESPHome should be reachable by going to the following URL. - ${BL}http://${IP}:6052${CL} -\n" diff --git a/ct/esphome-v2.sh b/ct/esphome-v2.sh deleted file mode 100644 index 8fcbf29b..00000000 --- a/ct/esphome-v2.sh +++ /dev/null @@ -1,259 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -APP="ESPHome" -HN=$(echo ${APP,,} | tr -d ' ') -while true; do - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - ______ _____ _____ _ _ ____ __ __ ______ - | ____|/ ____| __ \| | | |/ __ \| \/ | ____| - | |__ | (___ | |__) | |__| | | | | \ / | |__ - | __| \___ \| ___/| __ | | | | |\/| | __| - | |____ ____) | | | | | | |__| | | | | |____ - |______|_____/|_| |_| |_|\____/|_| |_|______| - -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=4 -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 2 - -memory 1024 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}. -${BL}${APP}${CL} should be reachable by going to the following URL. - ${BL}http://${IP}:6052${CL} \n" diff --git a/ct/esphome-v3.sh b/ct/esphome-v3.sh deleted file mode 100644 index b39f4f07..00000000 --- a/ct/esphome-v3.sh +++ /dev/null @@ -1,357 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="ESPHome" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - ______ _____ _____ _ _ ____ __ __ ______ - | ____|/ ____| __ \| | | |/ __ \| \/ | ____| - | |__ | (___ | |__) | |__| | | | | \ / | |__ - | __| \___ \| ___/| __ | | | | |\/| | __| - | |____ ____) | | | | | | |__| | | | | |____ - |______|_____/|_| v3 |_| |_|\____/|_| |_|______| - -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}4${CL}${DGN}GB${CL}" - DISK_SIZE="4" - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}1024${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="1024" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 4 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="4"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 1024 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="1024"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/esphome-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..7a2e0e87 --- /dev/null +++ b/ct/esphome.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/systemd/system/esphomeDashboard.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Stopping ESPHome" +systemctl stop esphomeDashboard +msg_ok "Stopped ESPHome" + +msg_info "Updating ESPHome" +if [[ -d /srv/esphome ]]; then + source /srv/esphome/bin/activate &>/dev/null +fi +pip3 install -U esphome &>/dev/null +msg_ok "Updated ESPHome" + +msg_info "Starting ESPHome" +systemctl start esphomeDashboard +msg_ok "Started ESPHome" +msg_ok "Updated Successfully" +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/fenrus.sh b/ct/fenrus.sh new file mode 100644 index 00000000..0f5e4d17 --- /dev/null +++ b/ct/fenrus.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Co-Author: Scorpoon +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ______ + / ____/__ ____ _______ _______ + / /_ / _ \/ __ \/ ___/ / / / ___/ + / __/ / __/ / / / / / /_/ (__ ) +/_/ \___/_/ /_/_/ \__,_/____/ + +EOF +} +header_info +echo -e "Loading..." +APP="Fenrus" +var_disk="4" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/${APP} ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_error "There is currently no update path available." +exit +msg_info "Updating ${APP}" +systemctl stop ${APP} +git clone https://github.com/revenz/Fenrus.git +cd Fenrus || exit +gitVersionNumber=$(git rev-parse HEAD) + +if [[ "${gitVersionNumber}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + mkdir /opt/fenrus-data-backup + cp -r "/opt/${APP}/data/" /opt/fenrus-data-backup/data + if [[ ! -d /opt/fenrus-data-backup/data ]]; then msg_error "Backup of data folder failed! exiting..."; rm -r /opt/fenrus-data-backup/; exit; fi + export DOTNET_CLI_TELEMETRY_OPTOUT=1 + dotnet publish -c Release -o "/opt/${APP}/" Fenrus.csproj + cp -r /opt/fenrus-data-backup/data/ "/opt/${APP}/" + echo "${gitVersionNumber}" >"/opt/${APP}_version.txt" + rm -r /opt/fenrus-data-backup/ + msg_ok "Updated $APP" +else + msg_ok "No update required. ${APP} is already up to date" +fi +cd .. +rm -r Fenrus/ + +systemctl start ${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}:5000${CL} \n" diff --git a/ct/fhem.sh b/ct/fhem.sh new file mode 100644 index 00000000..a98ce9ae --- /dev/null +++ b/ct/fhem.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Fhem" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/systemd/system/fhem.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 Successfully" +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}:8083${CL} \n" diff --git a/ct/flaresolverr.sh b/ct/flaresolverr.sh new file mode 100644 index 00000000..85cc927a --- /dev/null +++ b/ct/flaresolverr.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Co-Author: remz1337 +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ________ _____ __ + / ____/ /___ _________ / ___/____ / / _____ __________ + / /_ / / __ `/ ___/ _ \\__ \/ __ \/ / | / / _ \/ ___/ ___/ + / __/ / / /_/ / / / __/__/ / /_/ / /| |/ / __/ / / / +/_/ /_/\__,_/_/ \___/____/\____/_/ |___/\___/_/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="FlareSolverr" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + header_info + if [[ ! -f /etc/systemd/system/flaresolverr.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi + RELEASE=$(wget -q https://github.com/FlareSolverr/FlareSolverr/releases/latest -O - | grep "title>Release" | cut -d " " -f 4) + if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + msg_info "Updating $APP LXC" + systemctl stop flaresolverr + wget -q https://github.com/FlareSolverr/FlareSolverr/releases/download/$RELEASE/flaresolverr_linux_x64.tar.gz + tar -xzf flaresolverr_linux_x64.tar.gz -C /opt + rm flaresolverr_linux_x64.tar.gz + systemctl start flaresolverr + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated $APP LXC" + else + msg_ok "No update required. ${APP} is already at ${RELEASE}" + fi + exit +} + +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}:8191${CL} \n" diff --git a/ct/flowiseai.sh b/ct/flowiseai.sh new file mode 100644 index 00000000..4dc58f6b --- /dev/null +++ b/ct/flowiseai.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="FlowiseAI" +var_disk="10" +var_cpu="4" +var_ram="4096" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/systemd/system/flowise.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP}" +systemctl stop flowise +npm install -g flowise --upgrade +systemctl start flowise +msg_ok "Updated ${APP}" +exit +} + +start +build_container +description + +msg_info "Setting Container to Normal Resources" +pct set $CTID -memory 2048 +pct set $CTID -cores 2 +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}:3000${CL} \n" diff --git a/ct/forgejo.sh b/ct/forgejo.sh new file mode 100644 index 00000000..9df120ba --- /dev/null +++ b/ct/forgejo.sh @@ -0,0 +1,89 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Forgejo" +var_disk="10" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/forgejo ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Stopping ${APP}" +systemctl stop forgejo +msg_ok "Stopped ${APP}" + +msg_info "Updating ${APP}" +RELEASE=$(curl -s https://codeberg.org/api/v1/repos/forgejo/forgejo/releases/latest | grep -oP '"tag_name":\s*"\K[^"]+' | sed 's/^v//') +wget -qO forgejo-$RELEASE-linux-amd64 "https://codeberg.org/forgejo/forgejo/releases/download/v${RELEASE}/forgejo-${RELEASE}-linux-amd64" +rm -rf /opt/forgejo/* +cp -r forgejo-$RELEASE-linux-amd64 /opt/forgejo/forgejo-$RELEASE-linux-amd64 +chmod +x /opt/forgejo/forgejo-$RELEASE-linux-amd64 +ln -sf /opt/forgejo/forgejo-$RELEASE-linux-amd64 /usr/local/bin/forgejo +msg_ok "Updated ${APP}" + +msg_info "Cleaning" +rm -rf forgejo-$RELEASE-linux-amd64 +msg_ok "Cleaned" + +msg_info "Starting ${APP}" +systemctl start forgejo +msg_ok "Started ${APP}" +msg_ok "Updated Successfully" +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/frigate.sh b/ct/frigate.sh new file mode 100644 index 00000000..f3483013 --- /dev/null +++ b/ct/frigate.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Authors: 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="Frigate" +var_disk="20" +var_cpu="4" +var_ram="4096" +var_os="debian" +var_version="11" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + if [[ ! -f /etc/systemd/system/frigate.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi + msg_error "There is currently no update path available." + exit +} + +start +build_container +description + +msg_info "Setting Container to Normal Resources" +pct set $CTID -memory 1024 +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}:5000${CL} \n" +echo -e "go2rtc should be reachable by going to the following URL. + ${BL}http://${IP}:1984${CL} \n" diff --git a/ct/gitea.sh b/ct/gitea.sh new file mode 100644 index 00000000..6ab81615 --- /dev/null +++ b/ct/gitea.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Co-author: Rogue-King +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ______ _ __ + / ____/(_)/ /____ ____ _ + / / __// // __/ _ \/ __ / +/ /_/ // // /_/ __/ /_/ / +\____//_/ \__/\___/\__,_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Gitea" +var_disk="8" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /usr/local/bin/gitea ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +RELEASE=$(wget -q https://github.com/go-gitea/gitea/releases/latest -O - | grep "title>Release" | cut -d " " -f 4 | sed 's/^v//') +msg_info "Updating $APP to ${RELEASE}" +wget -q https://github.com/go-gitea/gitea/releases/download/v$RELEASE/gitea-$RELEASE-linux-amd64 +systemctl stop gitea +rm -rf /usr/local/bin/gitea +mv gitea* /usr/local/bin/gitea +chmod +x /usr/local/bin/gitea +systemctl start gitea +msg_ok "Updated $APP Successfully" +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/go2rtc.sh b/ct/go2rtc.sh new file mode 100644 index 00000000..380ed801 --- /dev/null +++ b/ct/go2rtc.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/go2rtc ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP" +systemctl stop go2rtc +cd /opt/go2rtc +rm go2rtc_linux_amd64 +wget -q https://github.com/AlexxIT/go2rtc/releases/latest/download/go2rtc_linux_amd64 +chmod +x go2rtc_linux_amd64 +systemctl start go2rtc +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}:1984${CL} \n" diff --git a/ct/gokapi.sh b/ct/gokapi.sh new file mode 100644 index 00000000..942cc560 --- /dev/null +++ b/ct/gokapi.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Gokapi" +var_disk="4" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/gokapi ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_error "There is currently no update path available." +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}:53842/setup${CL} \n" diff --git a/ct/gotify.sh b/ct/gotify.sh new file mode 100644 index 00000000..15f911df --- /dev/null +++ b/ct/gotify.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Gotify" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/gotify ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_error "There is currently no update path available." +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/grafana-v2.sh b/ct/grafana-v2.sh deleted file mode 100644 index 04d65207..00000000 --- a/ct/grafana-v2.sh +++ /dev/null @@ -1,252 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will create a New Grafana LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${YW} - _____ __ - / ____| / _| - | | __ _ __ __ _| |_ __ _ _ __ __ _ - | | |_ | __/ _ | _/ _ | _ \ / _ | - | |__| | | | (_| | || (_| | | | | (_| | - \_____|_| \__,_|_| \__,_|_| |_|\__,_| - -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=2 -export PCT_OPTIONS=" - -features $FEATURES - -hostname grafana - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 1 - -memory 512 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/grafana-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created Grafana LXC to${CL} ${BL}$CTID${CL}. -${BL}Grafana${CL} should be reachable by going to the following URL. - ${BL}http://${IP}:3000${CL} \n" diff --git a/ct/grafana-v3.sh b/ct/grafana-v3.sh deleted file mode 100644 index cf708a67..00000000 --- a/ct/grafana-v3.sh +++ /dev/null @@ -1,356 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Grafana" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${YW} - _____ __ - / ____| / _| - | | __ _ __ __ _| |_ __ _ _ __ __ _ - | | |_ | __/ _ | _/ _ | _ \ / _ | - | |__| | | | (_| | || (_| | | | | (_| | - \_____|_|v3\__,_|_| \__,_|_| |_|\__,_| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}2${CL}${DGN}GB${CL}" - DISK_SIZE="2" - echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}" - CORE_COUNT="1" - echo -e "${DGN}Using ${BGN}512${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="512" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 2 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="2"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 512 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="512"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/grafana-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..b5ea2aa9 --- /dev/null +++ b/ct/grafana.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/grafana.list ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP}" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated Successfully" +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-v3.sh b/ct/grocy-v3.sh deleted file mode 100644 index 38f6b555..00000000 --- a/ct/grocy-v3.sh +++ /dev/null @@ -1,359 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -APP="grocy" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[0-9]+$' -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-install" -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}" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${YW} - __ _ _ __ ___ ___ _ _ - / _ | __/ _ \ / __| | | | - | (_| | | | (_) | (__| |_| | - \__, |_| \___/ \___|\__, | - __/ | v3 __/ | - |___/ |___/ -${CL}" -} - -header_info - -function PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${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}Using ${BGN}$var_cpu${CL}${DGN}vCPU${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Using ${BGN}$var_ram${CL}${DGN}MiB 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: $var_disk " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: $var_cpu " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: $var_ram " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -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 - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/$var_install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..fc48644b --- /dev/null +++ b/ct/grocy.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 +php_version=$(php -v | head -n 1 | awk '{print $2}') +if [[ ! $php_version == "8.3"* ]]; then + msg_info "Updating PHP" + curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg + echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ bookworm main" >/etc/apt/sources.list.d/php.list + apt-get update + apt-get install -y php8.3 php8.3-cli php8.3-{bz2,curl,mbstring,intl,sqlite3,fpm,gd,zip,xml} + systemctl reload apache2 + apt autoremove + msg_ok "Updated PHP" +fi +msg_info "Updating ${APP}" +bash /var/www/html/update.sh +msg_ok "Updated Successfully" +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/headscale.sh b/ct/headscale.sh new file mode 100644 index 00000000..f50347eb --- /dev/null +++ b/ct/headscale.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Headscale" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /etc/headscale ]]; then msg_error "No ${APP} Installation Found!"; exit; fi + +RELEASE=$(curl -s https://api.github.com/repos/juanfont/headscale/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + msg_info "Stopping ${APP}" + systemctl stop headscale + msg_ok "Stopped ${APP}" + + msg_info "Updating $APP to v${RELEASE}" + wget -q https://github.com/juanfont/headscale/releases/download/v${RELEASE}/headscale_${RELEASE}_linux_amd64.deb + dpkg -i headscale_${RELEASE}_linux_amd64.deb + rm headscale_${RELEASE}_linux_amd64.deb + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated $APP to ${RELEASE}" + + msg_info "Starting ${APP}" + systemctl start headscale + msg_ok "Started ${APP}" + msg_ok "Updated Successfully" +else + msg_ok "No update required. ${APP} is already at ${RELEASE}" +fi +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/heimdall-dashboard.sh b/ct/heimdall-dashboard.sh new file mode 100644 index 00000000..04db1ea7 --- /dev/null +++ b/ct/heimdall-dashboard.sh @@ -0,0 +1,111 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 +RELEASE=$(curl -sX GET "https://api.github.com/repos/linuxserver/Heimdall/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]') +if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + msg_info "Stopping ${APP}" + systemctl stop heimdall + sleep 1 + msg_ok "Stopped ${APP}" + + msg_info "Backing up Data" + cp -R /opt/Heimdall/database database-backup + cp -R /opt/Heimdall/public public-backup + sleep 1 + msg_ok "Backed up Data" + + msg_info "Updating Heimdall Dashboard to ${RELEASE}" + wget -q https://github.com/linuxserver/Heimdall/archive/${RELEASE}.tar.gz + tar xzf ${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) }') + cp -R Heimdall-${VER}/* /opt/Heimdall + cd /opt/Heimdall + apt-get install -y composer &>/dev/null + COMPOSER_ALLOW_SUPERUSER=1 composer dump-autoload &>/dev/null + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated Heimdall Dashboard to ${RELEASE}" + + msg_info "Restoring Data" + cd ~ + cp -R database-backup/* /opt/Heimdall/database + cp -R public-backup/* /opt/Heimdall/public + sleep 1 + msg_ok "Restored Data" + + msg_info "Cleanup" + rm -rf {${RELEASE}.tar.gz,Heimdall-${VER},public-backup,database-backup,Heimdall} + sleep 1 + msg_ok "Cleaned" + + msg_info "Starting ${APP}" + systemctl start heimdall.service + sleep 2 + msg_ok "Started ${APP}" + msg_ok "Updated Successfully" +else + msg_ok "No update required. ${APP} is already at ${RELEASE}." +fi +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/heimdalldashboard-v2.sh b/ct/heimdalldashboard-v2.sh deleted file mode 100644 index 1a60e74c..00000000 --- a/ct/heimdalldashboard-v2.sh +++ /dev/null @@ -1,259 +0,0 @@ -#!/usr/bin/env bash -PP=`echo "\e[1;35m"` -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -APP="Heimdall Dashboard" -HN=$(echo ${APP,,} | tr -d ' ') -while true; do - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${PP} - _ _ _ _ _ _ _____ _ _ _ - | | | | (_) | | | | | | __ \ | | | | | | - | |__| | ___ _ _ __ ___ __| | __ _| | | | | | | __ _ ___| |__ | |__ ___ __ _ _ __ __| | - | __ |/ _ \ | _ _ \ / _ |/ _ | | | | | | |/ _ / __| _ \| _ \ / _ \ / _ | __/ _ | - | | | | __/ | | | | | | (_| | (_| | | | | |__| | (_| \__ \ | | | |_) | (_) | (_| | | | (_| | - |_| |_|\___|_|_| |_| |_|\__,_|\__,_|_|_| |_____/ \__,_|___/_| |_|_.__/ \___/ \__,_|_| \__,_| -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and press [ENTER] or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and press [ENTER] or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and press [ENTER] or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=2 -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 1 - -memory 512 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press [ENTER]." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}. -${BL}${APP}${CL} should be reachable by going to the following URL. - ${BL}http://${IP}:7990${CL} \n" diff --git a/ct/heimdalldashboard-v3.sh b/ct/heimdalldashboard-v3.sh deleted file mode 100644 index 1a1eb641..00000000 --- a/ct/heimdalldashboard-v3.sh +++ /dev/null @@ -1,357 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[0-9]+$' -PP=`echo "\e[1;35m"` -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}" -APP="Heimdall Dashboard" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${PP} - _ _ _ _ _ _ _____ _ _ _ - | | | | (_) | | | | | | __ \ | | | | | | - | |__| | ___ _ _ __ ___ __| | __v3| | | | | | | __ _ ___| |__ | |__ ___ __ _ _ __ __| | - | __ |/ _ \ | _ _ \ / _ |/ _ | | | | | | |/ _ / __| _ \| _ \ / _ \ / _ | __/ _ | - | | | | __/ | | | | | | (_| | (_| | | | | |__| | (_| \__ \ | | | |_) | (_) | (_| | | | (_| | - |_| |_|\___|_|_| |_| |_|\__,_|\__,_|_|_| |_____/ \__,_|___/_| |_|_.__/ \___/ \__,_|_| \__,_| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}2${CL}${DGN}GB${CL}" - DISK_SIZE="2" - echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}" - CORE_COUNT="1" - echo -e "${DGN}Using ${BGN}512${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="512" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 2 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="2"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 512 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="512"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/heimdalldashboard-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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/hivemq.sh b/ct/hivemq.sh new file mode 100644 index 00000000..80b79c81 --- /dev/null +++ b/ct/hivemq.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="HiveMQ" +var_disk="4" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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_error "There is currently no update path available." +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/homarr.sh b/ct/homarr.sh new file mode 100644 index 00000000..a42089f9 --- /dev/null +++ b/ct/homarr.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Homarr" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/homarr ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP (Patience)" +systemctl stop homarr +cd /opt/homarr +if ! git pull; then + echo "Already up to date." + systemctl start homarr + echo "No update required." + exit +fi +yarn install +yarn build +systemctl start homarr +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}:3000${CL} \n" diff --git a/ct/homeassistant-core.sh b/ct/homeassistant-core.sh new file mode 100644 index 00000000..01c1c36f --- /dev/null +++ b/ct/homeassistant-core.sh @@ -0,0 +1,156 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="ubuntu" +var_version="24.04" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 --backtitle "Proxmox VE Helper Scripts" --title "UPDATE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 4 \ + "1" "Update Core" ON \ + "2" "Install HACS" OFF \ + "3" "Install FileBrowser" OFF \ + 3>&1 1>&2 2>&3) + header_info + if [ "$UPD" == "1" ]; then + if (whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SELECT BRANCH" --yesno "Use Beta Branch?" 10 58); then + clear + header_info + echo -e "${GN}Updating to Beta Version${CL}" + BR="--pre " + else + clear + header_info + echo -e "${GN}Updating to Stable Version${CL}" + BR="" + fi + if [[ "$PY" == "python3.11" ]]; then echo -e "⚠️ Home Assistant will soon require Python 3.12."; 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 Community 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 Community Store (HACS)" + echo -e "\n Reboot Home Assistant and clear browser cache then Add HACS integration.\n" + exit + fi + if [ "$UPD" == "3" ]; then + set +Eeuo pipefail + read -r -p "Would you like to use No Authentication? <y/N> " prompt + msg_info "Installing FileBrowser" + RELEASE=$(curl -fsSL https://api.github.com/repos/filebrowser/filebrowser/releases/latest | grep -o '"tag_name": ".*"' | sed 's/"//g' | sed 's/tag_name: //g') + curl -fsSL https://github.com/filebrowser/filebrowser/releases/download/$RELEASE/linux-amd64-filebrowser.tar.gz | tar -xzv -C /usr/local/bin &>/dev/null + + if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + filebrowser config init -a '0.0.0.0' &>/dev/null + filebrowser config set -a '0.0.0.0' &>/dev/null + filebrowser config set --auth.method=noauth &>/dev/null + filebrowser users add ID 1 --perm.admin &>/dev/null + else + 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 + fi + 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 -q filebrowser.service + 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}" diff --git a/ct/homeassistant-v1.sh b/ct/homeassistant-v1.sh deleted file mode 100644 index 40c7652e..00000000 --- a/ct/homeassistant-v1.sh +++ /dev/null @@ -1,176 +0,0 @@ -#!/usr/bin/env bash - -while true; do - read -p "This will create a New Home Assistant Container LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if [ ! -z ${MOUNT+x} ]; then - pct unmount $CTID - fi - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} -function load_module() { - if ! $(lsmod | grep -Fq $1); then - modprobe $1 &>/dev/null || \ - die "Failed to load '$1' module." - fi - MODULES_PATH=/etc/modules - if ! $(grep -Fxq "$1" $MODULES_PATH); then - echo "$1" >> $MODULES_PATH || \ - die "Failed to add '$1' module to load at boot." - fi -} -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/ha_setup.sh - -load_module overlay - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content rootdir | awk 'NR>1') -if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then - warn "'Container' needs to be selected for at least one storage location." - die "Unable to detect valid storage location." -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 container?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit - done -fi -info "Using '$STORAGE' for storage location." -CTID=$(pvesh get /cluster/nextid) -info "Container ID is $CTID." - -echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m" -pveam update >/dev/null -echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m" -OSTYPE=debian -OSVERSION=${OSTYPE}-11 -mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V) -TEMPLATE="${TEMPLATES[-1]}" -pveam download local $TEMPLATE >/dev/null || - die "A problem occured while downloading the LXC template." - -STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') -case $STORAGE_TYPE in - dir|nfs) - DISK_EXT=".raw" - DISK_REF="$CTID/" - ;; - zfspool) - DISK_PREFIX="subvol" - DISK_FORMAT="subvol" - ;; -esac -DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-} -ROOTFS=${STORAGE}:${DISK_REF-}${DISK} - -echo -e "${CHECKMARK} \e[1;92m Creating LXC Container... \e[0m" -DISK_SIZE=8G -pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null -if [ "$STORAGE_TYPE" == "zfspool" ]; then - wget -qL -O fuse-overlayfs https://github.com/containers/fuse-overlayfs/releases/download/v1.8.2/fuse-overlayfs-x86_64 - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -else - mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null -fi - ARCH=$(dpkg --print-architecture) -HOSTNAME=homeassistant -TEMPLATE_STRING="local:vztmpl/${TEMPLATE}" -if [ "$STORAGE_TYPE" == "zfspool" ]; then - CT_FEATURES="fuse=1,keyctl=1,mknod=1,nesting=1" -else - CT_FEATURES="nesting=1" -fi -pct create $CTID $TEMPLATE_STRING -arch $ARCH -features $CT_FEATURES \ - -hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 2 -memory 2048 \ - -ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF - -MOUNT=$(pct mount $CTID | cut -d"'" -f 2) -ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime -pct unmount $CTID && unset MOUNT - -echo -e "${CHECKMARK} \e[1;92m Starting LXC Container... \e[0m" -pct start $CTID -if [ "$STORAGE_TYPE" == "zfspool" ]; then -pct push $CTID fuse-overlayfs /usr/local/bin/fuse-overlayfs -perms 755 -info "Using fuse-overlayfs." -fi -pct push $CTID ha_setup.sh /ha_setup.sh -perms 755 -pct exec $CTID /ha_setup.sh -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') -info "Successfully Created Home Assistant Container LXC to $CTID." -msg " - -Home Assistant should be reachable by going to the following URL. - - http://${IP}:8123 -" diff --git a/ct/homeassistant-v2.sh b/ct/homeassistant-v2.sh deleted file mode 100644 index 938b6921..00000000 --- a/ct/homeassistant-v2.sh +++ /dev/null @@ -1,316 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[94m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will create a New Home Assistant Container LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - _ _ _ _ - | | (_) | | | | - | |__ ___ _ __ ___ ___ __ _ ___ ___ _ ___| |_ __ _ _ __ | |_ - | _ \ / _ \| _ _ \ / _ \/ _ / __/ __| / __| __/ _ | _ \| __| - | | | | (_) | | | | | | __/ (_| \__ \__ \ \__ \ || (_| | | | | |_ - |_| |_|\___/|_| |_| |_|\___|\__,_|___/___/_|___/\__\__,_|_| |_|\__| - -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${RD} If Using ZFS, You Have Storage Driver Options${CL}\n" - printf " ${RD} Non ZFS, Select Standard overlay2 Storage Driver${CL}\n" - printf " ${YW} 1)${GN} Use fuse-overlayfs Storage Driver${CL}\n" - printf " ${YW} 2)${GN} Use Standard overlay2 Storage Driver${CL}\n" - - printf "Please choose a Storage Driver and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using fuse-overlayfs Storage Driver"; - STORAGE_DRIVER="fuse" - break; - ;; - 2) clear; - header_info; - option_picked "Using overlay2 Storage Driver"; - STORAGE_DRIVER=" " - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Storage Driver from the menu"; - show_menu3; - ;; - esac - done -show_menu4(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message4=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" - printf " ${YW}${message4}${CL}\n" -} -show_menu4 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu4; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ] && [ "$STORAGE_DRIVER" == " " ]; then - FEATURES="nesting=1,keyctl=1" - elif - [ "$IM" == "1" ] && [ "$STORAGE_DRIVER" == "fuse" ]; then - FEATURES="nesting=1,keyctl=1,fuse=1" - elif - [ "$IM" == "0" ] && [ "$STORAGE_DRIVER" == "fuse" ]; then - FEATURES="nesting=1,fuse=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=16 -export PCT_OPTIONS=" - -features $FEATURES - -hostname homeassistant - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 2 - -memory 2048 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - wget -qL -O fuse-overlayfs https://github.com/containers/fuse-overlayfs/releases/download/v1.8.2/fuse-overlayfs-x86_64 - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -fi -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - - if [ "$STORAGE_TYPE" == "zfspool" ] && [ "$STORAGE_DRIVER" == "fuse" ]; then - pct push $CTID fuse-overlayfs /usr/local/bin/fuse-overlayfs -perms 755 - info "Using ${BL}fuse-overlayfs${CL} Storage Driver." - else - info "Using ${BL}overlay2${CL} Storage Driver." - fi - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/homeassistant-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created Home Assistant Container LXC to${CL} ${BL}$CTID${CL}. -${BL}Home Assistant${CL} should be reachable by going to the following URL. - - ${BL}http://${IP}:8123${CL} \n" diff --git a/ct/homeassistant-v3.sh b/ct/homeassistant-v3.sh deleted file mode 100644 index ad4dc553..00000000 --- a/ct/homeassistant-v3.sh +++ /dev/null @@ -1,365 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Home Assistant" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - _ _ _ _ - | | ${YW}v3${CL}${BL} (_) | | | | - | |__ ___ _ __ ___ ___ __ _ ___ ___ _ ___| |_ __ _ _ __ | |_ - | _ \ / _ \| _ _ \ / _ \/ _ / __/ __| / __| __/ _ | _ \| __| - | | | | (_) | | | | | | __/ (_| \__ \__ \ \__ \ || (_| | | | | |_ - |_| |_|\___/|_| |_| |_|\___|\__,_|___/___/_|___/\__\__,_|_| |_|\__| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}16${CL}${DGN}GB${CL}" - DISK_SIZE="16" - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="2048" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 16 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="16"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -PVE_CHECK -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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 <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -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/setup/homeassistant-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..3f2c63ed --- /dev/null +++ b/ct/homeassistant.sh @@ -0,0 +1,141 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 --backtitle "Proxmox VE Helper Scripts" --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 Community 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 Community 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" + RELEASE=$(curl -fsSL https://api.github.com/repos/filebrowser/filebrowser/releases/latest | grep -o '"tag_name": ".*"' | sed 's/"//g' | sed 's/tag_name: //g') + curl -fsSL https://github.com/filebrowser/filebrowser/releases/download/v2.23.0/linux-amd64-filebrowser.tar.gz | tar -xzv -C /usr/local/bin &>/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}https://${IP}:9443${CL}\n" diff --git a/ct/homebridge-v2.sh b/ct/homebridge-v2.sh deleted file mode 100644 index 3e045697..00000000 --- a/ct/homebridge-v2.sh +++ /dev/null @@ -1,251 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will create a New Homebridge LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${YW} - _ _ ____ __ __ ______ ____ _____ _____ _____ _____ ______ - | | | |/ __ \| \/ | ____| _ \| __ \|_ _| __ \ / ____| ____| - | |__| | | | | \ / | |__ | |_) | |__) | | | | | | | | __| |__ - | __ | | | | |\/| | __| | _ <| _ / | | | | | | | |_ | __| - | | | | |__| | | | | |____| |_) | | \ \ _| |_| |__| | |__| | |____ - |_| |_|\____/|_| |_|______|____/|_| \_\_____|_____/ \_____|______| -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=4 -export PCT_OPTIONS=" - -features $FEATURES - -hostname homebridge - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 1 - -memory 1024 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/homebridge-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created Homebridge LXC to${CL} ${BL}$CTID${CL}. -${BL}Homebridge${CL} should be reachable by going to the following URL. - ${BL}http://${IP}:8581${CL} \n" diff --git a/ct/homebridge-v3.sh b/ct/homebridge-v3.sh deleted file mode 100644 index 629a9a19..00000000 --- a/ct/homebridge-v3.sh +++ /dev/null @@ -1,356 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Homebridge" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${YW} - _ _ ____ __ __ ______ ____ _____ _____ _____ _____ ______ - | | | |/ __ \| \/ | ____| _ \| __ \|_ _| __ \ / ____| ____| - | |__| | | | | \ / | |__ | |_) | |__) | | | | | | | | __| |__ - | __ | | | | |\/| | __| | _ <| _ / | | | | | | | |_ | __| - | | | | |__| | | | | |____| |_) | | \ \ _| |_| |__| | |__| | |____ - |_|v3|_|\____/|_| |_|______|____/|_| \_\_____|_____/ \_____|______| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}4${CL}${DGN}GB${CL}" - DISK_SIZE="4" - echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}" - CORE_COUNT="1" - echo -e "${DGN}Using ${BGN}1024${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="1024" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 4 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="4"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 1024 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="1024"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/homebridge-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/Proxmox" - -msg_ok "Completed Successfully!\n" -echo -e "Homebridge 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..d252b52b --- /dev/null +++ b/ct/homebridge.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/homebridge.list ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP} LXC" +apt-get update &>/dev/null +apt-get install -y homebridge &>/dev/null +msg_ok "Updated Successfully" +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.sh b/ct/homepage.sh new file mode 100644 index 00000000..716da76b --- /dev/null +++ b/ct/homepage.sh @@ -0,0 +1,94 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 +if [[ "$(node -v | cut -d 'v' -f 2)" == "18."* ]]; then + if ! command -v npm >/dev/null 2>&1; then + echo "Installing NPM..." + apt-get install -y npm >/dev/null 2>&1 + npm install -g pnpm >/dev/null 2>&1 + echo "Installed NPM..." + fi +fi +RELEASE=$(curl -s https://api.github.com/repos/gethomepage/homepage/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + msg_info "Updating Homepage to v${RELEASE} (Patience)" + systemctl stop homepage + wget -q https://github.com/gethomepage/homepage/archive/refs/tags/v${RELEASE}.tar.gz + tar -xzf v${RELEASE}.tar.gz + rm -rf v${RELEASE}.tar.gz + cp -r homepage-${RELEASE}/* /opt/homepage/ + rm -rf homepage-${RELEASE} + cd /opt/homepage + npx update-browserslist-db@latest + pnpm install + pnpm build + systemctl start homepage + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated Homepage to v${RELEASE}" +else + msg_ok "No update required. ${APP} is already at ${RELEASE}" +fi +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.sh b/ct/homer.sh new file mode 100644 index 00000000..bfec3090 --- /dev/null +++ b/ct/homer.sh @@ -0,0 +1,97 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 assets directory" +cd ~ +mkdir -p assets-backup +cp -R /opt/homer/assets/. assets-backup +msg_ok "Backed up assets directory" + +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 assets directory" +cd ~ +cp -Rf assets-backup/. /opt/homer/assets/ +msg_ok "Restored assets directory" + +msg_info "Cleaning" +rm -rf assets-backup /opt/homer/homer.zip +msg_ok "Cleaned" + +msg_info "Starting ${APP}" +systemctl start homer +msg_ok "Started ${APP}" +msg_ok "Updated Successfully" +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/hyperhdr.sh b/ct/hyperhdr.sh new file mode 100644 index 00000000..7c04a596 --- /dev/null +++ b/ct/hyperhdr.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="HyperHDR" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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}:8090${CL} \n" diff --git a/ct/hyperion.sh b/ct/hyperion.sh new file mode 100644 index 00000000..4edd8dd8 --- /dev/null +++ b/ct/hyperion.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 Successfully" +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-v2.sh b/ct/influxdb-v2.sh deleted file mode 100644 index 0d9e113c..00000000 --- a/ct/influxdb-v2.sh +++ /dev/null @@ -1,250 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will create a New InfluxDB LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${YW} - _____ __ _ _____ ____ - |_ _| / _| | | __ \| _ \ - | | _ __ | |_| |_ ___ _| | | | |_) | - | | | _ \| _| | | | \ \/ / | | | _ < - _| |_| | | | | | | |_| |> <| |__| | |_) | - |_____|_| |_|_| |_|\__,_/_/\_\_____/|____/ - with Telegraf -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=8 -export PCT_OPTIONS=" - -features $FEATURES - -hostname influxdb - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 2 - -memory 2048 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/influxdb-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created InfluxDB LXC to${CL} ${BL}$CTID${CL}. \n" diff --git a/ct/influxdb-v3.sh b/ct/influxdb-v3.sh deleted file mode 100644 index d4288d8b..00000000 --- a/ct/influxdb-v3.sh +++ /dev/null @@ -1,355 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="InfluxDB" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${YW} - _____ __ _ _____ ____ - |_ _| / _| | | __ \| _ \ - | | _ __ | |_| |_ v3___ _| | | | |_) | - | | | _ \| _| | | | \ \/ / | | | _ < - _| |_| | | | | | | |_| |> <| |__| | |_) | - |_____|_| |_|_| |_|\__,_/_/\_\_____/|____/ - with Telegraf -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}8${CL}${DGN}GB${CL}" - DISK_SIZE="8" - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="2048" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 8 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="8"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/influxdb-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/Proxmox" - -msg_ok "Completed Successfully!\n" diff --git a/ct/influxdb.sh b/ct/influxdb.sh new file mode 100644 index 00000000..2d995f6b --- /dev/null +++ b/ct/influxdb.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="InfluxDB" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/influxdata.list ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP}" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated Successfully" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/iobroker-v3.sh b/ct/iobroker-v3.sh deleted file mode 100644 index f6a52106..00000000 --- a/ct/iobroker-v3.sh +++ /dev/null @@ -1,356 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="ioBroker" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - _ ____ _ - (_) | _ \ | | - _ ___ | |_) |_ __ ___ | | _____ _ __ - | |/ _ \| _ <| __/ _ \| |/ / _ \ __| - | | (_) | |_) | | | (_) | < __/ | - |_|\___/|____/|_|v3\___/|_|\_\___|_| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}8${CL}${DGN}GB${CL}" - DISK_SIZE="8" - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="2048" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 8 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="8"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/iobroker-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..0bbd1d0f --- /dev/null +++ b/ct/iobroker.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 Successfully" +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/iventoy.sh b/ct/iventoy.sh new file mode 100644 index 00000000..08e067ab --- /dev/null +++ b/ct/iventoy.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="iVentoy" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +if [[ ! -d /opt/iventoy ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_error "There is currently no update path available." +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}:26000/ ${CL} \n" \ No newline at end of file diff --git a/ct/jackett.sh b/ct/jackett.sh new file mode 100644 index 00000000..278373d0 --- /dev/null +++ b/ct/jackett.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 +RELEASE=$(wget -q https://github.com/Jackett/Jackett/releases/latest -O - | grep "title>Release" | cut -d " " -f 4) +if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + msg_info "Updating ${APP}" + wget -q https://github.com/Jackett/Jackett/releases/download/$RELEASE/Jackett.Binaries.LinuxAMDx64.tar.gz + systemctl stop jackett + rm -rf /opt/Jackett + tar -xzf Jackett.Binaries.LinuxAMDx64.tar.gz -C /opt + rm -rf Jackett.Binaries.LinuxAMDx64.tar.gz + systemctl start jackett + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated ${APP} to ${RELEASE}" +else + msg_ok "No update required. ${APP} is already at ${RELEASE}" +fi +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-v1.sh b/ct/jellyfin-v1.sh deleted file mode 100644 index 3b8e674a..00000000 --- a/ct/jellyfin-v1.sh +++ /dev/null @@ -1,171 +0,0 @@ -#!/usr/bin/env bash - -while true; do - read -p "This will create a Jellyfin Media Server LXC Container. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if [ ! -z ${MOUNT+x} ]; then - pct unmount $CTID - fi - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} -function load_module() { - if ! $(lsmod | grep -Fq $1); then - modprobe $1 &>/dev/null || \ - die "Failed to load '$1' module." - fi - MODULES_PATH=/etc/modules - if ! $(grep -Fxq "$1" $MODULES_PATH); then - echo "$1" >> $MODULES_PATH || \ - die "Failed to add '$1' module to load at boot." - fi -} -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/jellyfin_setup.sh - -load_module overlay - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content rootdir | awk 'NR>1') -if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then - warn "'Container' needs to be selected for at least one storage location." - die "Unable to detect valid storage location." -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 container?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit - done -fi -info "Using '$STORAGE' for Storage Location." - -CTID=$(pvesh get /cluster/nextid) -info "Container ID is $CTID." - -echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m" -pveam update >/dev/null -echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m" -OSTYPE=ubuntu -OSVERSION=${OSTYPE}-20.04 -mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V) -TEMPLATE="${TEMPLATES[-1]}" -pveam download local $TEMPLATE >/dev/null || - die "A problem occured while downloading the LXC template." - -STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') -case $STORAGE_TYPE in - dir|nfs) - DISK_EXT=".raw" - DISK_REF="$CTID/" - ;; - zfspool) - DISK_PREFIX="subvol" - DISK_FORMAT="subvol" - ;; -esac -DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-} -ROOTFS=${STORAGE}:${DISK_REF-}${DISK} - -echo -e "${CHECKMARK} \e[1;92m Creating LXC Container... \e[0m" -DISK_SIZE=8G -pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -else - mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null -fi -ARCH=$(dpkg --print-architecture) -HOSTNAME=jellyfin -TEMPLATE_STRING="local:vztmpl/${TEMPLATE}" -pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \ - -hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 2 -memory 2048\ - -ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null - -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $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.mount.entry: /dev/dri dev/dri none bind,optional,create=dir -lxc.mount.entry: /dev/dri/card0 dev/dri/card0 none bind,optional,create=file -lxc.mount.entry: /dev/dri/renderD128 dev/renderD128 none bind,optional,create=file -EOF - -MOUNT=$(pct mount $CTID | cut -d"'" -f 2) -ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime -pct unmount $CTID && unset MOUNT - -echo -e "${CHECKMARK} \e[1;92m Starting LXC Container... \e[0m" -pct start $CTID -pct push $CTID jellyfin_setup.sh /jellyfin_setup.sh -perms 755 -pct exec $CTID /jellyfin_setup.sh - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') -info "Successfully Created Jellyfin Media Server LXC to $CTID." -echo -e "\e[1;92m Jellyfin Media Server should be reachable by going to the following URL. - http://${IP}:8096 -\e[0m" diff --git a/ct/jellyfin-v3.sh b/ct/jellyfin-v3.sh deleted file mode 100644 index 59b4cae9..00000000 --- a/ct/jellyfin-v3.sh +++ /dev/null @@ -1,370 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Jellyfin" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${DGN} - _ _ _ __ _ - | | | | | / _(_) - | | ___| | |_v3 _| |_ _ _ __ - _ | |/ _ \ | | | | | _| | _ \ - | |__| | __/ | | |_| | | | | | | | - \____/ \___|_|_|\__, |_| |_|_| |_| - __/ | - |___/ -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Privileged${CL}" - CT_TYPE="0" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}8${CL}${DGN}GB${CL}" - DISK_SIZE="8" - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="2048" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type ${CROSS}${YW}Unprivileged, or Press [ENTER] for Default: Privileged" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Privileged" CT_TYPE="0"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Unprivileged" - CT_TYPE="1" - echo -en "${DGN}Set CT Type ${BL}Unprivileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 8 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="8"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -PVE_CHECK -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=ubuntu -export PCT_OSVERSION=20.04 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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 <<EOF >> $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/renderD128 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/setup/jellyfin-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/Proxmox" - -msg_ok "Completed Successfully!\n" -echo -e "Jellyfin Media Server 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..079836c2 --- /dev/null +++ b/ct/jellyfin.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="22.04" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/jellyseerr.sh b/ct/jellyseerr.sh new file mode 100644 index 00000000..5f3548bf --- /dev/null +++ b/ct/jellyseerr.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Jellyseerr" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/jellyseerr ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP" +systemctl stop jellyseerr +cd /opt/jellyseerr +output=$(git pull) +git pull &>/dev/null +if echo "$output" | grep -q "Already up to date." +then + msg_ok " $APP is already up to date." + systemctl start jellyseerr + exit +fi +CYPRESS_INSTALL_BINARY=0 yarn install --frozen-lockfile --network-timeout 1000000 &>/dev/null +yarn build &>/dev/null +systemctl start jellyseerr +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}:5055${CL} \n" diff --git a/ct/k0s.sh b/ct/k0s.sh new file mode 100644 index 00000000..3b62bfc6 --- /dev/null +++ b/ct/k0s.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 Successfully" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/kavita.sh b/ct/kavita.sh new file mode 100644 index 00000000..206778fb --- /dev/null +++ b/ct/kavita.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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" +systemctl stop kavita +RELEASE=$(curl -s https://api.github.com/repos/Kareadita/Kavita/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +tar -xvzf <(curl -fsSL https://github.com/Kareadita/Kavita/releases/download/$RELEASE/kavita-linux-x64.tar.gz) --no-same-owner &>/dev/null +rm -rf Kavita/config +cp -r Kavita/* /opt/Kavita +rm -rf Kavita +systemctl start kavita +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-v3.sh b/ct/keycloak-v3.sh deleted file mode 100644 index f11080d3..00000000 --- a/ct/keycloak-v3.sh +++ /dev/null @@ -1,360 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -APP="Keycloak" -var_disk="4" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[0-9]+$' -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-install" -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}" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - - _ __________ _______ _ ____ _ __ - | |/ / ____\ \ / / ____| | / __ \ /\ | |/ / - | ' /| |__ \ \_/ / | | | | | | | / \ | ' / - | < | __| \ /| | v3 | | | | | |/ /\ \ | < - | . \| |____ | | | |____| |___| |__| / ____ \| . \ - |_|\_\______| |_| \_____|______\____/_/ \_\_|\_\ -${CL}" -} - -header_info - -function PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${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}Using ${BGN}$var_cpu${CL}${DGN}vCPU${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Using ${BGN}$var_ram${CL}${DGN}MiB 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: $var_disk " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: $var_cpu " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: $var_ram " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -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 - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/$var_install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..63827313 --- /dev/null +++ b/ct/keycloak.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 Successfully" +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/admin${CL} \n" diff --git a/ct/kubo.sh b/ct/kubo.sh new file mode 100644 index 00000000..e792b791 --- /dev/null +++ b/ct/kubo.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Co-Author: ulmentflam +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ __ __ + / //_/_ __/ /_ ____ + / ,< / / / / __ \/ __ \ + / /| / /_/ / /_/ / /_/ / +/_/ |_\__,_/_.___/\____/ +EOF +} +header_info +echo -e "Loading..." +APP="Kubo" +var_disk="4" +var_cpu="2" +var_ram="4096" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /usr/local/kubo ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +RELEASE=$(wget -q https://github.com/ipfs/kubo/releases/latest -O - | grep "title>Release" | cut -d " " -f 4) +if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + msg_info "Updating $APP LXC" + apt-get update &>/dev/null + apt-get -y upgrade &>/dev/null + wget -q "https://github.com/ipfs/kubo/releases/download/${RELEASE}/kubo_${RELEASE}_linux-amd64.tar.gz" + tar -xzf "kubo_${RELEASE}_linux-amd64.tar.gz" -C /usr/local + systemctl restart ipfs.service + echo "${RELEASE}" >/opt/${APP}_version.txt + rm "kubo_${RELEASE}_linux-amd64.tar.gz" + msg_ok "Updated $APP LXC" +else + msg_ok "No update required. ${APP} is already at ${RELEASE}" +fi +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}:5001/webui ${CL} \n" diff --git a/ct/lazylibrarian.sh b/ct/lazylibrarian.sh new file mode 100644 index 00000000..9f29dc43 --- /dev/null +++ b/ct/lazylibrarian.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: tteck +# Co-Author: MountyMapleSyrup (MountyMapleSyrup) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ __ _ __ _ + / / ____ _____ __ __/ / (_) /_ _________ ______(_)___ _____ + / / / __ `/_ / / / / / / / / __ \/ ___/ __ `/ ___/ / __ `/ __ \ + / /___/ /_/ / / /_/ /_/ / /___/ / /_/ / / / /_/ / / / / /_/ / / / / +/_____/\__,_/ /___/\__, /_____/_/_.___/_/ \__,_/_/ /_/\__,_/_/ /_/ + /____/ +EOF +} +header_info +echo -e "Loading..." +APP="LazyLibrarian" +var_disk="4" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/LazyLibrarian/ ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Stopping LazyLibrarian" +systemctl stop lazylibrarian +msg_ok "LazyLibrarian Stopped" + +msg_info "Updating $APP LXC" +git -C /opt/LazyLibrarian pull origin master &>/dev/null +msg_ok "Updated $APP LXC" + +msg_info "Starting LazyLibrarian" +systemctl start lazylibrarian +msg_ok "Started LazyLibrarian" + +msg_ok "Updated Successfully" +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}:5299${CL} \n" diff --git a/ct/lidarr.sh b/ct/lidarr.sh new file mode 100644 index 00000000..9628b885 --- /dev/null +++ b/ct/lidarr.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/linkwarden.sh b/ct/linkwarden.sh new file mode 100644 index 00000000..2054aa9b --- /dev/null +++ b/ct/linkwarden.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Linkwarden" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="ubuntu" +var_version="22.04" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/linkwarden ]]; then msg_error "No ${APP} Installation Found!"; exit; fi + +RELEASE=$(curl -s https://api.github.com/repos/linkwarden/linkwarden/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + msg_info "Stopping ${APP}" + systemctl stop linkwarden + msg_ok "Stopped ${APP}" + + msg_info "Updating ${APP} to ${RELEASE}" + cd /opt/linkwarden + git pull + yarn + npx playwright install-deps + yarn playwright install + yarn prisma generate + yarn build + yarn prisma migrate deploy + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated ${APP} to ${RELEASE}" + + msg_info "Starting ${APP}" + systemctl start linkwarden + msg_ok "Started ${APP}" + msg_ok "Updated Successfully" +else + msg_ok "No update required. ${APP} is already at ${RELEASE}." +fi +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP}${CL} should be reachable by going to the following URL. + ${BL}http://${IP}:3000${CL} \n" diff --git a/ct/lldap.sh b/ct/lldap.sh new file mode 100644 index 00000000..050b471d --- /dev/null +++ b/ct/lldap.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Co-Author: remz1337 +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ____ __ + / / /___/ /___ _____ + / / / __ / __ `/ __ \ + / / / /_/ / /_/ / /_/ / +/_/_/\__,_/\__,_/ .___/ + /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="lldap" +var_disk="4" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/systemd/system/lldap.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP" +apt update +apt upgrade -y lldap +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}:17170${CL} \n" diff --git a/ct/mafl.sh b/ct/mafl.sh new file mode 100644 index 00000000..2dfee171 --- /dev/null +++ b/ct/mafl.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Mafl" +var_disk="6" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + header_info + if [[ ! -d /opt/mafl ]]; then msg_error "No ${APP} Installation Found!"; exit; fi + + RELEASE=$(curl -s https://api.github.com/repos/hywax/mafl/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') + msg_info "Updating Mafl to v${RELEASE} (Patience)" + systemctl stop mafl + wget -q https://github.com/hywax/mafl/archive/refs/tags/v${RELEASE}.tar.gz + tar -xzf v${RELEASE}.tar.gz + cp -r mafl-${RELEASE}/* /opt/mafl/ + rm -rf mafl-${RELEASE} + cd /opt/mafl + yarn install + yarn build + systemctl start mafl + msg_ok "Updated Mafl to v${RELEASE}" + exit +} + +start +build_container +description + +msg_info "Setting Container to Normal Resources" +pct set $CTID -memory 1024 +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}:3000${CL} \n" diff --git a/ct/magicmirror-v3.sh b/ct/magicmirror-v3.sh deleted file mode 100644 index fc2fa201..00000000 --- a/ct/magicmirror-v3.sh +++ /dev/null @@ -1,359 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -APP="MagicMirror" -var_disk="3" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[0-9]+$' -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-install" -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}" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - __ __ _____ _____ _____ __ __ _____ _____ _____ ____ _____ - | \/ | /\ / ____|_ _/ ____| \/ |_ _| __ \| __ \ / __ \| __ \ - | \ / | / \ | | __ | || | | \ / | | | | |__) | |__) | | | | |__) | - | |\/| | / /\ \| | |_ | | || | v3 | |\/| | | | | _ /| _ /| | | | _ / - | | | |/ ____ \ |__| |_| || |____| | | |_| |_| | \ \| | \ \| |__| | | \ \ - |_| |_/_/ \_\_____|_____\_____|_| |_|_____|_| \_\_| \_\ ____/|_| \_\ -${CL}" -} - -header_info - -function PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${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}Using ${BGN}$var_cpu${CL}${DGN}vCPU${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Using ${BGN}$var_ram${CL}${DGN}MiB 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: $var_disk " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: $var_cpu " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: $var_ram " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -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 - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/$var_install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..bb5e0b7b --- /dev/null +++ b/ct/magicmirror.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 + if [[ "$(node -v | cut -d 'v' -f 2)" == "18."* ]]; then + if ! command -v npm >/dev/null 2>&1; then + echo "Installing NPM..." + apt-get install -y npm >/dev/null 2>&1 + echo "Installed NPM..." + fi + fi +msg_info "Updating ${APP} LXC" +cd /opt/magicmirror +git pull &>/dev/null +npm install --only=prod --omit=dev &>/dev/null +msg_ok "Updated Successfully" +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-v1.sh b/ct/mariadb-v1.sh deleted file mode 100644 index c3f09991..00000000 --- a/ct/mariadb-v1.sh +++ /dev/null @@ -1,168 +0,0 @@ -#!/usr/bin/env bash - -while true; do - read -p "This will create a New Mariadb LXC Container. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -BL=`echo "\033[36m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if [ ! -z ${MOUNT+x} ]; then - pct unmount $CTID - fi - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} -function load_module() { - if ! $(lsmod | grep -Fq $1); then - modprobe $1 &>/dev/null || \ - die "Failed to load '$1' module." - fi - MODULES_PATH=/etc/modules - if ! $(grep -Fxq "$1" $MODULES_PATH); then - echo "$1" >> $MODULES_PATH || \ - die "Failed to add '$1' module to load at boot." - fi -} -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/mariadb_setup.sh - -load_module overlay - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content rootdir | awk 'NR>1') -if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then - warn "'Container' needs to be selected for at least one storage location." - die "Unable to detect valid storage location." -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 container?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit - done -fi -info "Using ${BL}${STORAGE}${CL} for Storage Location." - -CTID=$(pvesh get /cluster/nextid) -info "Container ID is ${BL}${CTID}${CL}." - -echo -en "${GN} Updating LXC Template List... " -pveam update >/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Downloading LXC Template... " -OSTYPE=debian -OSVERSION=${OSTYPE}-11 -mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V) -TEMPLATE="${TEMPLATES[-1]}" -pveam download local $TEMPLATE >/dev/null || - die "A problem occured while downloading the LXC template." - -STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') -case $STORAGE_TYPE in - dir|nfs) - DISK_EXT=".raw" - DISK_REF="$CTID/" - ;; - zfspool) - DISK_PREFIX="subvol" - DISK_FORMAT="subvol" - ;; -esac -DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-} -ROOTFS=${STORAGE}:${DISK_REF-}${DISK} -echo -e "${CM}${CL} \r" - -echo -en "${GN} Creating LXC Container... " -DISK_SIZE=4G -pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -else - mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null -fi -ARCH=$(dpkg --print-architecture) -HOSTNAME=mariadb -TEMPLATE_STRING="local:vztmpl/${TEMPLATE}" -pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \ - -hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 1 -memory 1024 \ - -ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null - -MOUNT=$(pct mount $CTID | cut -d"'" -f 2) -ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime -pct unmount $CTID && unset MOUNT -echo -e "${CM}${CL} \r" - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -pct push $CTID mariadb_setup.sh /mariadb_setup.sh -perms 755 -echo -e "${CM}${CL} \r" -pct exec $CTID /mariadb_setup.sh - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') -info "${GN} Successfully created a MariaDB LXC Container to ${BL}${CTID}${CL}" -echo -e "${CL} Adminer should be reachable by going to the following URL. - ${BL} http://${IP}/adminer/ ${CL}" diff --git a/ct/mariadb-v2.sh b/ct/mariadb-v2.sh deleted file mode 100644 index 233296d4..00000000 --- a/ct/mariadb-v2.sh +++ /dev/null @@ -1,252 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will create a New Mariadb LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - __ __ _ _ _ - | \/ | (_) | | | - | \ / | __ _ _ __ _ __ _ __| | |__ - | |\/| |/ _ | __| |/ _ |/ _ | _ \ - | | | | (_| | | | | (_| | (_| | |_) | - |_| |_|\__,_|_| |_|\__,_|\__,_|_.__/ - -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=4 -export PCT_OPTIONS=" - -features $FEATURES - -hostname mariadb - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 1 - -memory 1024 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/mariadb-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created Mariadb LXC to${CL} ${BL}$CTID${CL}. -${BL}Adminer${CL} should be reachable by going to the following URL. - ${BL}http://${IP}/adminer/${CL} \n" diff --git a/ct/mariadb-v3.sh b/ct/mariadb-v3.sh deleted file mode 100644 index 74c52575..00000000 --- a/ct/mariadb-v3.sh +++ /dev/null @@ -1,356 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="MariaDB" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - __ __ _ _ _ - | \/ | (_) | | | - | \ / | __ _ _ __ _ __ _ __| | |__ - | |\/| |/ _ | __| |/ _ |/ _ | _ \ - | | | | (_| | | | | (_| | (_| | |_) | - |_| |_|\__,_|_|v3|_|\__,_|\__,_|_.__/ -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}4${CL}${DGN}GB${CL}" - DISK_SIZE="4" - echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}" - CORE_COUNT="1" - echo -e "${DGN}Using ${BGN}1024${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="1024" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 4 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="4"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 1024 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="1024"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/mariadb-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/Proxmox" - -msg_ok "Completed Successfully!\n" -echo -e "Adminer should be reachable by going to the following URL. - ${BL}http://${IP}/adminer/${CL} \n" diff --git a/ct/mariadb.sh b/ct/mariadb.sh new file mode 100644 index 00000000..2b3eef00 --- /dev/null +++ b/ct/mariadb.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 Successfully" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/matterbridge.sh b/ct/matterbridge.sh new file mode 100644 index 00000000..48245bd5 --- /dev/null +++ b/ct/matterbridge.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: MickLesk (Canbiz) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ ___ __ __ __ _ __ + / |/ /___ _/ /_/ /____ _____/ /_ _____(_)___/ /___ ____ + / /|_/ / __ `/ __/ __/ _ \/ ___/ __ \/ ___/ / __ / __ `/ _ \ + / / / / /_/ / /_/ /_/ __/ / / /_/ / / / / /_/ / /_/ / __/ +/_/ /_/\__,_/\__/\__/\___/_/ /_.___/_/ /_/\__,_/\__, /\___/ + /____/ +EOF +} +header_info +echo -e "Loading..." +APP="Matterbridge" +var_disk="4" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /root/Matterbridge ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_error "Update via the Matterbridge UI" +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}:8283${CL} \n" diff --git a/ct/mediamtx.sh b/ct/mediamtx.sh new file mode 100644 index 00000000..83e660eb --- /dev/null +++ b/ct/mediamtx.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="MediaMTX" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/mediamtx/ ]]; then msg_error "No ${APP} Installation Found!"; exit; fi + +msg_error "There is currently no update path available." +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/medusa.sh b/ct/medusa.sh new file mode 100644 index 00000000..d617a114 --- /dev/null +++ b/ct/medusa.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Medusa" +var_disk="6" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/medusa ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP}" +systemctl stop medusa.service +/opt/medusa +git pull +systemctl start medusa.service +msg_ok "Successfully 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}:8081${CL} \n" diff --git a/ct/meshcentral-v2.sh b/ct/meshcentral-v2.sh deleted file mode 100644 index f8df0b17..00000000 --- a/ct/meshcentral-v2.sh +++ /dev/null @@ -1,258 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -APP="MeshCentral" -HN=$(echo ${APP,,} | tr -d ' ') -while true; do - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - __ __ _ _____ _ _ - | \/ | | | / ____| | | | | - | \ / | ___ ___| |__ | | ___ _ __ | |_ _ __ __ _| | - | |\/| |/ _ \/ __| _ \| | / _ \ _ \| __| __/ _ | | - | | | | __/\__ \ | | | |___| __/ | | | |_| | | (_| | | - |_| |_|\___||___/_| |_|\_____\___|_| |_|\__|_| \__,_|_| -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=2 -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 1 - -memory 512 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some applications may not work properly due to ZFS not supporting 'fallocate'." -fi -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}. -${APP} should be reachable by going to the following URL. - ${BL}http://${IP}${CL} \n" diff --git a/ct/meshcentral-v3.sh b/ct/meshcentral-v3.sh deleted file mode 100644 index ff411439..00000000 --- a/ct/meshcentral-v3.sh +++ /dev/null @@ -1,356 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="MeshCentral" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - __ __ _ _____ _ _ - | \/ | | | / ____| | | | | - | \ / | ___ ___| |__ | | ___ _ __ | |_ _ __ __ _| | - | |\/| |/ _ \/ __| _ \| | v3 / _ \ _ \| __| __/ _ | | - | | | | __/\__ \ | | | |___| __/ | | | |_| | | (_| | | - |_| |_|\___||___/_| |_|\_____\___|_| |_|\__|_| \__,_|_| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}2${CL}${DGN}GB${CL}" - DISK_SIZE="2" - echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}" - CORE_COUNT="1" - echo -e "${DGN}Using ${BGN}512${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="512" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 2 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="2"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 512 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="512"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/meshcentral-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..1040a700 --- /dev/null +++ b/ct/meshcentral.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 Successfully" +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/metube.sh b/ct/metube.sh new file mode 100644 index 00000000..57d8b46b --- /dev/null +++ b/ct/metube.sh @@ -0,0 +1,100 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: MickLesk (Canbiz) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ ___ ______ __ + / |/ /__/_ __/_ __/ /_ ___ + / /|_/ / _ \/ / / / / / __ \/ _ \ + / / / / __/ / / /_/ / /_/ / __/ +/_/ /_/\___/_/ \__,_/_.___/\___/ + +EOF +} +header_info +echo -e "Loading..." +APP="MeTube" +var_disk="10" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/metube ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +if (( $(df /boot | awk 'NR==2{gsub("%","",$5); print $5}') > 80 )); then + read -r -p "Warning: Storage is dangerously low, continue anyway? <y/N> " prompt + [[ ${prompt,,} =~ ^(y|yes)$ ]] || exit +fi +msg_info "Stopping ${APP} Service" +systemctl stop metube +msg_ok "Stopped ${APP} Service" + +msg_info "Updating ${APP} to latest Git" +cd /opt +if [ -d metube_bak ]; then + rm -rf metube_bak +fi +mv metube metube_bak +git clone https://github.com/alexta69/metube /opt/metube >/dev/null 2>&1 +cd /opt/metube/ui +npm install >/dev/null 2>&1 +node_modules/.bin/ng build >/dev/null 2>&1 +cd /opt/metube +cp /opt/metube_bak/.env /opt/metube/ +pip3 install pipenv >/dev/null 2>&1 +pipenv install >/dev/null 2>&1 + +if [ -d "/opt/metube_bak" ]; then +rm -rf /opt/metube_bak +fi +msg_ok "Updated ${APP} to latest Git" + +msg_info "Starting ${APP} Service" +systemctl start metube +sleep 1 +msg_ok "Started ${APP} Service" +msg_ok "Updated Successfully!\n" +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}:8081${CL} \n" \ No newline at end of file diff --git a/ct/mongodb.sh b/ct/mongodb.sh new file mode 100644 index 00000000..5b88ca4b --- /dev/null +++ b/ct/mongodb.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="MongoDB" +var_disk="4" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/mongodb-org-7.0.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 Successfully" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/motioneye-v1.sh b/ct/motioneye-v1.sh deleted file mode 100644 index 944ee9b6..00000000 --- a/ct/motioneye-v1.sh +++ /dev/null @@ -1,168 +0,0 @@ -#!/usr/bin/env bash - -while true; do - read -p "This will create a New MotionEye NVR LXC Container. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if [ ! -z ${MOUNT+x} ]; then - pct unmount $CTID - fi - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} -function load_module() { - if ! $(lsmod | grep -Fq $1); then - modprobe $1 &>/dev/null || \ - die "Failed to load '$1' module." - fi - MODULES_PATH=/etc/modules - if ! $(grep -Fxq "$1" $MODULES_PATH); then - echo "$1" >> $MODULES_PATH || \ - die "Failed to add '$1' module to load at boot." - fi -} -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/motioneye_setup.sh - -load_module overlay - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content rootdir | awk 'NR>1') -if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then - warn "'Container' needs to be selected for at least one storage location." - die "Unable to detect valid storage location." -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 container?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit - done -fi -info "Using '$STORAGE' for storage location." - -CTID=$(pvesh get /cluster/nextid) -info "Container ID is $CTID." - -echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m" -pveam update >/dev/null - -echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m" -OSTYPE=debian -OSVERSION=${OSTYPE}-11 -mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V) -TEMPLATE="${TEMPLATES[-1]}" -pveam download local $TEMPLATE >/dev/null || - die "A problem occured while downloading the LXC template." - -STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') -case $STORAGE_TYPE in - dir|nfs) - DISK_EXT=".raw" - DISK_REF="$CTID/" - ;; - zfspool) - DISK_PREFIX="subvol" - DISK_FORMAT="subvol" - ;; -esac -DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-} -ROOTFS=${STORAGE}:${DISK_REF-}${DISK} - -echo -e "${CHECKMARK} \e[1;92m Creating LXC Container... \e[0m" -DISK_SIZE=8G -pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -else - mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null -fi -ARCH=$(dpkg --print-architecture) -HOSTNAME=motioneye -TEMPLATE_STRING="local:vztmpl/${TEMPLATE}" -pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \ - -hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 2 -memory 2048\ - -ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null - -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF - -MOUNT=$(pct mount $CTID | cut -d"'" -f 2) -ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime -pct unmount $CTID && unset MOUNT - -echo -e "${CHECKMARK} \e[1;92m Starting LXC Container... \e[0m" -pct start $CTID -pct push $CTID motioneye_setup.sh /motioneye_setup.sh -perms 755 -pct exec $CTID /motioneye_setup.sh - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') -info "Successfully Created MotionEye LXC to $CTID." -echo -e "\e[1;92m MotionEye NVR should be reachable by going to the following URL. - http://${IP}:8765 -\e[0m" diff --git a/ct/motioneye-v2.sh b/ct/motioneye-v2.sh deleted file mode 100644 index 0c3449b3..00000000 --- a/ct/motioneye-v2.sh +++ /dev/null @@ -1,258 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -APP="Motioneye" -HN=$(echo ${APP,,} | tr -d ' ') -while true; do - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - __ __ ____ _______ _____ ____ _ _ ________ ________ - | \/ |/ __ \__ __|_ _/ __ \| \ | | ____\ \ / / ____| - | \ / | | | | | | | || | | | \| | |__ \ \_/ /| |__ - | |\/| | | | | | | | || | | | | __| \ / | __| - | | | | |__| | | | _| || |__| | |\ | |____ | | | |____ - |_| |_|\____/ |_| |_____\____/|_| \_|______| |_| |______| -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=8 -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 2 - -memory 2048 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}. -${BL}${APP}${CL} should be reachable by going to the following URL. - ${BL}http://${IP}:8765${CL} \n" diff --git a/ct/motioneye-v3.sh b/ct/motioneye-v3.sh deleted file mode 100644 index 1c3ca29e..00000000 --- a/ct/motioneye-v3.sh +++ /dev/null @@ -1,356 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Motioneye" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - __ __ ____ _______ _____ ____ _ _ ________ ________ - | \/ |/ __ \__ __|_ _/ __ \| \ | | ____\ \ / / ____| - | \ / | | | | | | | || | | | \| | |__ \ \_/ /| |__ - | |\/| | | | | | | | || | | | | __| \ / | __| - | | | | |__| | | | v3_| || |__| | |\ | |____ | | | |____ - |_| |_|\____/ |_| |_____\____/|_| \_|______| |_| |______| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}8${CL}${DGN}GB${CL}" - DISK_SIZE="8" - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="2048" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 8 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="8"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/motioneye-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..d5a2579f --- /dev/null +++ b/ct/motioneye.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 Successfully" +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-v1.sh b/ct/mqtt-v1.sh deleted file mode 100644 index bda6ed8e..00000000 --- a/ct/mqtt-v1.sh +++ /dev/null @@ -1,158 +0,0 @@ -#!/usr/bin/env bash - -while true; do - read -p "This will create a New MQTT LXC Container. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if [ ! -z ${MOUNT+x} ]; then - pct unmount $CTID - fi - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} -function load_module() { - if ! $(lsmod | grep -Fq $1); then - modprobe $1 &>/dev/null || \ - die "Failed to load '$1' module." - fi - MODULES_PATH=/etc/modules - if ! $(grep -Fxq "$1" $MODULES_PATH); then - echo "$1" >> $MODULES_PATH || \ - die "Failed to add '$1' module to load at boot." - fi -} -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/mqtt_setup.sh - -load_module overlay - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content rootdir | awk 'NR>1') -if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then - warn "'Container' needs to be selected for at least one storage location." - die "Unable to detect valid storage location." -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 container?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit - done -fi -info "Using '$STORAGE' for storage location." - -CTID=$(pvesh get /cluster/nextid) -info "Container ID is $CTID." - -echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m" -pveam update >/dev/null - -echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m" -OSTYPE=debian -OSVERSION=${OSTYPE}-11 -mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V) -TEMPLATE="${TEMPLATES[-1]}" -pveam download local $TEMPLATE >/dev/null || - die "A problem occured while downloading the LXC template." - -STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') -case $STORAGE_TYPE in - dir|nfs) - DISK_EXT=".raw" - DISK_REF="$CTID/" - ;; - zfspool) - DISK_PREFIX="subvol" - DISK_FORMAT="subvol" - ;; -esac -DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-} -ROOTFS=${STORAGE}:${DISK_REF-}${DISK} - -echo -e "${CHECKMARK} \e[1;92m Creating LXC Container... \e[0m" -DISK_SIZE=2G -pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -else - mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null -fi -ARCH=$(dpkg --print-architecture) -HOSTNAME=mqtt -TEMPLATE_STRING="local:vztmpl/${TEMPLATE}" -pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \ - -hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 1 -memory 512 \ - -ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null - -MOUNT=$(pct mount $CTID | cut -d"'" -f 2) -ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime -pct unmount $CTID && unset MOUNT - -echo -e "${CHECKMARK} \e[1;92m Starting LXC Container... \e[0m" -pct start $CTID -pct push $CTID mqtt_setup.sh /mqtt_setup.sh -perms 755 -pct exec $CTID /mqtt_setup.sh -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') -info "Successfully created a MQTT LXC Container to $CTID at IP Address ${IP}" diff --git a/ct/mqtt-v2.sh b/ct/mqtt-v2.sh deleted file mode 100644 index 7bd70ed0..00000000 --- a/ct/mqtt-v2.sh +++ /dev/null @@ -1,250 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will create a New MQTT LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - __ __ ____ _______ _______ - | \/ |/ __ \__ __|__ __| - | \ / | | | | | | | | - | |\/| | | | | | | | | - | | | | |__| | | | | | - |_| |_|\___\_\ |_| |_| - -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=2 -export PCT_OPTIONS=" - -features $FEATURES - -hostname mqtt - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 1 - -memory 512 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/mqtt-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created MQTT LXC to${CL} ${BL}$CTID${CL}. \n" diff --git a/ct/mqtt-v3.sh b/ct/mqtt-v3.sh deleted file mode 100644 index 7d74a950..00000000 --- a/ct/mqtt-v3.sh +++ /dev/null @@ -1,354 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="MQTT" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - __ __ ____ _______ _______ - | \/ |/ __ \__ __|__ __| - | \ / | | | | | | | | - | |\/| | | | | | | | | - | | | | |__| | | | | | - |_| |_|\___\_\ |_| v3 |_| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}2${CL}${DGN}GB${CL}" - DISK_SIZE="2" - echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}" - CORE_COUNT="1" - echo -e "${DGN}Using ${BGN}512${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="512" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 2 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="2"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 512 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="512"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/mqtt-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/Proxmox" - -msg_ok "Completed Successfully!\n" diff --git a/ct/mqtt.sh b/ct/mqtt.sh new file mode 100644 index 00000000..b79777df --- /dev/null +++ b/ct/mqtt.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/mosquitto/conf.d/default.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 Successfully" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/myspeed.sh b/ct/myspeed.sh new file mode 100644 index 00000000..23c98878 --- /dev/null +++ b/ct/myspeed.sh @@ -0,0 +1,103 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Co-Author: MickLesk (Canbiz) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ ___ _____ __ + / |/ /_ __/ ___/____ ___ ___ ____/ / + / /|_/ / / / /\__ \/ __ \/ _ \/ _ \/ __ / + / / / / /_/ /___/ / /_/ / __/ __/ /_/ / +/_/ /_/\__, //____/ .___/\___/\___/\__,_/ + /____/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="MySpeed" +var_disk="4" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/myspeed ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +if (( $(df /boot | awk 'NR==2{gsub("%","",$5); print $5}') > 80 )); then + read -r -p "Warning: Storage is dangerously low, continue anyway? <y/N> " prompt + [[ ${prompt,,} =~ ^(y|yes)$ ]] || exit +fi +RELEASE=$(wget -q https://github.com/gnmyt/myspeed/releases/latest -O - | grep "title>Release" | cut -d " " -f 5) +if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + + msg_info "Stopping ${APP} Service" + systemctl stop myspeed + msg_ok "Stopped ${APP} Service" + + msg_info "Updating ${APP} to ${RELEASE}" + cd /opt + rm -rf myspeed_bak + mv myspeed myspeed_bak + wget -q https://github.com/gnmyt/myspeed/releases/download/v$RELEASE/MySpeed-$RELEASE.zip + unzip -q MySpeed-$RELEASE.zip -d myspeed + cd myspeed + npm install >/dev/null 2>&1 + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated ${APP} to ${RELEASE}" + + msg_info "Starting ${APP} Service" + systemctl start myspeed + msg_ok "Started ${APP} Service" + + msg_info "Cleaning up" + rm -rf MySpeed-$RELEASE.zip + msg_ok "Cleaned" + + msg_ok "Updated Successfully!\n" +else + msg_ok "No update required. ${APP} is already at ${RELEASE}" +fi +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}:5216${CL} \n" diff --git a/ct/n8n-v3.sh b/ct/n8n-v3.sh deleted file mode 100644 index 1347f25c..00000000 --- a/ct/n8n-v3.sh +++ /dev/null @@ -1,356 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="n8n" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - ___ - / _ \ - _ __ | (_) |_v3_ - | _ \ > _ <| _ \ - | | | | (_) | | | | - |_| |_|\___/|_| |_| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}3${CL}${DGN}GB${CL}" - DISK_SIZE="3" - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="2048" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 3 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="3"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/n8n-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..b78f3ec6 --- /dev/null +++ b/ct/n8n.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="6" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 + if [[ "$(node -v | cut -d 'v' -f 2)" == "18."* ]]; then + if ! command -v npm >/dev/null 2>&1; then + echo "Installing NPM..." + apt-get install -y npm >/dev/null 2>&1 + echo "Installed NPM..." + fi + fi +msg_info "Updating ${APP} LXC" +npm update -g n8n &>/dev/null +systemctl restart n8n +msg_ok "Updated Successfully" +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.sh b/ct/navidrome.sh new file mode 100644 index 00000000..b9af1d6f --- /dev/null +++ b/ct/navidrome.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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_amd64.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 "Updated Successfully" +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.sh b/ct/nextcloudpi.sh new file mode 100644 index 00000000..7255de3d --- /dev/null +++ b/ct/nextcloudpi.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="NextCloudPi" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /lib/systemd/system/nextcloud-domain.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 Successfully" +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/nginx-proxy-manager-v1.sh b/ct/nginx-proxy-manager-v1.sh deleted file mode 100644 index efc67e28..00000000 --- a/ct/nginx-proxy-manager-v1.sh +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/env bash - -#!/usr/bin/env bash -while true; do - read -p "This will create a New Nginx Proxy Manager LXC Container. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if [ ! -z ${MOUNT+x} ]; then - pct unmount $CTID - fi - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} -function load_module() { - if ! $(lsmod | grep -Fq $1); then - modprobe $1 &>/dev/null || \ - die "Failed to load '$1' module." - fi - MODULES_PATH=/etc/modules - if ! $(grep -Fxq "$1" $MODULES_PATH); then - echo "$1" >> $MODULES_PATH || \ - die "Failed to add '$1' module to load at boot." - fi -} -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/npm_setup.sh - -load_module overlay - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content rootdir | awk 'NR>1') -if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then - warn "'Container' needs to be selected for at least one storage location." - die "Unable to detect valid storage location." -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 container?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit - done -fi -info "Using '$STORAGE' for storage location." - -CTID=$(pvesh get /cluster/nextid) -info "LXC ID is $CTID." - -echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m" -pveam update >/dev/null -echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m" -OSTYPE=debian -OSVERSION=${OSTYPE}-11 -mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V) -TEMPLATE="${TEMPLATES[-1]}" -pveam download local $TEMPLATE >/dev/null || - die "A problem occured while downloading the LXC template." - -STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') -case $STORAGE_TYPE in - dir|nfs) - DISK_EXT=".raw" - DISK_REF="$CTID/" - ;; - zfspool) - DISK_PREFIX="subvol" - DISK_FORMAT="subvol" - ;; -esac -DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-} -ROOTFS=${STORAGE}:${DISK_REF-}${DISK} - -echo -e "${CHECKMARK} \e[1;92m Creating LXC... \e[0m" -DISK_SIZE=3G -pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -else - mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null -fi -ARCH=$(dpkg --print-architecture) -HOSTNAME=npm -TEMPLATE_STRING="local:vztmpl/${TEMPLATE}" -pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \ - -hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 1 -memory 1024 \ - -ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null - -MOUNT=$(pct mount $CTID | cut -d"'" -f 2) -ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime -pct unmount $CTID && unset MOUNT - -echo -e "${CHECKMARK} \e[1;92m Starting LXC... \e[0m" -pct start $CTID -pct push $CTID npm_setup.sh /npm_setup.sh -perms 755 -pct exec $CTID /npm_setup.sh - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') -info "Successfully Created Nginx Proxy Manager LXC to $CTID." -echo -e "\e[1;92m Nginx Proxy Manager should be reachable by going to the following URL. - http://${IP}:81 -\e[0m" diff --git a/ct/nginx-proxy-manager-v2.sh b/ct/nginx-proxy-manager-v2.sh deleted file mode 100644 index 2b147d60..00000000 --- a/ct/nginx-proxy-manager-v2.sh +++ /dev/null @@ -1,251 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will create a New Nginx Proxy Manager LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - _ _ _____ __ __ - | \ | | __ \| \/ | - | \| | |__) | \ / | - | | ___/| |\/| | - | |\ | | | | | | - |_| \_|_| |_| |_| -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=3 -export PCT_OPTIONS=" - -features $FEATURES - -hostname npm - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 1 - -memory 1024 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/nginx-proxy-manager-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created Nginx Proxy Manager LXC to${CL} ${BL}$CTID${CL}. -Nginx Proxy Manager should be reachable by going to the following URL. - ${BL}http://${IP}:81${CL} \n" diff --git a/ct/nginx-proxy-manager-v3.sh b/ct/nginx-proxy-manager-v3.sh deleted file mode 100644 index bfcf2225..00000000 --- a/ct/nginx-proxy-manager-v3.sh +++ /dev/null @@ -1,356 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Nginx Proxy Manager" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - _ _ _____ __ __ - | \ | | __ \| \/ | - | \| | |__) | \ / | - | | ___/| |\/| | - | |\ | | | | | | - |_| \_|_| v3 |_| |_| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}3${CL}${DGN}GB${CL}" - DISK_SIZE="3" - echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}" - CORE_COUNT="1" - echo -e "${DGN}Using ${BGN}1024${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="1024" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 3 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="3"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 1024 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="1024"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/nginx-proxy-manager-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..75969716 --- /dev/null +++ b/ct/nginxproxymanager.sh @@ -0,0 +1,193 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Nginx Proxy Manager" +var_disk="4" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + header_info + if [[ ! -f /lib/systemd/system/npm.service ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + if ! command -v pnpm &> /dev/null; then + msg_info "Installing pnpm" + export NODE_OPTIONS=--openssl-legacy-provider + npm install -g pnpm@8.15 &>/dev/null + msg_ok "Installed pnpm" + fi + 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|\"version\": \"0.0.0\"|\"version\": \"$RELEASE\"|" backend/package.json + sed -i "s|\"version\": \"0.0.0\"|\"version\": \"$RELEASE\"|" frontend/package.json + sed -i 's|"fork-me": ".*"|"fork-me": "Proxmox VE Helper-Scripts"|' frontend/js/i18n/messages.json + sed -i "s|https://github.com.*source=nginx-proxy-manager|https://helper-scripts.com|g" frontend/js/app/ui/footer/main.ejs + 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 + 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 + python3 -m pip install --no-cache-dir certbot-dns-cloudflare &>/dev/null + msg_ok "Setup Enviroment" + + msg_info "Building Frontend" + cd ./frontend + pnpm install &>/dev/null + pnpm upgrade &>/dev/null + pnpm run 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 + pnpm install &>/dev/null + msg_ok "Initialized Backend" + + msg_info "Starting Services" + sed -i 's/user npm/user root/g; s/^pid/#pid/g' /usr/local/openresty/nginx/conf/nginx.conf + sed -i 's/include-system-site-packages = false/include-system-site-packages = true/g' /opt/certbot/pyvenv.cfg + systemctl enable -q --now openresty + systemctl enable -q --now npm + msg_ok "Started Services" + + msg_info "Cleaning up" + rm -rf ~/nginx-proxy-manager-* + msg_ok "Cleaned" + + msg_ok "Updated Successfully" + exit +} + +start +build_container +description + +msg_info "Setting Container to Normal Resources" +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}:81${CL}\n" diff --git a/ct/nocodb-v2.sh b/ct/nocodb-v2.sh deleted file mode 100644 index 4eafd1cf..00000000 --- a/ct/nocodb-v2.sh +++ /dev/null @@ -1,258 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -APP="NocoDB" -HN=$(echo ${APP,,} | tr -d ' ') -while true; do - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${YW} - _ _ _____ ____ - | \ | | | __ \| _ \ - | \| | ___ ___ ___ | | | | |_) | - | |/ _ \ / __/ _ \| | | | _ < - | |\ | (_) | (_| (_) | |__| | |_) | - |_| \_|\___/ \___\___/|_____/|____/ -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=4 -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 1 - -memory 1024 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some applications may not work properly due to ZFS not supporting 'fallocate'." -fi -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}. -${BL}${APP}${CL} should be reachable by going to the following URL. - ${BL}http://${IP}:8080/dashboard${CL}\n" diff --git a/ct/nocodb-v3.sh b/ct/nocodb-v3.sh deleted file mode 100644 index 9ede88a8..00000000 --- a/ct/nocodb-v3.sh +++ /dev/null @@ -1,356 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="NocoDB" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${YW} - _ _ _____ ____ - | \ | | | __ \| _ \ - | \| | ___ v3___ ___ | | | | |_) | - | |/ _ \ / __/ _ \| | | | _ < - | |\ | (_) | (_| (_) | |__| | |_) | - |_| \_|\___/ \___\___/|_____/|____/ -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}4${CL}${DGN}GB${CL}" - DISK_SIZE="4" - echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}" - CORE_COUNT="1" - echo -e "${DGN}Using ${BGN}1024${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="1024" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 4 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="4"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 1024 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="1024"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/nocodb-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..4f8ff0b7 --- /dev/null +++ b/ct/nocodb.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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}" +systemctl stop nocodb.service +cd /opt/nocodb +rm -rf nocodb +curl -s http://get.nocodb.com/linux-x64 -o nocodb -L +chmod +x nocodb +systemctl start nocodb.service +msg_ok "Updated Successfully" +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-v1.sh b/ct/node-red-v1.sh deleted file mode 100644 index ebd544b3..00000000 --- a/ct/node-red-v1.sh +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/env bash - -while true; do - read -p "This will create a New Node-Red LXC Container. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if [ ! -z ${MOUNT+x} ]; then - pct unmount $CTID - fi - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} -function load_module() { - if ! $(lsmod | grep -Fq $1); then - modprobe $1 &>/dev/null || \ - die "Failed to load '$1' module." - fi - MODULES_PATH=/etc/modules - if ! $(grep -Fxq "$1" $MODULES_PATH); then - echo "$1" >> $MODULES_PATH || \ - die "Failed to add '$1' module to load at boot." - fi -} -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/node-red_setup.sh - -load_module overlay - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content rootdir | awk 'NR>1') -if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then - warn "'Container' needs to be selected for at least one storage location." - die "Unable to detect valid storage location." -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 container?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit - done -fi -info "Using '$STORAGE' for storage location." - -CTID=$(pvesh get /cluster/nextid) -info "Container ID is $CTID." - -echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m" -pveam update >/dev/null -echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m" -OSTYPE=debian -OSVERSION=${OSTYPE}-11 -mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V) -TEMPLATE="${TEMPLATES[-1]}" -pveam download local $TEMPLATE >/dev/null || - die "A problem occured while downloading the LXC template." - -STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') -case $STORAGE_TYPE in - dir|nfs) - DISK_EXT=".raw" - DISK_REF="$CTID/" - ;; - zfspool) - DISK_PREFIX="subvol" - DISK_FORMAT="subvol" - ;; -esac -DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-} -ROOTFS=${STORAGE}:${DISK_REF-}${DISK} - -echo -e "${CHECKMARK} \e[1;92m Creating LXC Container... \e[0m" -DISK_SIZE=4G -pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -else - mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null -fi -ARCH=$(dpkg --print-architecture) -HOSTNAME=nodered -TEMPLATE_STRING="local:vztmpl/${TEMPLATE}" -pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \ - -hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 1 -memory 1024 \ - -ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null - -MOUNT=$(pct mount $CTID | cut -d"'" -f 2) -ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime -pct unmount $CTID && unset MOUNT - -echo -e "${CHECKMARK} \e[1;92m Starting LXC Container... \e[0m" -pct start $CTID -pct push $CTID node-red_setup.sh /node-red_setup.sh -perms 755 -pct exec $CTID /node-red_setup.sh - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') -info "Successfully Created Node-Red LXC to $CTID." -echo -e "\e[1;92m Node-Red should be reachable by going to the following URL. - http://${IP}:1880 -\e[0m" diff --git a/ct/node-red-v2.sh b/ct/node-red-v2.sh deleted file mode 100644 index 9ecc7d17..00000000 --- a/ct/node-red-v2.sh +++ /dev/null @@ -1,253 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will create a New Node-Red LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - _ _ _ _____ _ - | \ | | | | | __ \ | | - | \| | ___ __| | ___ ______| |__) |___ __| | - | |/ _ \ / _ |/ _ \______| _ // _ \/ _ | - | |\ | (_) | (_| | __/ | | \ \ __/ (_| | - |_| \_|\___/ \__,_|\___| |_| \_\___|\__,_| - -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=4 -export PCT_OPTIONS=" - -features $FEATURES - -hostname node-red - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 1 - -memory 1024 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/node-red-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created Node-Red LXC to${CL} ${BL}$CTID${CL}. -${RD}Node-Red${CL} should be reachable by going to the following URL. - - ${BL}http://${IP}:1880${CL} \n" diff --git a/ct/node-red-v3.sh b/ct/node-red-v3.sh deleted file mode 100644 index 58252e17..00000000 --- a/ct/node-red-v3.sh +++ /dev/null @@ -1,356 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Node Red" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - _ _ _ _____ _ - | \ | | | | | __ \ | | - | \| | ___ __| | ___ ______| |__) |___ __| | - | |/ _ \ / _ |/ _ \__v3__| _ // _ \/ _ | - | |\ | (_) | (_| | __/ | | \ \ __/ (_| | - |_| \_|\___/ \__,_|\___| |_| \_\___|\__,_| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}4${CL}${DGN}GB${CL}" - DISK_SIZE="4" - echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}" - CORE_COUNT="1" - echo -e "${DGN}Using ${BGN}1024${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="1024" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 4 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="4"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 1024 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="1024"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/node-red-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..1f68dc09 --- /dev/null +++ b/ct/node-red.sh @@ -0,0 +1,129 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 --backtitle "Proxmox VE Helper Scripts" --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 + if [[ "$(node -v | cut -d 'v' -f 2)" == "18."* ]]; then + if ! command -v npm >/dev/null 2>&1; then + msg_info "Installing NPM" + apt-get install -y npm >/dev/null 2>&1 + msg_ok "Installed NPM" + fi + fi +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 --backtitle "Proxmox VE Helper Scripts" --title "NODE-RED THEMES" --radiolist --cancel-button Exit-Script "Choose Theme" 15 58 6 \ + "aurora" "" OFF \ + "cobalt2" "" OFF \ + "dark" "" OFF \ + "dracula" "" OFF \ + "espresso-libre" "" OFF \ + "github-dark" "" OFF \ + "github-dark-default" "" OFF \ + "github-dark-dimmed" "" OFF \ + "midnight-red" "" ON \ + "monoindustrial" "" OFF \ + "monokai" "" OFF \ + "monokai-dimmed" "" OFF \ + "noctis" "" OFF \ + "oceanic-next" "" OFF \ + "oled" "" OFF \ + "one-dark-pro" "" OFF \ + "one-dark-pro-darker" "" OFF \ + "solarized-dark" "" OFF \ + "solarized-light" "" OFF \ + "tokyo-night" "" OFF \ + "tokyo-night-light" "" OFF \ + "tokyo-night-storm" "" OFF \ + "totallyinformation" "" OFF \ + "zenburn" "" 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-collection &>/dev/null +sed -i "{s/theme: ".*"/theme: '${THEME}',/g}" /root/.node-red/settings.js +systemctl restart nodered +msg_ok "Installed ${THEME} Theme" +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/notifiarr.sh b/ct/notifiarr.sh new file mode 100644 index 00000000..ac63e454 --- /dev/null +++ b/ct/notifiarr.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Notifiarr" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/golift.list ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +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}:5454${CL} \n" diff --git a/ct/ntfy.sh b/ct/ntfy.sh new file mode 100644 index 00000000..d12e4b3d --- /dev/null +++ b/ct/ntfy.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="ntfy" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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}${CL} \n" diff --git a/ct/octoprint.sh b/ct/octoprint.sh new file mode 100644 index 00000000..75c2ccd9 --- /dev/null +++ b/ct/octoprint.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="OctoPrint" +var_disk="4" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/octoprint ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Stopping OctoPrint" +systemctl stop octoprint +msg_ok "Stopped OctoPrint" + +msg_info "Updating OctoPrint" +source /opt/octoprint/bin/activate +pip3 install octoprint --upgrade &>/dev/null +msg_ok "Updated OctoPrint" + +msg_info "Starting OctoPrint" +systemctl start octoprint +msg_ok "Started OctoPrint" +msg_ok "Updated Successfully" +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/omada-v2.sh b/ct/omada-v2.sh deleted file mode 100644 index 6ec8036b..00000000 --- a/ct/omada-v2.sh +++ /dev/null @@ -1,252 +0,0 @@ -#!/usr/bin/env bash -clear -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will create a New Omada Controller LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - ____ _ _____ _ _ _ - / __ \ | | / ____| | | | | | - | | | |_ __ ___ __ _ __| | __ _ | | ___ _ __ | |_ _ __ ___ | | | ___ _ __ - | | | | _ _ \ / _ |/ _ |/ _ | | | / _ \| _ \| __| __/ _ \| | |/ _ \ __| - | |__| | | | | | | (_| | (_| | (_| | | |___| (_) | | | | |_| | | (_) | | | __/ | - \____/|_| |_| |_|\__,_|\__,_|\__,_| \_____\___/|_| |_|\__|_| \___/|_|_|\___|_| -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose an Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=ubuntu -export PCT_OSVERSION=20.04 -export PCT_DISK_SIZE=8 -export PCT_OPTIONS=" - -features $FEATURES - -hostname omada - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 2 - -memory 2048 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/omada-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created Omada Controller LXC to${CL} ${BL}$CTID${CL}. -${BL}Omada${CL} should be reachable by going to the following URL. - ${BL}https://${IP}:8043${CL} \n" diff --git a/ct/omada-v3.sh b/ct/omada-v3.sh deleted file mode 100644 index 7b97dace..00000000 --- a/ct/omada-v3.sh +++ /dev/null @@ -1,356 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Omada" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - ____ _ _____ _ _ _ - / __ \ | | / ____| | | | | | - | | | |_ __ ___ v3__ _ __| | __ _ | | ___ _ __ | |_ _ __ ___ | | | ___ _ __ - | | | | _ _ \ / _ |/ _ |/ _ | | | / _ \| _ \| __| __/ _ \| | |/ _ \ __| - | |__| | | | | | | (_| | (_| | (_| | | |___| (_) | | | | |_| | | (_) | | | __/ | - \____/|_| |_| |_|\__,_|\__,_|\__,_| \_____\___/|_| |_|\__|_| \___/|_|_|\___|_| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}8${CL}${DGN}GB${CL}" - DISK_SIZE="8" - echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}512${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="2048" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 8 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="8"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=ubuntu -export PCT_OSVERSION=20.04 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/omada-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..5c637de8 --- /dev/null +++ b/ct/omada.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 +latest_url=$(curl -fsSL "https://www.tp-link.com/en/support/download/omada-software-controller/" | grep -o 'https://.*x64.deb' | head -n1) +latest_version=$(basename "${latest_url}") +if [ -z "${latest_version}" ]; then + msg_error "It seems that the server (tp-link.com) might be down. Please try again at a later time." + exit +fi +echo -e "Updating Omada Controller" +wget -qL ${latest_url} +dpkg -i ${latest_version} +rm -rf ${latest_version} +echo -e "Updated Omada Controller" +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/ombi.sh b/ct/ombi.sh index 73330b81..4e53aa6b 100644 --- a/ct/ombi.sh +++ b/ct/ombi.sh @@ -1,356 +1,86 @@ #!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="ombi" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear function header_info { -echo -e "${RD} - _ _ - | | (_) - ___ ____ | | _ _ - / _ \| \| || \| | -| |_| | | | | |_) ) | - \___/|_|_|_|____/|_| - -${CL}" -} +clear +cat <<"EOF" + ____ __ _ + / __ \____ ___ / /_ (_) + / / / / __ `__ \/ __ \/ / +/ /_/ / / / / / / /_/ / / +\____/_/ /_/ /_/_.___/_/ +EOF +} header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} +echo -e "Loading..." +APP="Ombi" +var_disk="4" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="12" +variables +color +catch_errors function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}5${CL}${DGN}GB${CL}" - DISK_SIZE="5" - echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}" - CORE_COUNT="1" - echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="2048" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" + 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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default } -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 5 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="5"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear +function update_script() { header_info +if [[ ! -d /opt/ombi ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +RELEASE=$(curl -sL https://api.github.com/repos/Ombi-app/Ombi/releases/latest | grep '"tag_name":' | cut -d'"' -f4) +if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + msg_info "Stopping ${APP}" + systemctl stop ombi + msg_ok "Stopped ${APP}" - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" + msg_info "Updating ${APP} to ${RELEASE}" + wget -q https://github.com/Ombi-app/Ombi/releases/download/${RELEASE}/linux-x64.tar.gz + tar -xzf linux-x64.tar.gz -C /opt/ombi + rm -rf linux-x64.tar.gz + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated ${APP} to ${RELEASE}" -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings + msg_info "Starting ${APP}" + systemctl start ombi + msg_ok "Started ${APP}" + msg_ok "Updated Successfully" +else + msg_ok "No update required. ${APP} ia already at ${RELEASE}." fi +exit } -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -onboot 1 - -cores $CORE_COUNT - -memory $RAM_SIZE - -unprivileged $CT_TYPE - $PW -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/Kickbut101/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/Kickbut101/Proxmox/main/setup/ombi-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/Kickbut101/Proxmox" +start +build_container +description msg_ok "Completed Successfully!\n" echo -e "${APP} should be reachable by going to the following URL. diff --git a/ct/omv.sh b/ct/omv.sh new file mode 100644 index 00000000..525a35db --- /dev/null +++ b/ct/omv.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 Successfully" +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-v3.sh b/ct/openhab-v3.sh deleted file mode 100644 index a4726cb0..00000000 --- a/ct/openhab-v3.sh +++ /dev/null @@ -1,361 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -APP="openHAB" -var_disk="8" -var_cpu="2" -var_ram="2048" -var_os="debian" -var_version="11" -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[0-9]+$' -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-install" -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}" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${YW} - _ _ ____ - | | | | /\ | _ \ - ___ _ __ ___ _ __ | |__| | / \ | |_) | - / _ \| _ \ / _ \ _ \| __ | / /\ \ | _ < - | (_) | |_) | __/ | | | | | |/ ____ \| |_) | - \___/| .__/ \___|_| |_|_| |_/_/ v3 \_\____/ - | | - |_| -${CL}" -} - -header_info - -function PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Privileged${CL}" - CT_TYPE="0" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${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}Using ${BGN}$var_cpu${CL}${DGN}vCPU${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Using ${BGN}$var_ram${CL}${DGN}MiB 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Unprivileged, or Press [ENTER] for Default: Privileged" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Privileged" CT_TYPE="0"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Unprivileged" - CT_TYPE="1" - echo -en "${DGN}Set CT Type ${BL}Unprivileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: $var_disk " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: $var_cpu " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: $var_ram " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -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 - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/$var_install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..9546085a --- /dev/null +++ b/ct/openhab.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 Successfully" +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/openobserve.sh b/ct/openobserve.sh new file mode 100644 index 00000000..cea4c29a --- /dev/null +++ b/ct/openobserve.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="OpenObserve" +var_disk="3" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/openobserve/ ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP" +systemctl stop openobserve +LATEST=$(curl -sL https://api.github.com/repos/openobserve/openobserve/releases/latest | grep '"tag_name":' | cut -d'"' -f4) +tar zxvf <(curl -fsSL https://github.com/openobserve/openobserve/releases/download/$LATEST/openobserve-${LATEST}-linux-amd64.tar.gz) -C /opt/openobserve +systemctl start openobserve +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}:5080${CL} \n" diff --git a/ct/overseerr.sh b/ct/overseerr.sh new file mode 100644 index 00000000..a4a76bfc --- /dev/null +++ b/ct/overseerr.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Overseerr" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/overseerr ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP" +systemctl stop overseerr +cd /opt/overseerr +output=$(git pull) +git pull &>/dev/null +if echo "$output" | grep -q "Already up to date." +then + msg_ok " $APP is already up to date." + systemctl start overseerr + exit +fi +yarn install &>/dev/null +yarn build &>/dev/null +systemctl start overseerr +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}:5055${CL} \n" diff --git a/ct/owncast.sh b/ct/owncast.sh new file mode 100644 index 00000000..c06ccfbb --- /dev/null +++ b/ct/owncast.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Owncast" +var_disk="2" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/owncast ]]; 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}:8080${CL} + ${BL}http://${IP}:8080/admin${CL} admin|abc123\n" diff --git a/ct/pairdrop.sh b/ct/pairdrop.sh new file mode 100644 index 00000000..a1680a8c --- /dev/null +++ b/ct/pairdrop.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="PairDrop" +var_disk="4" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/pairdrop ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP" +systemctl stop pairdrop +cd /opt/pairdrop +git pull +npm install +systemctl start pairdrop +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}:3000${CL} \n" diff --git a/ct/paperless-ngx.sh b/ct/paperless-ngx.sh new file mode 100644 index 00000000..d23986b1 --- /dev/null +++ b/ct/paperless-ngx.sh @@ -0,0 +1,115 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="10" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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) }') + + UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --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 + if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + msg_info "Stopping all Paperless-ngx Services" + systemctl stop paperless-consumer paperless-webserver paperless-scheduler paperless-task-queue.service + msg_ok "Stopped all Paperless-ngx Services" + + msg_info "Updating to ${RELEASE}" + cd ~ + wget -q https://github.com/paperless-ngx/paperless-ngx/releases/download/$RELEASE/paperless-ngx-$RELEASE.tar.xz + tar -xf paperless-ngx-$RELEASE.tar.xz + cp -r /opt/paperless/paperless.conf paperless-ngx/ + cp -r paperless-ngx/* /opt/paperless/ + cd /opt/paperless + pip install -r requirements.txt &>/dev/null + cd /opt/paperless/src + /usr/bin/python3 manage.py migrate &>/dev/null + echo "${RELEASE}" >/opt/${APP}_version.txt + 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 all Paperless-ngx Services" + systemctl start paperless-consumer paperless-webserver paperless-scheduler paperless-task-queue.service + sleep 1 + msg_ok "Started all Paperless-ngx Services" + msg_ok "Updated Successfully!\n" + else + msg_ok "No update required. ${APP} is already at ${RELEASE}" + fi + 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/pbs.sh b/ct/pbs.sh new file mode 100644 index 00000000..97ffd5a4 --- /dev/null +++ b/ct/pbs.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="PBS" +var_disk="10" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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}:8007${CL} \n" diff --git a/ct/peanut.sh b/ct/peanut.sh new file mode 100644 index 00000000..fb2975d7 --- /dev/null +++ b/ct/peanut.sh @@ -0,0 +1,89 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Co-Author: remz1337 +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ____ _ ____ ________ + / __ \___ ____ _/ | / / / / /_ __/ + / /_/ / _ \/ __ `/ |/ / / / / / / + / ____/ __/ /_/ / /| / /_/ / / / +/_/ \___/\__,_/_/ |_/\____/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="PeaNUT" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + header_info + if [[ ! -f /etc/systemd/system/peanut.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi + RELEASE=$(curl -sL https://api.github.com/repos/Brandawg93/PeaNUT/releases/latest | grep '"tag_name":' | cut -d'"' -f4) + if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + msg_info "Updating $APP to ${RELEASE}" + systemctl stop peanut + wget -qO peanut.tar.gz https://api.github.com/repos/Brandawg93/PeaNUT/tarball/${RELEASE} + tar -xzf peanut.tar.gz -C /opt/peanut --strip-components 1 + rm peanut.tar.gz + cd /opt/peanut + pnpm i &>/dev/null + pnpm run build &>/dev/null + cp -r .next/static .next/standalone/.next/ + systemctl start peanut + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated $APP to ${RELEASE}" + else + msg_ok "No update required. ${APP} is already at ${RELEASE}" + fi + exit +} + +start +build_container +description + +msg_info "Setting Container to Normal Resources" +pct set $CTID -memory 1024 +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}:3000${CL} \n" diff --git a/ct/petio.sh b/ct/petio.sh new file mode 100644 index 00000000..040b0c9b --- /dev/null +++ b/ct/petio.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Petio" +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="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET="dhcp" + GATE="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/Petio ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP" +systemctl stop petio.service +wget https://petio.tv/releases/latest -O petio-latest.zip +unzip petio-latest.zip -d /opt/Petio +systemctl start petio.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/photoprism-v2.sh b/ct/photoprism-v2.sh deleted file mode 100644 index 31035d89..00000000 --- a/ct/photoprism-v2.sh +++ /dev/null @@ -1,259 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -PP=`echo "\e[1;35m"` -APP="PhotoPrism" -HN=$(echo ${APP,,} | tr -d ' ') -while true; do - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${PP} - _____ _ _ _____ _ - | __ \| | | | | __ \ (_) - | |__) | |__ ___ | |_ ___ | |__) | __ _ ___ _ __ ___ - | ___/| _ \ / _ \| __/ _ \| ___/ __| / __| _ _ \ - | | | | | | (_) | || (_) | | | | | \__ \ | | | | | - |_| |_| |_|\___/ \__\___/|_| |_| |_|___/_| |_| |_| -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=8 -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 2 - -memory 2048 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}. -${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:2342${CL} \n" diff --git a/ct/photoprism-v3.sh b/ct/photoprism-v3.sh deleted file mode 100644 index 3f90236f..00000000 --- a/ct/photoprism-v3.sh +++ /dev/null @@ -1,357 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[0-9]+$' -PP=`echo "\e[1;35m"` -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}" -APP="PhotoPrism" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${PP} - _____ _ _ _____ _ - | __ \| | | | | __ \ (_) - | |__) | |__ ___ | |_ ___ | |__) | __ _ ___ _ __ ___ - | ___/| _ \ / _ \| __/ _ \| ___/ __| / __| _ _ \ - | | | | | | (_) | || (_) | | | | | \__ \ | | | | | - |_| v3 |_| |_|\___/ \__\___/|_| |_| |_|___/_| |_| |_| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}8${CL}${DGN}GB${CL}" - DISK_SIZE="8" - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="2048" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 8 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="8"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/photoprism-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/Proxmox" - -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..593fe362 --- /dev/null +++ b/ct/photoprism.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 "Updating PhotoPrism" + apt-get install -y libvips42 &>/dev/null + wget -q -cO - https://dl.photoprism.app/pkg/linux/amd64.tar.gz | tar -xzf - -C /opt/photoprism --strip-components=1 + msg_ok "Updated PhotoPrism" + + msg_info "Starting PhotoPrism" + sudo systemctl start photoprism + msg_ok "Started PhotoPrism" + msg_ok "Update Successful" + 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}:2342${CL} \n" diff --git a/ct/pialert.sh b/ct/pialert.sh new file mode 100644 index 00000000..7604d444 --- /dev/null +++ b/ct/pialert.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="PiAlert" +var_disk="3" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/pialert ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +bash -c "$(wget -qLO - https://github.com/leiweibau/Pi.Alert/raw/main/install/pialert_update.sh)" -s --lxc +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}/pialert/${CL} \n" diff --git a/ct/pihole-v1.sh b/ct/pihole-v1.sh deleted file mode 100644 index 1d420089..00000000 --- a/ct/pihole-v1.sh +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/env bash - -while true; do - read -p "This will create a New Pi-hole LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if [ ! -z ${MOUNT+x} ]; then - pct unmount $CTID - fi - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} -function load_module() { - if ! $(lsmod | grep -Fq $1); then - modprobe $1 &>/dev/null || \ - die "Failed to load '$1' module." - fi - MODULES_PATH=/etc/modules - if ! $(grep -Fxq "$1" $MODULES_PATH); then - echo "$1" >> $MODULES_PATH || \ - die "Failed to add '$1' module to load at boot." - fi -} -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/pihole_setup.sh - -load_module overlay - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content rootdir | awk 'NR>1') -if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then - warn "'Container' needs to be selected for at least one storage location." - die "Unable to detect valid storage location." -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 container?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit - done -fi -info "Using '$STORAGE' for storage location." - -CTID=$(pvesh get /cluster/nextid) -info "LXC ID is $CTID." - -echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m" -pveam update >/dev/null - -echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m" -OSTYPE=debian -OSVERSION=${OSTYPE}-11 -mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V) -TEMPLATE="${TEMPLATES[-1]}" -pveam download local $TEMPLATE >/dev/null || - die "A problem occured while downloading the LXC template." - -STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') -case $STORAGE_TYPE in - dir|nfs) - DISK_EXT=".raw" - DISK_REF="$CTID/" - ;; - zfspool) - DISK_PREFIX="subvol" - DISK_FORMAT="subvol" - ;; -esac -DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-} -ROOTFS=${STORAGE}:${DISK_REF-}${DISK} - -echo -e "${CHECKMARK} \e[1;92m Creating LXC... \e[0m" -DISK_SIZE=2G -pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -else - mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null -fi -ARCH=$(dpkg --print-architecture) -HOSTNAME=pi-hole -TEMPLATE_STRING="local:vztmpl/${TEMPLATE}" -pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \ - -hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 1 -memory 512 \ - -ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null - -MOUNT=$(pct mount $CTID | cut -d"'" -f 2) -ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime -pct unmount $CTID && unset MOUNT - -echo -e "${CHECKMARK} \e[1;92m Starting LXC... \e[0m" -pct start $CTID -pct push $CTID pihole_setup.sh /pihole_setup.sh -perms 755 -pct exec $CTID /pihole_setup.sh - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') -info "Successfully created a Pi-hole LXC to $CTID" -echo -e "\e[1;92m Pi-hole should be reachable by going to the following URL. - http://${IP} -\e[0m" diff --git a/ct/pihole-v2.sh b/ct/pihole-v2.sh deleted file mode 100644 index 9a0abcdd..00000000 --- a/ct/pihole-v2.sh +++ /dev/null @@ -1,258 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -APP="Pihole" -HN=$(echo ${APP,,} | tr -d ' ') -while true; do - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - _____ _____ _ _ ____ _ ______ - | __ \_ _| | | |/ __ \| | | ____| - | |__) || | | |__| | | | | | | |__ - | ___/ | | | __ | | | | | | __| - | | _| |_| | | | |__| | |____| |____ - |_| |_____|_| |_|\____/|______|______| -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=2 -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 1 - -memory 512 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}. -${BL}${APP}${CL} should be reachable by going to the following URL. - ${BL}http://${IP}${CL} \n" diff --git a/ct/pihole-v3.sh b/ct/pihole-v3.sh deleted file mode 100644 index 03a5b577..00000000 --- a/ct/pihole-v3.sh +++ /dev/null @@ -1,356 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Pihole" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - _____ _____ _ _ ____ _ ______ - | __ \_ _| | | |/ __ \| | | ____| - | |__) || | | |__| | | | | | | |__ - | ___/ | | | __ | | | | | | __| - | | v3 _| |_| | | | |__| | |____| |____ - |_| |_____|_| |_|\____/|______|______| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Privileged${CL}" - CT_TYPE="0" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}2${CL}${DGN}GB${CL}" - DISK_SIZE="2" - echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}" - CORE_COUNT="1" - echo -e "${DGN}Using ${BGN}512${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="512" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Unprivileged, or Press [ENTER] for Default: Privileged" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Privileged" CT_TYPE="0"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Unprivileged" - CT_TYPE="1" - echo -en "${DGN}Set CT Type ${BL}Unprivileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 2 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="2"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 512 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="512"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/pihole-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/Proxmox" - -msg_ok "Completed Successfully!\n" -echo -e "${APP}${CL} 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..bd66c313 --- /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/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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}" +set +e +pihole -up +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}/admin${CL} \n" diff --git a/ct/pingvin.sh b/ct/pingvin.sh new file mode 100644 index 00000000..0cce4f60 --- /dev/null +++ b/ct/pingvin.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Pingvin" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/pingvin-share ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Stopping Pingvin Share" +pm2 stop pingvin-share-backend pingvin-share-frontend &>/dev/null +msg_ok "Stopped Pingvin Share" + +msg_info "Updating Pingvin Share" +cd /opt/pingvin-share +git fetch --tags +git checkout $(git describe --tags `git rev-list --tags --max-count=1`) &>/dev/null +cd backend +npm install &>/dev/null +npm run build &>/dev/null +cd ../frontend +npm install &>/dev/null +npm run build &>/dev/null +msg_ok "Updated Pingvin Share" + +msg_info "Starting Pingvin Share" +pm2 start pingvin-share-backend pingvin-share-frontend &>/dev/null +msg_ok "Started Pingvin Share" + +msg_ok "Updated Successfully" +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/plex-v1.sh b/ct/plex-v1.sh deleted file mode 100644 index 68949613..00000000 --- a/ct/plex-v1.sh +++ /dev/null @@ -1,170 +0,0 @@ -#!/usr/bin/env bash - -while true; do - read -p "This will create a New Plex Media Server LXC Container. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if [ ! -z ${MOUNT+x} ]; then - pct unmount $CTID - fi - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} -function load_module() { - if ! $(lsmod | grep -Fq $1); then - modprobe $1 &>/dev/null || \ - die "Failed to load '$1' module." - fi - MODULES_PATH=/etc/modules - if ! $(grep -Fxq "$1" $MODULES_PATH); then - echo "$1" >> $MODULES_PATH || \ - die "Failed to add '$1' module to load at boot." - fi -} -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/plex_setup.sh - -load_module overlay - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content rootdir | awk 'NR>1') -if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then - warn "'Container' needs to be selected for at least one storage location." - die "Unable to detect valid storage location." -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 container?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit - done -fi -info "Using '$STORAGE' for Storage Location." - -CTID=$(pvesh get /cluster/nextid) -info "Container ID is $CTID." - -echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m" -pveam update >/dev/null -echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m" -OSTYPE=ubuntu -OSVERSION=${OSTYPE}-20.04 -mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V) -TEMPLATE="${TEMPLATES[-1]}" -pveam download local $TEMPLATE >/dev/null || - die "A problem occured while downloading the LXC template." - -STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') -case $STORAGE_TYPE in - dir|nfs) - DISK_EXT=".raw" - DISK_REF="$CTID/" - ;; - zfspool) - DISK_PREFIX="subvol" - DISK_FORMAT="subvol" - ;; -esac -DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-} -ROOTFS=${STORAGE}:${DISK_REF-}${DISK} - -echo -e "${CHECKMARK} \e[1;92m Creating LXC Container... \e[0m" -DISK_SIZE=8G -pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -else - mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null -fi -ARCH=$(dpkg --print-architecture) -HOSTNAME=plex -TEMPLATE_STRING="local:vztmpl/${TEMPLATE}" -pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \ - -hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 2 -memory 2048\ - -ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null - -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $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/renderD128 none bind,optional,create=file -EOF - -MOUNT=$(pct mount $CTID | cut -d"'" -f 2) -ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime -pct unmount $CTID && unset MOUNT - -echo -e "${CHECKMARK} \e[1;92m Starting LXC Container... \e[0m" -pct start $CTID -pct push $CTID plex_setup.sh /plex_setup.sh -perms 755 -pct exec $CTID /plex_setup.sh - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') -info "Successfully Created Plex Media Server LXC to $CTID." -echo -e "\e[1;92m Plex Media Server should be reachable by going to the following URL. - http://${IP}:32400/web -\e[0m" diff --git a/ct/plex-v3.sh b/ct/plex-v3.sh deleted file mode 100644 index da77b58e..00000000 --- a/ct/plex-v3.sh +++ /dev/null @@ -1,368 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Plex" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${YW} - _____ _ - | __ \| | - | |__) | | _____ __ - | ___/| |/ _ \ \/ / - | | | | __/> < - |_| v3 |_|\___/_/\_\ -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Privileged${CL}" - CT_TYPE="0" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}8${CL}${DGN}GB${CL}" - DISK_SIZE="8" - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="2048" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type ${CROSS}${YW}Unprivileged, or Press [ENTER] for Default: Privileged" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Privileged" CT_TYPE="0"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Unprivileged" - CT_TYPE="1" - echo -en "${DGN}Set CT Type ${BL}Unprivileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 8 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="8"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -PVE_CHECK -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=ubuntu -export PCT_OSVERSION=20.04 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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 <<EOF >> $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/renderD128 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/setup/plex-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/Proxmox" - -msg_ok "Completed Successfully!\n" -echo -e "Plex Media Server 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..c112078e --- /dev/null +++ b/ct/plex.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="22.04" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 --backtitle "Proxmox VE Helper Scripts" --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select \nplexupdate info >> https://github.com/mrworf/plexupdate" 10 59 2 \ + "1" "Update LXC" ON \ + "2" "Install 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 +set +e +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/pocketbase.sh b/ct/pocketbase.sh new file mode 100644 index 00000000..d7cae744 --- /dev/null +++ b/ct/pocketbase.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Pocketbase" +var_disk="8" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +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}" diff --git a/ct/podman-homeassistant-v1.sh b/ct/podman-homeassistant-v1.sh deleted file mode 100644 index 7bf3164a..00000000 --- a/ct/podman-homeassistant-v1.sh +++ /dev/null @@ -1,189 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will create a New Podman Home Assistant Container LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - _____ _ - | __ \ | | - | |__) |__ __| |_ __ ___ __ _ _ __ - | ___/ _ \ / _ | _ _ \ / _ | _ \ - | | | (_) | (_| | | | | | | (_| | | | | - |_| \___/ \__,_|_| |_| |_|\__,_|_| |_| _ _ _ - | | (_) | | | | - | |__ ___ _ __ ___ ___ __ _ ___ ___ _ ___| |_ __ _ _ __ | |_ - | _ \ / _ \| _ _ \ / _ \/ _ / __/ __| / __| __/ _ | _ \| __| - | | | | (_) | | | | | | __/ (_| \__ \__ \ \__ \ || (_| | | | | |_ - |_| |_|\___/|_| |_| |_|\___|\__,_|___/___/_|___/\__\__,_|_| |_|\__| - -${CL}" -} -header_info -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if [ ! -z ${MOUNT+x} ]; then - pct unmount $CTID - fi - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} -function load_module() { - if ! $(lsmod | grep -Fq $1); then - modprobe $1 &>/dev/null || \ - die "Failed to load '$1' module." - fi - MODULES_PATH=/etc/modules - if ! $(grep -Fxq "$1" $MODULES_PATH); then - echo "$1" >> $MODULES_PATH || \ - die "Failed to add '$1' module to load at boot." - fi -} -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/podman_ha_setup.sh - -load_module overlay - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content rootdir | awk 'NR>1') -if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then - warn "'Container' needs to be selected for at least one storage location." - die "Unable to detect valid storage location." -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 container?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit - done -fi -info "Using ${BL}$STORAGE${CL} for storage location." - -CTID=$(pvesh get /cluster/nextid) -info "Container ID is ${BL}$CTID${CL}" -echo -en "${GN} Updating LXC Template List... " -pveam update >/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Downloading LXC Template... " -OSTYPE=debian -OSVERSION=${OSTYPE}-11 -mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V) -TEMPLATE="${TEMPLATES[-1]}" -pveam download local $TEMPLATE >/dev/null || - die "A problem occured while downloading the LXC template." - -STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') -case $STORAGE_TYPE in - dir|nfs) - DISK_EXT=".raw" - DISK_REF="$CTID/" - ;; - zfspool) - DISK_PREFIX="subvol" - DISK_FORMAT="subvol" - ;; -esac -DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-} -ROOTFS=${STORAGE}:${DISK_REF-}${DISK} -echo -e "${CM}${CL} \r" - -echo -en "${GN} Creating LXC Container... " -DISK_SIZE=16G -pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -else - mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null -fi - ARCH=$(dpkg --print-architecture) -HOSTNAME=p-homeassistant -TEMPLATE_STRING="local:vztmpl/${TEMPLATE}" -pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \ - -hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 2 -memory 2048 \ - -ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -MOUNT=$(pct mount $CTID | cut -d"'" -f 2) -ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime -pct unmount $CTID && unset MOUNT -echo -e "${CM}${CL} \r" -echo -en "${GN} Starting LXC Container... " -pct start $CTID -pct push $CTID podman_ha_setup.sh /podman_ha_setup.sh -perms 755 -echo -e "${CM}${CL} \r" -pct exec $CTID /podman_ha_setup.sh - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') -info "Successfully Created Podman Home Assistant Container LXC to ${BL}$CTID${CL}." -echo -e "${CL} Home Assistant Container should be reachable by going to the following URL. - ${BL}http://${IP}:8123${CL} -Yacht should be reachable by going to the following URL. - ${BL}http://${IP}:8000${CL} \n" diff --git a/ct/podman-homeassistant-v3.sh b/ct/podman-homeassistant-v3.sh deleted file mode 100644 index 30985849..00000000 --- a/ct/podman-homeassistant-v3.sh +++ /dev/null @@ -1,371 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="P-Home Assistant" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - _____ _ - | __ \ | | - | |__) |__ __| |_ __ ___ __ _ _ __ - | ___/ _ \ / _ | _ _ \ / _ | _ \ - | | | (_) | (_| | | | | | | (_| | | | | - |_| \___/ \__,_|_| |_| |_|\__,_|_| |_| _ _ _ - | | v3 (_) | | | | - | |__ ___ _ __ ___ ___ __ _ ___ ___ _ ___| |_ __ _ _ __ | |_ - | _ \ / _ \| _ _ \ / _ \/ _ / __/ __| / __| __/ _ | _ \| __| - | | | | (_) | | | | | | __/ (_| \__ \__ \ \__ \ || (_| | | | | |_ - |_| |_|\___/|_| |_| |_|\___|\__,_|___/___/_|___/\__\__,_|_| |_|\__| - -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Privileged${CL}" - CT_TYPE="0" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}16${CL}${DGN}GB${CL}" - DISK_SIZE="16" - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="2048" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type ${CROSS}${YW}Unprivileged, or Press [ENTER] for Default: Privileged" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Privileged" CT_TYPE="0"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Unprivileged" - CT_TYPE="1" - echo -en "${DGN}Set CT Type ${BL}UnPrivileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 16 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="16"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} -PVE_CHECK -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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 <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -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/setup/podman-homeassistant-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/Proxmox" - -msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable by going to the following URL. - ${BL}http://${IP}:8123${CL} -Yacht should be reachable by going to the following URL. - ${BL}http://${IP}:8000${CL}\n" diff --git a/ct/podman-homeassistant.sh b/ct/podman-homeassistant.sh new file mode 100644 index 00000000..1f02fe7f --- /dev/null +++ b/ct/podman-homeassistant.sh @@ -0,0 +1,143 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + if [[ ! -f /etc/systemd/system/homeassistant.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi + UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UPDATE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 4 \ + "1" "Update system and containers" ON \ + "2" "Install HACS" OFF \ + "3" "Install FileBrowser" OFF \ + "4" "Remove ALL Unused Images" 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 Successfully" + + msg_info "Updating All Containers\n" + CONTAINER_LIST="${1:-$(podman ps -q)}" + for container in ${CONTAINER_LIST}; do + CONTAINER_IMAGE="$(podman inspect --format "{{.Config.Image}}" --type container ${container})" + RUNNING_IMAGE="$(podman inspect --format "{{.Image}}" --type container "${container}")" + podman pull "${CONTAINER_IMAGE}" + LATEST_IMAGE="$(podman inspect --format "{{.Id}}" --type image "${CONTAINER_IMAGE}")" + if [[ "${RUNNING_IMAGE}" != "${LATEST_IMAGE}" ]]; then + echo "Updating ${container} image ${CONTAINER_IMAGE}" + systemctl restart homeassistant + fi + done + msg_ok "All containers updated." + exit +fi +if [ "$UPD" == "2" ]; then + msg_info "Installing Home Assistant Community 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 Community 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 [ "$UPD" == "4" ]; then + msg_info "Removing ALL Unused Images" + podman image prune -a -f + msg_ok "Removed ALL Unused Images" + 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.sh b/ct/podman.sh new file mode 100644 index 00000000..e1e65b56 --- /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/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 Successfully" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/postgresql-v3.sh b/ct/postgresql-v3.sh deleted file mode 100644 index d68d8102..00000000 --- a/ct/postgresql-v3.sh +++ /dev/null @@ -1,361 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -APP="PostgreSQL" -var_disk="4" -var_cpu="1" -var_ram="1024" -var_os="debian" -var_version="11" -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[0-9]+$' -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-install" -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}" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - _____ _ _____ ____ _ - | __ \ | | / ____|/ __ \| | - | |__) |__ ___| |_ __ _ _ __ ___| (___ | | | | | - | ___/ _ \/ __| __/ _ | __/ _ \\___ \| | | | | - | | | (_) \__ \ || (_| | | | __/____) | |__| | |____ - |_| \___/|___/\__\__, |_| \___|_____/ \___\_\______| - __/ | - v3|___/ -${CL}" -} - -header_info - -function PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${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}Using ${BGN}$var_cpu${CL}${DGN}vCPU${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Using ${BGN}$var_ram${CL}${DGN}MiB 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: $var_disk " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: $var_cpu " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: $var_ram " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -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 - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/$var_install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/Proxmox" - -msg_ok "Completed Successfully!\n" -echo -e "Adminer should be reachable by going to the following URL. - ${BL}http://${IP}/adminer/${CL} \n" diff --git a/ct/postgresql.sh b/ct/postgresql.sh new file mode 100644 index 00000000..8ca8f172 --- /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/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 Successfully" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/prometheus-v3.sh b/ct/prometheus-v3.sh deleted file mode 100644 index a41f5125..00000000 --- a/ct/prometheus-v3.sh +++ /dev/null @@ -1,359 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -APP="Prometheus" -var_disk="4" -var_cpu="1" -var_ram="2048" -var_os="debian" -var_version="11" -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[0-9]+$' -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-install" -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}" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - _____ _____ ____ __ __ ______ _______ _ _ ______ _ _ _____ - | __ \| __ \ / __ \| \/ | ____|__ __| | | | ____| | | |/ ____| - | |__) | |__) | | | | \ / | |__ | | | |__| | |__ | | | | (___ - | ___/| _ /| | | | |\/| | __| v3 | | | __ | __| | | | |\___ \ - | | | | \ \| |__| | | | | |____ | | | | | | |____| |__| |____) | - |_| |_| \_\\_____/|_| |_|______| |_| |_| |_|______|\____/|_____/ -${CL}" -} - -header_info - -function PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${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}Using ${BGN}$var_cpu${CL}${DGN}vCPU${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Using ${BGN}$var_ram${CL}${DGN}MiB 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: $var_disk " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: $var_cpu " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: $var_ram " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -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 - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/$var_install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..b2230eaa --- /dev/null +++ b/ct/prometheus.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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_error "There is currently no update path available." +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.sh b/ct/prowlarr.sh new file mode 100644 index 00000000..610928f8 --- /dev/null +++ b/ct/prowlarr.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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_error "There is currently no update path available." +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.sh b/ct/qbittorrent.sh new file mode 100644 index 00000000..0a8b1db8 --- /dev/null +++ b/ct/qbittorrent.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/rabbitmq.sh b/ct/rabbitmq.sh new file mode 100644 index 00000000..ff31111e --- /dev/null +++ b/ct/rabbitmq.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: tteck +# Co-Author: MickLesk (Canbiz) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ____ __ __ _ __ __ _______ + / __ \____ _/ /_ / /_ (_) /_/ |/ / __ \ + / /_/ / __ `/ __ \/ __ \/ / __/ /|_/ / / / / + / _, _/ /_/ / /_/ / /_/ / / /_/ / / / /_/ / +/_/ |_|\__,_/_.___/_.___/_/\__/_/ /_/\___\_\ + +EOF +} +header_info +echo -e "Loading..." +APP="RabbitMQ" +var_disk="4" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + + +function update_script() { +header_info +if [[ ! -d /etc/rabbitmq ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +if (( $(df /boot | awk 'NR==2{gsub("%","",$5); print $5}') > 80 )); then + read -r -p "Warning: Storage is dangerously low, continue anyway? <y/N> " prompt + [[ ${prompt,,} =~ ^(y|yes)$ ]] || exit +fi +msg_info "Stopping ${APP} Service" +systemctl stop rabbitmq-server +msg_ok "Stopped ${APP} Service" + +msg_info "Updating..." +apt install --only-upgrade rabbitmq-server &>/dev/null +msg_ok "Update Successfully" + +msg_info "Starting ${APP}" +systemctl start rabbitmq-server +msg_ok "Started ${APP}" +msg_ok "Updated Successfully" +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}:15672${CL} \n" diff --git a/ct/radarr.sh b/ct/radarr.sh new file mode 100644 index 00000000..8903135a --- /dev/null +++ b/ct/radarr.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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_error "There is currently no update path available." +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/rdtclient.sh b/ct/rdtclient.sh new file mode 100755 index 00000000..7168998e --- /dev/null +++ b/ct/rdtclient.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="RDTClient" +var_disk="4" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/rdtc/ ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP" +systemctl stop rdtc +mkdir -p rdtc-backup +cp -R /opt/rdtc/appsettings.json rdtc-backup/ +wget -q https://github.com/rogerfar/rdt-client/releases/latest/download/RealDebridClient.zip +unzip -oqq RealDebridClient.zip -d /opt/rdtc +cp -R rdtc-backup/appsettings.json /opt/rdtc/ +rm -rf rdtc-backup RealDebridClient.zip +systemctl start rdtc +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}:6500${CL} \n" diff --git a/ct/readarr.sh b/ct/readarr.sh new file mode 100644 index 00000000..2e4494cf --- /dev/null +++ b/ct/readarr.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/readeck.sh b/ct/readeck.sh new file mode 100644 index 00000000..cc5204ba --- /dev/null +++ b/ct/readeck.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Readeck" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/readeck ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP}" +LATEST=$(curl -s https://codeberg.org/readeck/readeck/releases/ | grep -oP '(?<=Version )\d+\.\d+\.\d+' | head -1) +systemctl stop readeck.service +rm -rf /opt/readeck/readeck +cd /opt/readeck +wget -q -O readeck https://codeberg.org/readeck/readeck/releases/download/${LATEST}/readeck-${LATEST}-linux-amd64 +chmod a+x readeck +systemctl start readeck.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}:8000${CL}\n" diff --git a/ct/redis.sh b/ct/redis.sh new file mode 100644 index 00000000..c4621e20 --- /dev/null +++ b/ct/redis.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Redis" +var_disk="4" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="12" +VERBOSE="yes" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /lib/systemd/system/redis-server.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_error "There is currently no update path available." +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/rockylinux.sh b/ct/rockylinux.sh new file mode 100644 index 00000000..8285e227 --- /dev/null +++ b/ct/rockylinux.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 "Updated Successfully" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/ct/rtsptoweb.sh b/ct/rtsptoweb.sh new file mode 100644 index 00000000..56484a60 --- /dev/null +++ b/ct/rtsptoweb.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="RTSPtoWeb" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/runtipi.sh b/ct/runtipi.sh new file mode 100644 index 00000000..279230f3 --- /dev/null +++ b/ct/runtipi.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Runtipi" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/runtipi ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +cd /opt/runtipi && ./runtipi-cli update latest +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/sabnzbd.sh b/ct/sabnzbd.sh new file mode 100644 index 00000000..c6d0aa26 --- /dev/null +++ b/ct/sabnzbd.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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.sh b/ct/scrypted.sh new file mode 100644 index 00000000..306ab620 --- /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/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 Successfully" +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/sftpgo.sh b/ct/sftpgo.sh new file mode 100644 index 00000000..2354fe7d --- /dev/null +++ b/ct/sftpgo.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="SFTPGo" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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}:8080/web/admin ${CL} \n" diff --git a/ct/shinobi.sh b/ct/shinobi.sh new file mode 100644 index 00000000..410f9433 --- /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/build.func) +# Copyright (c) 2021-2024 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" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/smokeping.sh b/ct/smokeping.sh new file mode 100644 index 00000000..8da7d96c --- /dev/null +++ b/ct/smokeping.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash + +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="SmokePing" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if ! command -v smokeping &> /dev/null; then msg_error "No ${APP} Installation Found!"; exit; fi + +msg_info "Updating ${APP}" +apt-get update &>/dev/null +apt-get -y upgrade &>/dev/null +msg_ok "Updated Successfully" +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}/smokeping${CL} \n" diff --git a/ct/sonarr.sh b/ct/sonarr.sh new file mode 100644 index 00000000..fe2c5939 --- /dev/null +++ b/ct/sonarr.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/Sonarr ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP v4" +systemctl stop sonarr.service +wget -q -O SonarrV4.tar.gz 'https://services.sonarr.tv/v1/download/main/latest?version=4&os=linux&arch=x64' +tar -xzf SonarrV4.tar.gz +rm -rf /opt/Sonarr +mv Sonarr /opt +rm -rf SonarrV4.tar.gz +systemctl start sonarr.service +msg_ok "Updated $APP v4" +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/spoolman.sh b/ct/spoolman.sh new file mode 100644 index 00000000..dadff3bf --- /dev/null +++ b/ct/spoolman.sh @@ -0,0 +1,103 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: tteck +# Co-Author: MickLesk (Canbiz) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + _____ __ + / ___/____ ____ ____ / /___ ___ ____ _____ + \__ \/ __ \/ __ \/ __ \/ / __ `__ \/ __ `/ __ \ + ___/ / /_/ / /_/ / /_/ / / / / / / / /_/ / / / / +/____/ .___/\____/\____/_/_/ /_/ /_/\__,_/_/ /_/ + /_/ +EOF +} +header_info +echo -e "Loading..." +APP="Spoolman" +var_disk="4" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/spoolman ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +if (( $(df /boot | awk 'NR==2{gsub("%","",$5); print $5}') > 80 )); then + read -r -p "Warning: Storage is dangerously low, continue anyway? <y/N> " prompt + [[ ${prompt,,} =~ ^(y|yes)$ ]] || exit +fi +RELEASE=$(wget -q https://github.com/Donkie/Spoolman/releases/latest -O - | grep "title>Release" | cut -d " " -f 4) +if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + + msg_info "Stopping ${APP} Service" + systemctl stop spoolman + msg_ok "Stopped ${APP} Service" + + msg_info "Updating ${APP} to ${RELEASE}" + cd /opt + rm -rf spoolman_bak + mv spoolman spoolman_bak + wget -q https://github.com/Donkie/Spoolman/releases/download/${RELEASE}/spoolman.zip + unzip -q spoolman.zip -d spoolman + cd spoolman + pip3 install -r requirements.txt >/dev/null 2>&1 + cp .env.example .env + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated ${APP} to ${RELEASE}" + + msg_info "Starting ${APP} Service" + systemctl start spoolman + msg_ok "Started ${APP} Service" + + msg_info "Cleaning up" + rm -rf /opt/spoolman.zip + msg_ok "Cleaned" + + msg_ok "Updated Successfully!\n" +else + msg_ok "No update required. ${APP} is already at ${RELEASE}" +fi +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}:7912${CL} \n" diff --git a/ct/stirling-pdf.sh b/ct/stirling-pdf.sh new file mode 100644 index 00000000..f1505054 --- /dev/null +++ b/ct/stirling-pdf.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Stirling-PDF" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/Stirling-PDF ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating ${APP}" +systemctl stop stirlingpdf +RELEASE=$(curl -s https://api.github.com/repos/Stirling-Tools/Stirling-PDF/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +wget -q https://github.com/Stirling-Tools/Stirling-PDF/archive/refs/tags/v$RELEASE.tar.gz +tar -xzf v$RELEASE.tar.gz +cd Stirling-PDF-$RELEASE +chmod +x ./gradlew +./gradlew build &>/dev/null +cp -r ./build/libs/Stirling-PDF-*.jar /opt/Stirling-PDF/ +cp -r scripts /opt/Stirling-PDF/ +cd ~ +rm -rf Stirling-PDF-$RELEASE v$RELEASE.tar.gz +ln -sf /opt/Stirling-PDF/Stirling-PDF-$RELEASE.jar /opt/Stirling-PDF/Stirling-PDF.jar +systemctl start stirlingpdf +msg_ok "Updated ${APP} to v$RELEASE" +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/syncthing.sh b/ct/syncthing.sh new file mode 100644 index 00000000..5cf7765c --- /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/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 Successfully" +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/tandoor.sh b/ct/tandoor.sh new file mode 100644 index 00000000..29085af5 --- /dev/null +++ b/ct/tandoor.sh @@ -0,0 +1,89 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: tteck +# Co-Author: MickLesk (Canbiz) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ______ __ ____ _ + /_ __/___ _____ ____/ /___ ____ _____ / __ \___ _____(_)___ ___ _____ + / / / __ `/ __ \/ __ / __ \/ __ \/ ___/ / /_/ / _ \/ ___/ / __ \/ _ \/ ___/ + / / / /_/ / / / / /_/ / /_/ / /_/ / / / _, _/ __/ /__/ / /_/ / __(__ ) +/_/ \__,_/_/ /_/\__,_/\____/\____/_/ /_/ |_|\___/\___/_/ .___/\___/____/ + /_/ +EOF +} +header_info +echo -e "Loading..." +APP="Tandoor" +var_disk="10" +var_cpu="4" +var_ram="4096" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + header_info + if [[ ! -d /opt/tandoor ]]; then msg_error "No ${APP} Installation Found!"; exit; fi + if cd /opt/tandoor && git pull | grep -q 'Already up to date'; then + msg_ok "There is currently no update available." + else + msg_info "Updating ${APP} (Patience)" + export $(cat /opt/tandoor/.env | grep "^[^#]" | xargs) + cd /opt/tandoor/ + pip3 install -r requirements.txt >/dev/null 2>&1 + /usr/bin/python3 /opt/tandoor/manage.py migrate >/dev/null 2>&1 + /usr/bin/python3 /opt/tandoor/manage.py collectstatic --no-input >/dev/null 2>&1 + /usr/bin/python3 /opt/tandoor/manage.py collectstatic_js_reverse >/dev/null 2>&1 + cd /opt/tandoor/vue + yarn install >/dev/null 2>&1 + yarn build >/dev/null 2>&1 + systemctl restart gunicorn_tandoor + msg_ok "Updated ${APP}" + fi + exit +} + +start +build_container +description + +msg_info "Setting Container to Normal Resources" +pct set $CTID -memory 2048 +pct set $CTID -cores 2 +msg_ok "Set Container to Normal Resources" + +msg_ok "Completed Successfully!\n" +echo -e "${APP} Setup should be reachable by going to the following URL. + ${BL}http://${IP}:8002${CL} \n" diff --git a/ct/tasmoadmin.sh b/ct/tasmoadmin.sh new file mode 100644 index 00000000..662c36f1 --- /dev/null +++ b/ct/tasmoadmin.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="TasmoAdmin" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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}:9999${CL} \n" diff --git a/ct/tautulli.sh b/ct/tautulli.sh new file mode 100644 index 00000000..55a628d3 --- /dev/null +++ b/ct/tautulli.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Tautulli" +var_disk="4" +var_cpu="2" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/Tautulli/ ]]; 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}:8181${CL} \n" diff --git a/ct/tdarr.sh b/ct/tdarr.sh new file mode 100644 index 00000000..11bc2880 --- /dev/null +++ b/ct/tdarr.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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-v2.sh b/ct/technitiumdns-v2.sh deleted file mode 100644 index 2d960480..00000000 --- a/ct/technitiumdns-v2.sh +++ /dev/null @@ -1,259 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -APP="Technitium DNS" -HN=$(echo ${APP,,} | tr -d ' ') -while true; do - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - - _______ _ _ _ _ - |__ __| | | (_) | (_) - | | ___ ___| |__ _ __ _| |_ _ _ _ _ __ ___ - | |/ _ \/ __| _ \| _ \| | __| | | | | _ _ \ - | | __/ (__| | | | | | | | |_| | |_| | | | | | | - |_|\___|\___|_| |_|_| |_|_|\__|_|\__,_|_| |_| |_| -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=2 -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 1 - -memory 512 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}. -${BL}${APP}${CL} should be reachable by going to the following URL. - ${BL}http://${IP}:5380${CL} \n" diff --git a/ct/technitiumdns-v3.sh b/ct/technitiumdns-v3.sh deleted file mode 100644 index 201b6267..00000000 --- a/ct/technitiumdns-v3.sh +++ /dev/null @@ -1,356 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Technitium DNS" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - _______ _ _ _ _ - |__ __| | | (_) | (_) - | | ___v3___| |__ _ __ _| |_ _ _ _ _ __ ___ - | |/ _ \/ __| _ \| _ \| | __| | | | | _ _ \ - | | __/ (__| | | | | | | | |_| | |_| | | | | | | - |_|\___|\___|_| |_|_| |_|_|\__|_|\__,_|_| |_| |_| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}2${CL}${DGN}GB${CL}" - DISK_SIZE="2" - echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}" - CORE_COUNT="1" - echo -e "${DGN}Using ${BGN}512${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="512" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 2 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="2"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 512 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="512"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/technitiumdns-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..85775abd --- /dev/null +++ b/ct/technitiumdns.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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-8.0 > /dev/null 2>&1; then + wget -q https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb + dpkg -i packages-microsoft-prod.deb &>/dev/null + apt-get update &>/dev/null + apt-get install -y aspnetcore-runtime-8.0 &>/dev/null + rm packages-microsoft-prod.deb +fi +bash <(curl -fsSL https://download.technitium.com/dns/install.sh) &>/dev/null +msg_ok "Updated Successfully" +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/threadfin.sh b/ct/threadfin.sh new file mode 100644 index 00000000..e870e26c --- /dev/null +++ b/ct/threadfin.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Threadfin" +var_disk="4" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/threadfin ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP" +systemctl stop threadfin.service +wget -q -O /opt/threadfin/threadfin 'https://github.com/Threadfin/Threadfin/releases/latest/download/Threadfin_linux_amd64' +chmod +x /opt/threadfin/threadfin +systemctl start threadfin.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}:34400/web${CL} \n" diff --git a/ct/traccar.sh b/ct/traccar.sh new file mode 100644 index 00000000..1b62939a --- /dev/null +++ b/ct/traccar.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Traccar" +var_disk="2" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/traccar ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_error "There is currently no update path available." +exit +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}:8082${CL} \n" diff --git a/ct/traefik.sh b/ct/traefik.sh new file mode 100644 index 00000000..d86ac143 --- /dev/null +++ b/ct/traefik.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Traefik" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/systemd/system/traefik.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +RELEASE=$(curl -s https://api.github.com/repos/traefik/traefik/releases | grep -oP '"tag_name":\s*"v\K[\d.]+?(?=")' | sort -V | tail -n 1) +msg_info "Updating $APP LXC" +if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + wget -q https://github.com/traefik/traefik/releases/download/v${RELEASE}/traefik_v${RELEASE}_linux_amd64.tar.gz + tar -C /tmp -xzf traefik*.tar.gz + mv /tmp/traefik /usr/bin/ + rm -rf traefik*.tar.gz + msg_ok "Updated $APP LXC" +else + msg_ok "No update required. ${APP} is already at ${RELEASE}" +fi +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/transmission.sh b/ct/transmission.sh new file mode 100644 index 00000000..a7e234e4 --- /dev/null +++ b/ct/transmission.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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.sh b/ct/trilium.sh new file mode 100644 index 00000000..ac162c50 --- /dev/null +++ b/ct/trilium.sh @@ -0,0 +1,89 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/TriliumNext/Notes/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/TriliumNext/Notes/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 "Updated Successfully" +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-v1.sh b/ct/ubuntu-v1.sh deleted file mode 100644 index 3703d85a..00000000 --- a/ct/ubuntu-v1.sh +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/env bash - -while true; do - read -p "This will create a New Ubuntu 21.10 LXC Container. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if [ ! -z ${MOUNT+x} ]; then - pct unmount $CTID - fi - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} -function load_module() { - if ! $(lsmod | grep -Fq $1); then - modprobe $1 &>/dev/null || \ - die "Failed to load '$1' module." - fi - MODULES_PATH=/etc/modules - if ! $(grep -Fxq "$1" $MODULES_PATH); then - echo "$1" >> $MODULES_PATH || \ - die "Failed to add '$1' module to load at boot." - fi -} -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/ubuntu_setup.sh - -load_module overlay - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content rootdir | awk 'NR>1') -if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then - warn "'Container' needs to be selected for at least one storage location." - die "Unable to detect valid storage location." -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 container?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit - done -fi -info "Using '$STORAGE' for storage location." - -CTID=$(pvesh get /cluster/nextid) -info "Container ID is $CTID." - -echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m" -pveam update >/dev/null -echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m" -OSTYPE=ubuntu -OSVERSION=${OSTYPE}-21.10 -mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V) -TEMPLATE="${TEMPLATES[-1]}" -pveam download local $TEMPLATE >/dev/null || - die "A problem occured while downloading the LXC template." - -STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') -case $STORAGE_TYPE in - dir|nfs) - DISK_EXT=".raw" - DISK_REF="$CTID/" - ;; - zfspool) - DISK_PREFIX="subvol" - DISK_FORMAT="subvol" - ;; -esac -DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-} -ROOTFS=${STORAGE}:${DISK_REF-}${DISK} - -echo -e "${CHECKMARK} \e[1;92m Creating LXC... \e[0m" -DISK_SIZE=2G -pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -else - mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null -fi -ARCH=$(dpkg --print-architecture) -HOSTNAME=$OSTYPE -TEMPLATE_STRING="local:vztmpl/${TEMPLATE}" -pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \ - -hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 1 -memory 512\ - -ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null - -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF - -MOUNT=$(pct mount $CTID | cut -d"'" -f 2) -ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime -pct unmount $CTID && unset MOUNT - -echo -e "${CHECKMARK} \e[1;92m Starting LXC... \e[0m" -pct start $CTID -pct push $CTID ubuntu_setup.sh /ubuntu_setup.sh -perms 755 -pct exec $CTID /ubuntu_setup.sh - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') -info "Successfully created a Ubuntu LXC Container to $CTID at IP Address ${IP}" diff --git a/ct/ubuntu-v2.sh b/ct/ubuntu-v2.sh deleted file mode 100644 index 4152e1d0..00000000 --- a/ct/ubuntu-v2.sh +++ /dev/null @@ -1,255 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will create a New Ubuntu 21.10 LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${YW} - _ _ _ _ - | | | | | | | - | | | | |__ _ _ _ __ | |_ _ _ - | | | | _ \| | | | _ \| __| | | | - | |__| | |_) | |_| | | | | |_| |_| | - \____/|_.__/ \__,_|_| |_|\__|\__,_| - -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=ubuntu -export PCT_OSVERSION=21.10 -export PCT_DISK_SIZE=2 -export PCT_OPTIONS=" - -features $FEATURES - -hostname ubuntu - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 1 - -memory 512 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/ubuntu-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created Ubuntu 21.10 LXC to${CL} ${BL}$CTID${CL}. \n" diff --git a/ct/ubuntu-v3.sh b/ct/ubuntu-v3.sh deleted file mode 100644 index 5f5b38b1..00000000 --- a/ct/ubuntu-v3.sh +++ /dev/null @@ -1,377 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Ubuntu" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${YW} - _ _ _ _ - | | | | | | | - | | | | |__ _ v3_ _ __ | |_ _ _ - | | | | _ \| | | | _ \| __| | | | - | |__| | |_) | |_| | | | | |_| |_| | - \____/|_.__/ \__,_|_| |_|\__|\__,_| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using Version ${BGN}22.04${CL}" - VER="22.04" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}2${CL}${DGN}GB${CL}" - DISK_SIZE="2" - echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}" - CORE_COUNT="1" - echo -e "${DGN}Using ${BGN}512${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="512" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type 18.04, 20.04, 21.10 or Press [ENTER] for Default: 22.04" - read VER - if [ -z $VER ]; then VER="22.04"; fi; - echo -en "${DGN}Set Version To ${BL}$VER${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$VER${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$VER${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$VER${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$VER${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$VER${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 2 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="2"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$VER${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$VER${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 512 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="512"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$VER${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$VER${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$VER${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$VER${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$VER${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=ubuntu -export PCT_OSVERSION=$VER -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/ubuntu-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/Proxmox" - -msg_ok "Completed Successfully!\n" diff --git a/ct/ubuntu.sh b/ct/ubuntu.sh new file mode 100644 index 00000000..448ca243 --- /dev/null +++ b/ct/ubuntu.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="1" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET="dhcp" + GATE="" + APT_CACHER="" + APT_CACHER_IP="" + 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/umami.sh b/ct/umami.sh new file mode 100644 index 00000000..065f4516 --- /dev/null +++ b/ct/umami.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Umami" +var_disk="12" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/umami ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +if (( $(df /boot | awk 'NR==2{gsub("%","",$5); print $5}') > 80 )); then + read -r -p "Warning: Storage is dangerously low, continue anyway? <y/N> " prompt + [[ ${prompt,,} =~ ^(y|yes)$ ]] || exit +fi + +msg_info "Stopping ${APP}" +systemctl stop umami +msg_ok "Stopped $APP" + +msg_info "Updating ${APP}" +cd /opt/umami +git pull +yarn install +yarn build +msg_ok "Updated ${APP}" + +msg_info "Starting ${APP}" +systemctl start umami +msg_ok "Started ${APP}" + +msg_ok "Updated Successfully" +exit +} + +start +build_container +description + +msg_info "Setting Container to Normal Resources" +pct set $CTID -memory 1024 +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}:3000${CL} \n" diff --git a/ct/umbrel.sh b/ct/umbrel.sh new file mode 100644 index 00000000..62f9a471 --- /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/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="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-v2.sh b/ct/unifi-v2.sh deleted file mode 100644 index 077f3cc1..00000000 --- a/ct/unifi-v2.sh +++ /dev/null @@ -1,258 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -APP="UniFi" -HN=$(echo ${APP,,} | tr -d ' ') -while true; do - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - _ _ _ ______ _ - | | | | (_) ____(_) - | | | |_ __ _| |__ _ - | | | | _ \| | __| | | - | |__| | | | | | | | | - \____/|_| |_|_|_| |_| -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=8 -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 2 - -memory 2048 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}. -${BL}${APP}${CL} should be reachable by going to the following URL. - ${BL}https://${IP}:8443${CL} \n" diff --git a/ct/unifi-v3.sh b/ct/unifi-v3.sh deleted file mode 100644 index 158758b1..00000000 --- a/ct/unifi-v3.sh +++ /dev/null @@ -1,356 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Unifi" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - _ _ _ ______ _ - | | | | (_) ____(_) - | | | |_ __ _| |__ _ - | | | | _ \| | __| | | - | |__| | | | | | | | | - \____/|_| |_|_|_| v3 |_| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}8${CL}${DGN}GB${CL}" - DISK_SIZE="8" - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="2048" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 8 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="8"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/unifi-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..cec984c5 --- /dev/null +++ b/ct/unifi.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + __ __ _ _____ + / / / /__ (_) __(_) + / / / / __ \/ / /_/ / +/ /_/ / / / / / __/ / +\____/_/ /_/_/_/ /_/ + +EOF +} +header_info +if ! grep -q -m1 'avx[^ ]*' /proc/cpuinfo; then + echo "AVX instruction set is not supported on this CPU." + exit +fi +echo -e "Loading..." +APP="Unifi" +var_disk="8" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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}" +apt-get update --allow-releaseinfo-change +apt-get install -y unifi +msg_ok "Updated Successfully" +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/unmanic.sh b/ct/unmanic.sh new file mode 100644 index 00000000..04134cee --- /dev/null +++ b/ct/unmanic.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Unmanic" +var_disk="4" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/systemd/system/unmanic.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP LXC" +pip3 install -U unmanic &>/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}:8888${CL} \n" diff --git a/ct/uptimekuma-v2.sh b/ct/uptimekuma-v2.sh deleted file mode 100644 index b40519ba..00000000 --- a/ct/uptimekuma-v2.sh +++ /dev/null @@ -1,261 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -DGN=`echo "\033[32m"` -CL=`echo "\033[m"` -APP="Uptime Kuma" -HN=$(echo ${APP,,} | tr -d ' ') -while true; do - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${DGN} - _ _ _ _ _ __ - | | | | | | (_) | |/ / - | | | |_ __ | |_ _ _ __ ___ ___ | ' /_ _ _ __ ___ __ _ - | | | | _ \| __| | _ _ \ / _ \ | <| | | | _ _ \ / _ | - | |__| | |_) | |_| | | | | | | __/ | . \ |_| | | | | | | (_| | - \____/| .__/ \__|_|_| |_| |_|\___| |_|\_\__,_|_| |_| |_|\__,_| - | | - |_| -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=2 -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 1 - -memory 512 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some applications may not work properly due to ZFS not supporting 'fallocate'." -fi -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}. -${BL}${APP}${CL} should be reachable by going to the following URL. - ${BL}http://${IP}:3001${CL}\n" diff --git a/ct/uptimekuma-v3.sh b/ct/uptimekuma-v3.sh deleted file mode 100644 index d9cb376b..00000000 --- a/ct/uptimekuma-v3.sh +++ /dev/null @@ -1,358 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Uptime Kuma" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${DGN} - _ _ _ _ _ __ - | | | | | | (_) | |/ / - | | | |_v3_ | |_ _ _ __ ___ ___ | ' /_ _ _ __ ___ __ _ - | | | | _ \| __| | _ _ \ / _ \ | <| | | | _ _ \ / _ | - | |__| | |_) | |_| | | | | | | __/ | . \ |_| | | | | | | (_| | - \____/| .__/ \__|_|_| |_| |_|\___| |_|\_\__,_|_| |_| |_|\__,_| - | | - |_| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}4${CL}${DGN}GB${CL}" - DISK_SIZE="4" - echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}" - CORE_COUNT="1" - echo -e "${DGN}Using ${BGN}1024${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="1024" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 4 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="4"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 1024 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="1024"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/uptimekuma-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..17289c24 --- /dev/null +++ b/ct/uptimekuma.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 + if [[ "$(node -v | cut -d 'v' -f 2)" == "18."* ]]; then + if ! command -v npm >/dev/null 2>&1; then + echo "Installing NPM..." + apt-get install -y npm >/dev/null 2>&1 + echo "Installed NPM..." + fi + 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 "Updated Successfully" +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-v1.sh b/ct/vaultwarden-v1.sh deleted file mode 100644 index 56b5ac3b..00000000 --- a/ct/vaultwarden-v1.sh +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/env bash -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -RD=`echo "\033[01;31m"` -BL=`echo "\033[36m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will create a New Vaultwarden LXC Container. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - __ __ _ _ _ - \ \ / / | | | | | - \ \ / /_ _ _ _| | |___ ____ _ _ __ __| | ___ _ __ - \ \/ / _ | | | | | __\ \ /\ / / _ | __/ _ |/ _ \ _ \ - \ / (_| | |_| | | |_ \ V V / (_| | | | (_| | __/ | | | - \/ \__,_|\__,_|_|\__| \_/\_/ \__,_|_| \__,_|\___|_| |_| - -${CL}" -} - -header_info -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if [ ! -z ${MOUNT+x} ]; then - pct unmount $CTID - fi - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} -function load_module() { - if ! $(lsmod | grep -Fq $1); then - modprobe $1 &>/dev/null || \ - die "Failed to load '$1' module." - fi - MODULES_PATH=/etc/modules - if ! $(grep -Fxq "$1" $MODULES_PATH); then - echo "$1" >> $MODULES_PATH || \ - die "Failed to add '$1' module to load at boot." - fi -} -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/vault_setup.sh - -load_module overlay -echo -e "${RD} Expect 30+ minute install time. ${CL} \n" -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content rootdir | awk 'NR>1') -if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then - warn "'Container' needs to be selected for at least one storage location." - die "Unable to detect valid storage location." -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 container?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit - done -fi -info "Using '$STORAGE' for storage location." - -CTID=$(pvesh get /cluster/nextid) -info "Container ID is $CTID." - -echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m" -pveam update >/dev/null - -echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m" -OSTYPE=debian -OSVERSION=${OSTYPE}-11 -mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V) -TEMPLATE="${TEMPLATES[-1]}" -pveam download local $TEMPLATE >/dev/null || - die "A problem occured while downloading the LXC template." - -STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') -case $STORAGE_TYPE in - dir|nfs) - DISK_EXT=".raw" - DISK_REF="$CTID/" - ;; - zfspool) - DISK_PREFIX="subvol" - DISK_FORMAT="subvol" - ;; -esac -DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-} -ROOTFS=${STORAGE}:${DISK_REF-}${DISK} - -echo -e "${CHECKMARK} \e[1;92m Creating LXC Container... \e[0m" -DISK_SIZE=8G -pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -else - mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null -fi -ARCH=$(dpkg --print-architecture) -HOSTNAME=vaultwarden -TEMPLATE_STRING="local:vztmpl/${TEMPLATE}" -pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \ - -hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 4 -memory 4096\ - -ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null - -MOUNT=$(pct mount $CTID | cut -d"'" -f 2) -ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime -pct unmount $CTID && unset MOUNT - -echo -e "${CHECKMARK} \e[1;92m Starting LXC Container... \e[0m" -pct start $CTID -pct push $CTID vault_setup.sh /vault_setup.sh -perms 755 -pct exec $CTID /vault_setup.sh - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') -info "Successfully created a Vaultwarden LXC Container to $CTID" -echo -e "\e[1;92m Vaultwarden should be reachable by going to the following URL. - http://${IP}:8000 -\e[0m" diff --git a/ct/vaultwarden-v2.sh b/ct/vaultwarden-v2.sh deleted file mode 100644 index fe16570c..00000000 --- a/ct/vaultwarden-v2.sh +++ /dev/null @@ -1,259 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -APP="Vaultwarden" -HN=$(echo ${APP,,} | tr -d ' ') -while true; do - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - __ __ _ _ _ - \ \ / / | | | | | - \ \ / /_ _ _ _| | |___ ____ _ _ __ __| | ___ _ __ - \ \/ / _ | | | | | __\ \ /\ / / _ | __/ _ |/ _ \ _ \ - \ / (_| | |_| | | |_ \ V V / (_| | | | (_| | __/ | | | - \/ \__,_|\__,_|_|\__| \_/\_/ \__,_|_| \__,_|\___|_| |_| - -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=8 -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 4 - -memory 4096 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $LXC_CONFIG -lxc.cgroup2.devices.allow: a -lxc.cap.drop: -EOF -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}. -${BL}${APP}${CL} should be reachable by going to the following URL. - ${BL}http://${IP}:8000${CL} \n" diff --git a/ct/vaultwarden-v3.sh b/ct/vaultwarden-v3.sh deleted file mode 100644 index 735160ff..00000000 --- a/ct/vaultwarden-v3.sh +++ /dev/null @@ -1,361 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Vaultwarden" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - __ __ _ _ _ - \ \ v3 / / | | | | | - \ \ / /_ _ _ _| | |___ ____ _ _ __ __| | ___ _ __ - \ \/ / _ | | | | | __\ \ /\ / / _ | __/ _ |/ _ \ _ \ - \ / (_| | |_| | | |_ \ V V / (_| | | | (_| | __/ | | | - \/ \__,_|\__,_|_|\__| \_/\_/ \__,_|_| \__,_|\___|_| |_| -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}6${CL}${DGN}GB${CL}" - DISK_SIZE="6" - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="2048" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 6 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="6"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/vaultwarden-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..f7901b79 --- /dev/null +++ b/ct/vaultwarden.sh @@ -0,0 +1,150 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="5120" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 --backtitle "Proxmox VE Helper Scripts" --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 3 \ + "1" "VaultWarden $VAULT" ON \ + "2" "Web-Vault $WVRELEASE" OFF \ + "3" "Set 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 + if NEWTOKEN=$(whiptail --backtitle "Proxmox VE Helper Scripts" --passwordbox "Set the ADMIN_TOKEN" 10 58 3>&1 1>&2 2>&3); then + if [[ -z "$NEWTOKEN" ]]; then exit; fi + if ! command -v argon2 >/dev/null 2>&1; then apt-get install -y argon2 &>/dev/null; fi + TOKEN=$(echo -n ${NEWTOKEN} | argon2 "$(openssl rand -base64 32)" -t 2 -m 16 -p 4 -l 64 -e) + sed -i "s|ADMIN_TOKEN=.*|ADMIN_TOKEN='${TOKEN}'|" /opt/vaultwarden/.env + if [[ -f /opt/vaultwarden/data/config.json ]]; then + sed -i "s|\"admin_token\":.*|\"admin_token\": \"${TOKEN}\"|" /opt/vaultwarden/data/config.json + fi + systemctl restart vaultwarden + 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/wastebin.sh b/ct/wastebin.sh new file mode 100644 index 00000000..c76c428e --- /dev/null +++ b/ct/wastebin.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 tteck +# Author: tteck +# Co-Author: MickLesk (Canbiz) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +# Source: https://github.com/matze/wastebin + + +function header_info { +clear +cat <<"EOF" + _ __ __ __ _ +| | / /___ ______/ /____ / /_ (_)___ +| | /| / / __ `/ ___/ __/ _ \/ __ \/ / __ \ +| |/ |/ / /_/ (__ ) /_/ __/ /_/ / / / / / +|__/|__/\__,_/____/\__/\___/_.___/_/_/ /_/ + +EOF +} +header_info +echo -e "Loading..." +APP="Wastebin" +var_disk="4" +var_cpu="1" +var_ram="1024" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/wastebin ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +RELEASE=$(curl -s https://api.github.com/repos/matze/wastebin/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + msg_info "Stopping Wastebin" + systemctl stop wastebin + msg_ok "Wastebin Stopped" + + msg_info "Updating Wastebin" + wget -q https://github.com/matze/wastebin/releases/download/${RELEASE}/wastebin_${RELEASE}_x86_64-unknown-linux-musl.tar.zst + tar -xf wastebin_${RELEASE}_x86_64-unknown-linux-musl.tar.zst + cp -f wastebin /opt/wastebin/ + chmod +x /opt/wastebin/wastebin + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated Wastebin" + + msg_info "Starting Wastebin" + systemctl start wastebin + msg_ok "Started Wastebin" + + msg_info "Cleaning Up" + rm -rf wastebin_${RELEASE}_x86_64-unknown-linux-musl.tar.zst + msg_ok "Cleaned" + msg_ok "Updated Successfully" +else + msg_ok "No update required. ${APP} is already at ${RELEASE}" +fi +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}:8088${CL} \n" diff --git a/ct/watchyourlan.sh b/ct/watchyourlan.sh new file mode 100644 index 00000000..93eba4d1 --- /dev/null +++ b/ct/watchyourlan.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="WatchYourLAN" +var_disk="2" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /lib/systemd/system/watchyourlan.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP" +systemctl stop watchyourlan.service +cp -R /data/config.yaml config.yaml +RELEASE=$(curl -s https://api.github.com/repos/aceberg/WatchYourLAN/releases/latest | grep -o '"tag_name": *"[^"]*"' | cut -d '"' -f 4) +wget -q https://github.com/aceberg/WatchYourLAN/releases/download/$RELEASE/watchyourlan_${RELEASE}_linux_amd64.deb +dpkg -i watchyourlan_${RELEASE}_linux_amd64.deb +cp -R config.yaml /data/config.yaml +sed -i 's|/etc/watchyourlan/config.yaml|/data/config.yaml|' /lib/systemd/system/watchyourlan.service +rm watchyourlan_${RELEASE}_linux_amd64.deb config.yaml +systemctl enable -q --now watchyourlan.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}:8840${CL} \n" diff --git a/ct/whisparr.sh b/ct/whisparr.sh new file mode 100644 index 00000000..1a8b9a01 --- /dev/null +++ b/ct/whisparr.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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-v3.sh b/ct/whoogle-v3.sh deleted file mode 100644 index 59274f4e..00000000 --- a/ct/whoogle-v3.sh +++ /dev/null @@ -1,360 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -APP="Whoogle" -var_disk="2" -var_cpu="1" -var_ram="512" -var_os="debian" -var_version="11" -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[0-9]+$' -NSAPP=$(echo ${APP,,} | tr -d ' ') -var_install="${NSAPP}-install" -PP=`echo "\e[1;35m"` -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}" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${PP} - __ ___ _ ____ ____ _____ _ ______ - \ \ v3 / / | | |/ __ \ / __ \ / ____| | | ____| - \ \ /\ / /| |__| | | | | | | | | __| | | |__ - \ \/ \/ / | __ | | | | | | | | |_ | | | __| - \ /\ / | | | | |__| | |__| | |__| | |____| |____ - \/ \/ |_| |_|\____/ \____/ \_____|______|______| -${CL}" -} - -header_info - -function PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${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}Using ${BGN}$var_cpu${CL}${DGN}vCPU${CL}" - CORE_COUNT="$var_cpu" - echo -e "${DGN}Using ${BGN}$var_ram${CL}${DGN}MiB 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: $var_disk " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: $var_cpu " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: $var_ram " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -if [ "$CT_TYPE" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -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 - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/$var_install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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..5fa40ba2 --- /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/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 Successfully" +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.sh b/ct/wikijs.sh new file mode 100644 index 00000000..dedff2d6 --- /dev/null +++ b/ct/wikijs.sh @@ -0,0 +1,94 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="3" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 "Updated Successfully" +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-v2.sh b/ct/wireguard-v2.sh deleted file mode 100644 index 7137c4d3..00000000 --- a/ct/wireguard-v2.sh +++ /dev/null @@ -1,253 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will create a New WireGuard LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - __ ___ _____ _ - \ \ / (_) / ____| | | - \ \ /\ / / _ _ __ ___| | __ _ _ __ _ _ __ __| | - \ \/ \/ / | | __/ _ \ | |_ | | | |/ _ | __/ _ | - \ /\ / | | | | __/ |__| | |_| | (_| | | | (_| | - \/ \/ |_|_| \___|\_____|\__,_|\__,_|_| \__,_| - ${YW}With WGDashboard -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${YW} Privileged ${CL}\n" - printf " ${YW} 2)${GN} Unprivileged ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=2 -export PCT_OPTIONS=" - -features $FEATURES - -hostname wireguard - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 1 - -memory 512 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/wireguard-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created WireGuard LXC to${CL} ${BL}$CTID${CL}. - -${BL}WGDashboard${CL} should be reachable by going to the following URL. - ${BL}http://${IP}:10086${CL} \n" diff --git a/ct/wireguard-v3.sh b/ct/wireguard-v3.sh deleted file mode 100644 index 284f665c..00000000 --- a/ct/wireguard-v3.sh +++ /dev/null @@ -1,357 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Wireguard" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - __ ___ _____ _ - \ \ / (_) / ____| | | - \ \ /\ / / _ _ __ ___| | __ _ _ __ _ _ __ __| | - \ \/ \/ / | | __/ _ \ | |_ | | | |/ _ | __/ _ | - \ /\ / | | | | __/ |__| | |_| | (_| | | | (_| | - \/ \/ v3|_|_| \___|\_____|\__,_|\__,_|_| \__,_| - ${YW}With WGDashboard -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}" - CT_TYPE="1" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}2${CL}${DGN}GB${CL}" - DISK_SIZE="2" - echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}" - CORE_COUNT="1" - echo -e "${DGN}Using ${BGN}512${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="512" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 2 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="2"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 512 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="512"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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/setup/wireguard-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/Proxmox" - -msg_ok "Completed Successfully!\n" -echo -e "WGDashboard should be reachable by going to the following URL. - ${BL}http://${IP}:10086${CL} \n" diff --git a/ct/wireguard.sh b/ct/wireguard.sh new file mode 100644 index 00000000..a183c6bb --- /dev/null +++ b/ct/wireguard.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="4" +var_cpu="1" +var_ram="512" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +if [[ ! -d /etc/wireguard ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_error "Update WireGuard via apt" +exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "WGDashboard should be reachable by going to the following URL. + ${BL}http://${IP}:10086${CL} admin|admin \n" diff --git a/ct/yunohost.sh b/ct/yunohost.sh new file mode 100644 index 00000000..613de2f5 --- /dev/null +++ b/ct/yunohost.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="" + APT_CACHER="" + APT_CACHER_IP="" + 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/zabbix.sh b/ct/zabbix.sh new file mode 100644 index 00000000..3eb578d0 --- /dev/null +++ b/ct/zabbix.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Zabbix" +var_disk="6" +var_cpu="2" +var_ram="4096" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -f /etc/zabbix/zabbix_server.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" +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}/zabbix${CL} \n" diff --git a/ct/zigbee2mqtt-v1.sh b/ct/zigbee2mqtt-v1.sh deleted file mode 100644 index 4e7d8c65..00000000 --- a/ct/zigbee2mqtt-v1.sh +++ /dev/null @@ -1,173 +0,0 @@ -#!/usr/bin/env bash - -while true; do - read -p "This will create a New Zigbee2MQTT LXC Container. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if [ ! -z ${MOUNT+x} ]; then - pct unmount $CTID - fi - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} -function load_module() { - if ! $(lsmod | grep -Fq $1); then - modprobe $1 &>/dev/null || \ - die "Failed to load '$1' module." - fi - MODULES_PATH=/etc/modules - if ! $(grep -Fxq "$1" $MODULES_PATH); then - echo "$1" >> $MODULES_PATH || \ - die "Failed to add '$1' module to load at boot." - fi -} -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/zigbee2mqtt_setup.sh - -load_module overlay - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content rootdir | awk 'NR>1') -if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then - warn "'Container' needs to be selected for at least one storage location." - die "Unable to detect valid storage location." -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 container?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit - done -fi -info "Using '$STORAGE' for storage location." - -CTID=$(pvesh get /cluster/nextid) -info "Container ID is $CTID." - -echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m" -pveam update >/dev/null -echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m" -OSTYPE=debian -OSVERSION=${OSTYPE}-11 -mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V) -TEMPLATE="${TEMPLATES[-1]}" -pveam download local $TEMPLATE >/dev/null || - die "A problem occured while downloading the LXC Template." - -STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') -case $STORAGE_TYPE in - dir|nfs) - DISK_EXT=".raw" - DISK_REF="$CTID/" - ;; - zfspool) - DISK_PREFIX="subvol" - DISK_FORMAT="subvol" - ;; -esac -DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-} -ROOTFS=${STORAGE}:${DISK_REF-}${DISK} - -echo -e "${CHECKMARK} \e[1;92m Creating LXC Container... \e[0m" -DISK_SIZE=4G -pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -else - mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null -fi -ARCH=$(dpkg --print-architecture) -HOSTNAME=zigbee2mqtt -TEMPLATE_STRING="local:vztmpl/${TEMPLATE}" -pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \ - -hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 2 -memory 1024 \ - -ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null - -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $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 - -MOUNT=$(pct mount $CTID | cut -d"'" -f 2) -ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime -pct unmount $CTID && unset MOUNT - -echo -e "${CHECKMARK} \e[1;92m Starting LXC Container... \e[0m" -pct start $CTID -pct push $CTID zigbee2mqtt_setup.sh /zigbee2mqtt_setup.sh -perms 755 -pct exec $CTID /zigbee2mqtt_setup.sh - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') -info "Successfully created zigbee2mqtt LXC Container to $CTID at IP Address ${IP}" -echo -echo -e "\e[1;31m Updating the configuration.yaml is required and found at /opt/zigbee2mqtt/data/ \e[0m" -echo -echo diff --git a/ct/zigbee2mqtt-v2.sh b/ct/zigbee2mqtt-v2.sh deleted file mode 100644 index f4a0c0fd..00000000 --- a/ct/zigbee2mqtt-v2.sh +++ /dev/null @@ -1,263 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will create a New Zigbee2MQTT LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${YW} - _______ _ ___ __ __ ____ _______ _______ - |___ (_) | | |__ \| \/ |/ __ \__ __|__ __| - / / _ __ _| |__ ___ ___ ) | \ / | | | | | | | | - / / | |/ _ | _ \ / _ \/ _ \ / /| |\/| | | | | | | | | - / /__| | (_| | |_) | __/ __// /_| | | | |__| | | | | | - /_____|_|\__, |____/ \___|\___|____|_| |_|\___\_\ |_| |_| - __/ | - |___/ - -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${GN} Privileged ${CL}\n" - printf " ${YW} 2)${RD} Unprivileged (no device passthrough) ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=4 -export PCT_OPTIONS=" - -features $FEATURES - -hostname zigbee2mqtt - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 2 - -memory 1024 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi - -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $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 -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/zigbee2mqtt-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created Zigbee2MQTT LXC to${CL} ${BL}$CTID${CL}. \n" diff --git a/ct/zigbee2mqtt-v3.sh b/ct/zigbee2mqtt-v3.sh deleted file mode 100644 index 46a61c82..00000000 --- a/ct/zigbee2mqtt-v3.sh +++ /dev/null @@ -1,369 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Zigbee2MQTT" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${YW} - _______ _ ___ __ __ ____ _______ _______ - |___ (_) | | |__ \| \/ |/ __ \__ __|__ __| - / / _ __ _| |__ ___ ___ ) | \ / | | | | | | | | - / / | |/ _ | _ \ / _ \/ _ \ / /| |\/| | | | | | | | | - / /__| | (_| | |_) | __/ __// /_| | | | |__| | | | | | - /_____|_|\__, |____/ \___|\___|____|_| |_|\___\_\ |_| |_| - v3 __/ | - |___/ -${CL}" -} - -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Privileged${CL}" - CT_TYPE="0" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}4${CL}${DGN}GB${CL}" - DISK_SIZE="4" - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}1024${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="1024" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type ${CROSS}${YW}Unprivileged, or Press [ENTER] for Default: Privileged" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Privileged" CT_TYPE="0"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 4 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="4"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 1024 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="1024"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -PVE_CHECK -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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 <<EOF >> $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/setup/zigbee2mqtt-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/Proxmox" - -msg_ok "Completed Successfully!\n" diff --git a/ct/zigbee2mqtt.sh b/ct/zigbee2mqtt.sh new file mode 100644 index 00000000..e3ae7ee8 --- /dev/null +++ b/ct/zigbee2mqtt.sh @@ -0,0 +1,154 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 + if [[ "$(node -v | cut -d 'v' -f 2)" == "18."* ]]; then + if ! command -v npm >/dev/null 2>&1; then + echo "Installing NPM..." + apt-get install -y npm >/dev/null 2>&1 + echo "Installed NPM..." + fi + 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 "Checking if any changes were made to package-lock.json..." + git checkout package-lock.json || { + echo "Failed to check package-lock.json." + 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 "Building..." + npm run build || { + echo "Failed to build new version." + 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/zoraxy.sh b/ct/zoraxy.sh new file mode 100644 index 00000000..84a40785 --- /dev/null +++ b/ct/zoraxy.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="Zoraxy" +var_disk="6" +var_cpu="4" +var_ram="2048" +var_os="debian" +var_version="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { +header_info +if [[ ! -d /opt/zoraxy/src ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +msg_info "Updating $APP" +systemctl stop zoraxy +cd /opt/zoraxy/src +systemctl stop zoraxy +if git pull | grep -q 'Already up to date.'; then + msg_ok "Already up to date. No update required." +else + go mod tidy + go build + msg_ok "Updated $APP" +fi +systemctl start zoraxy +exit +} + +start +build_container +description + +msg_info "Setting Container to Normal Resources" +pct set $CTID -cores 2 +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/zwave-js-ui.sh b/ct/zwave-js-ui.sh new file mode 100644 index 00000000..3be12b44 --- /dev/null +++ b/ct/zwave-js-ui.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2024 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="12" +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="" + APT_CACHER="" + APT_CACHER_IP="" + 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 + 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 + 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/ct/zwavejs2mqtt-v1.sh b/ct/zwavejs2mqtt-v1.sh deleted file mode 100644 index fb21a900..00000000 --- a/ct/zwavejs2mqtt-v1.sh +++ /dev/null @@ -1,191 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` - -while true; do - read -p "This will create a New Zwavejs2MQTT LXC Container. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - ______ _ ___ __ __ ____ _______ _______ - |___ / (_) |__ \| \/ |/ __ \__ __|__ __| - / /_ ____ ___ _____ _ ___ ) | \ / | | | | | | | | - / /\ \ /\ / / _ \ \ / / _ \ / __| / /| |\/| | | | | | | | | - / /__\ V V / (_| |\ V / __/ \__ \/ /_| | | | |__| | | | | | - /_____|\_/\_/ \__,_| \_/ \___| |___/____|_| |_|\___\_\ |_| |_| - _/ | - |__/ -${CL}" -} - -header_info - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if [ ! -z ${MOUNT+x} ]; then - pct unmount $CTID - fi - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} -function load_module() { - if ! $(lsmod | grep -Fq $1); then - modprobe $1 &>/dev/null || \ - die "Failed to load '$1' module." - fi - MODULES_PATH=/etc/modules - if ! $(grep -Fxq "$1" $MODULES_PATH); then - echo "$1" >> $MODULES_PATH || \ - die "Failed to add '$1' module to load at boot." - fi -} -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/zwavejs2mqtt_setup.sh - -load_module overlay - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content rootdir | awk 'NR>1') -if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then - warn "'Container' needs to be selected for at least one storage location." - die "Unable to detect valid storage location." -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 container?\n\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit - done -fi -info "Using '$STORAGE' for Storage Location." - -CTID=$(pvesh get /cluster/nextid) -info "Container ID is $CTID." - -echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m" -pveam update >/dev/null -echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m" -OSTYPE=debian -OSVERSION=${OSTYPE}-11 -mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V) -TEMPLATE="${TEMPLATES[-1]}" -pveam download local $TEMPLATE >/dev/null || - die "A problem occured while downloading the LXC template." - -STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') -case $STORAGE_TYPE in - dir|nfs) - DISK_EXT=".raw" - DISK_REF="$CTID/" - ;; - zfspool) - DISK_PREFIX="subvol" - DISK_FORMAT="subvol" - ;; -esac -DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-} -ROOTFS=${STORAGE}:${DISK_REF-}${DISK} - -echo -e "${CHECKMARK} \e[1;92m Creating LXC Container... \e[0m" -DISK_SIZE=4G -pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some containers may not work properly due to ZFS not supporting 'fallocate'." -else - mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null -fi -ARCH=$(dpkg --print-architecture) -HOSTNAME=zwavejs2mqtt -TEMPLATE_STRING="local:vztmpl/${TEMPLATE}" -pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \ - -hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 2 -memory 1024\ - -ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null - -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $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 -lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file -EOF - -MOUNT=$(pct mount $CTID | cut -d"'" -f 2) -ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime -pct unmount $CTID && unset MOUNT - -echo -e "${CHECKMARK} \e[1;92m Starting LXC Container... \e[0m" -pct start $CTID -pct push $CTID zwavejs2mqtt_setup.sh /zwavejs2mqtt_setup.sh -perms 755 -pct exec $CTID /zwavejs2mqtt_setup.sh - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') -info "Successfully created a Zwavejs2MQTT LXC Container to $CTID at IP Address ${IP}:8091" diff --git a/ct/zwavejs2mqtt-v2.sh b/ct/zwavejs2mqtt-v2.sh deleted file mode 100644 index 72669df9..00000000 --- a/ct/zwavejs2mqtt-v2.sh +++ /dev/null @@ -1,266 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -APP="Zwavejs2MQTT" -HN=$(echo ${APP,,} | tr -d ' ') -while true; do - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - ______ _ ___ __ __ ____ _______ _______ - |___ / (_) |__ \| \/ |/ __ \__ __|__ __| - / /_ ____ ___ _____ _ ___ ) | \ / | | | | | | | | - / /\ \ /\ / / _ \ \ / / _ \ / __| / /| |\/| | | | | | | | | - / /__\ V V / (_| |\ V / __/ \__ \/ /_| | | | |__| | | | | | - /_____|\_/\_/ \__,_| \_/ \___| |___/____|_| |_|\___\_\ |_| |_| - _/ | - |__/ -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${GN} Privileged ${CL}\n" - printf " ${YW} 2)${RD} Unprivileged (no device passthrough) ${CL}\n" - - printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Privileged Install"; - IM=0 - break; - ;; - 2) clear; - header_info; - option_picked "Using Unprivileged Install"; - IM=1 - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Method from the menu"; - show_menu; - ;; - esac - done -show_menu2(){ - printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n" - printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n" - - printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message2=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" -} -show_menu2 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic Login"; - PW=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Password (changeme)"; - PW="-password changeme" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Password Type from the menu"; - show_menu2; - ;; - esac - done -show_menu3(){ - printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n" - printf " ${YW} 2)${GN} Manual DHCP ${CL}\n" - - printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message3=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" - printf " ${YW}${message2}${CL}\n" - printf " ${YW}${message3}${CL}\n" -} -show_menu3 -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Automatic DHCP"; - DHCP=" " - break; - ;; - 2) clear; - header_info; - option_picked "Using Manual DHCP"; - DHCP="1" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a DHCP Type from the menu"; - show_menu3; - ;; - esac - done - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - [ ! -z ${CTID-} ] && cleanup_ctid - exit $EXIT -} -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" -} -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup_ctid() { - if $(pct status $CTID &>/dev/null); then - if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then - pct stop $CTID - fi - pct destroy $CTID - elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then - pvesm free $ROOTFS - fi -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - if [ "$IM" == "1" ]; then - FEATURES="nesting=1,keyctl=1" - else - FEATURES="nesting=1" - fi - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -export CTID=$(pvesh get /cluster/nextid) -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=4 -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=vmbr0,ip=dhcp - -onboot 1 - -cores 2 - -memory 1024 - -unprivileged ${IM} - ${PW} -" -bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit - -STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}') -if [ "$STORAGE_TYPE" == "zfspool" ]; then - warn "Some addons may not work due to ZFS not supporting 'fallocate'." -fi -LXC_CONFIG=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $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 -lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file -EOF -if [ "$DHCP" == "1" ]; then -MAC=$(pct config $CTID \ -| grep -i hwaddr \ -| awk '{print substr($2, 31, length($3) 17 ) }') \ - -echo -e "MAC Address ${BL}$MAC${CL}" - -dhcp_reservation(){ - printf "Please set DHCP reservation and press Enter." - read -} -dhcp_reservation -fi - -echo -en "${GN} Starting LXC Container... " -pct start $CTID -echo -e "${CM}${CL} \r" - -alias lxc-cmd="lxc-attach -n $CTID --" - -lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}. -${BL}${APP}${CL} should be reachable by going to the following URL. - ${BL}http://${IP}:8091${CL} \n" diff --git a/ct/zwavejs2mqtt-v3.sh b/ct/zwavejs2mqtt-v3.sh deleted file mode 100644 index 88b9c87c..00000000 --- a/ct/zwavejs2mqtt-v3.sh +++ /dev/null @@ -1,371 +0,0 @@ -#!/usr/bin/env bash -echo -e "Loading..." -NEXTID=$(pvesh get /cluster/nextid) -INTEGER='^[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}" -APP="Zwavejs2MQTT" -NSAPP=$(echo ${APP,,} | tr -d ' ') -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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 -} - -while true; do - clear - read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${BL} - ______ _ ___ __ __ ____ _______ _______ - |___ / (_) |__ \| \/ |/ __ \__ __|__ __| - / /_ ____ ___ _____ _ ___ ) | \ / | | | | | | | | - / /\ \ /\ / / _ \ \ / / _ \ / __| / /| |\/| | | | | | | | | - / /__\ V V / (_| |\ V / __/ \__ \/ /_| | | | |__| | | | | | - /_____|\_/\_/ \__,_| \_/ \___| |___/____|_| |_|\___\_\ |_| v3 |_| - _/ | - |__/ -${CL}" -} -header_info - -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 PVE_CHECK() { - PVE=$(pveversion | grep "pve-manager/7" | wc -l) - - if [[ $PVE != 1 ]]; then - echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}" - echo -e "Exiting..." - sleep 2 - exit - fi -} - -function default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}Privileged${CL}" - CT_TYPE="0" - echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}" - PW=" " - echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}" - CT_ID=$NEXTID - echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}" - HN=$NSAPP - echo -e "${DGN}Using Disk Size ${BGN}4${CL}${DGN}GB${CL}" - DISK_SIZE="4" - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}1024${CL}${DGN}MiB RAM${CL}" - RAM_SIZE="1024" - 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}NONE${CL}" - GATE="" - echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}" - VLAN="" -} - -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type ${CROSS}${YW}Unprivileged, or Press [ENTER] for Default: Privileged" - read CT_TYPE1 - if [ -z $CT_TYPE1 ]; then CT_TYPE1="Privileged" CT_TYPE="0"; - echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}" - else - CT_TYPE1="Privileged" - CT_TYPE="0" - echo -en "${DGN}Set CT Type ${BL}Privileged${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login " - read PW1 - if [ -z $PW1 ]; then PW1="Automatic Login" PW=" "; - echo -en "${DGN}Set CT ${BL}$PW1${CL}" - else - PW="-password $PW1" - echo -en "${DGN}Set CT Password ${BL}$PW1${CL}" - fi; -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read CT_ID - if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi; - echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP " - read CT_NAME - if [ -z $CT_NAME ]; then - HN=$NSAPP - else - HN=$(echo ${CT_NAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$HN${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 4 " - read DISK_SIZE - if [ -z $DISK_SIZE ]; then DISK_SIZE="4"; fi; - if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; - echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 1024 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="1024"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP " - read NET - if [ -z $NET ]; then NET="dhcp"; fi; - echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE " - read GATE1 - if [ -z $GATE1 ]; then GATE1="NONE" GATE=""; - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - else - GATE=",gw=$GATE1" - echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}" - echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}" - echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}" - echo -e "${DGN}Using CT Name ${BGN}$HN${CL}" - echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}" - echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -PVE_CHECK -start_script - -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 CTID=$CT_ID -export PCT_OSTYPE=debian -export PCT_OSVERSION=11 -export PCT_DISK_SIZE=$DISK_SIZE -export PCT_OPTIONS=" - -features $FEATURES - -hostname $HN - -net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN - -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 <<EOF >> $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 -lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 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/setup/zwavejs2mqtt-install.sh)" || exit - -IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}') - -pct set $CTID -description "# ${APP} LXC -### https://github.com/tteck/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/install/actualbudget-install.sh b/install/actualbudget-install.sh new file mode 100644 index 00000000..fbd07867 --- /dev/null +++ b/install/actualbudget-install.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +$STD apt-get install -y git +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +$STD npm install --global yarn +msg_ok "Installed Node.js" + +msg_info "Installing Actual Budget" +$STD git clone https://github.com/actualbudget/actual-server.git /opt/actualbudget +cd /opt/actualbudget +$STD yarn install +msg_ok "Installed Actual Budget" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/actualbudget.service +[Unit] +Description=Actual Budget Service +After=network.target + +[Service] +Type=exec +WorkingDirectory=/opt/actualbudget +ExecStart=/usr/bin/yarn start + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now actualbudget.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/adguard-install.sh b/install/adguard-install.sh new file mode 100644 index 00000000..ef3688cf --- /dev/null +++ b/install/adguard-install.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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" +$STD tar zxvf <(curl -fsSL https://static.adtidy.org/adguardhome/release/AdGuardHome_linux_amd64.tar.gz) -C /opt +msg_ok "Installed AdGuard Home" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/AdGuardHome.service +[Unit] +Description=AdGuard Home: Network-level blocker +ConditionFileIsExecutable=/opt/AdGuardHome/AdGuardHome +After=syslog.target network-online.target + +[Service] +StartLimitInterval=5 +StartLimitBurst=10 +ExecStart=/opt/AdGuardHome/AdGuardHome "-s" "run" +WorkingDirectory=/opt/AdGuardHome +StandardOutput=file:/var/log/AdGuardHome.out +StandardError=file:/var/log/AdGuardHome.err +Restart=always +RestartSec=10 +EnvironmentFile=-/etc/sysconfig/AdGuardHome + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now AdGuardHome.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/agentdvr-install.sh b/install/agentdvr-install.sh new file mode 100644 index 00000000..f0c431a0 --- /dev/null +++ b/install/agentdvr-install.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 apt-transport-https +$STD apt-get install -y alsa-utils +$STD apt-get install -y libxext-dev +$STD apt-get install -y fontconfig +$STD apt-get install -y libva-drm2 +msg_ok "Installed Dependencies" + +msg_info "Installing AgentDVR" +mkdir -p /opt/agentdvr/agent +RELEASE=$(curl -s "https://www.ispyconnect.com/api/Agent/DownloadLocation4?platform=Linux64&fromVersion=0" | grep -o 'https://.*\.zip') +cd /opt/agentdvr/agent +wget -q $RELEASE +$STD unzip Agent_Linux64*.zip +rm -rf Agent_Linux64*.zip +chmod +x ./Agent +msg_ok "Installed AgentDVR" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/AgentDVR.service +[Unit] +Description=AgentDVR + +[Service] +WorkingDirectory=/opt/agentdvr/agent +ExecStart=/opt/agentdvr/agent/./Agent +Environment="MALLOC_TRIM_THRESHOLD_=100000" +SyslogIdentifier=AgentDVR +Restart=always +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now AgentDVR.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/alpine-docker-install.sh b/install/alpine-docker-install.sh new file mode 100644 index 00000000..58431201 --- /dev/null +++ b/install/alpine-docker-install.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 tzdata +$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") +PORTAINER_AGENT_LATEST_VERSION=$(get_latest_release "portainer/agent") + +read -r -p "Would you like to add Portainer? <y/N> " 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 9443:9443 \ + --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" +else + read -r -p "Would you like to add the Portainer Agent? <y/N> " prompt + if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + msg_info "Installing Portainer agent $PORTAINER_AGENT_LATEST_VERSION" + $STD docker run -d \ + -p 9001:9001 \ + --name portainer_agent \ + --restart=always \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v /var/lib/docker/volumes:/var/lib/docker/volumes \ + portainer/agent + msg_ok "Installed Portainer Agent $PORTAINER_AGENT_LATEST_VERSION" + fi +fi +read -r -p "Would you like to add Docker Compose? <y/N> " 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 +customize diff --git a/install/alpine-grafana-install.sh b/install/alpine-grafana-install.sh new file mode 100644 index 00000000..7d7e95ad --- /dev/null +++ b/install/alpine-grafana-install.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +customize \ No newline at end of file diff --git a/install/alpine-install.sh b/install/alpine-install.sh new file mode 100644 index 00000000..b904c7a4 --- /dev/null +++ b/install/alpine-install.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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" + +motd_ssh +customize diff --git a/install/alpine-nextcloud-install.sh b/install/alpine-nextcloud-install.sh new file mode 100644 index 00000000..9b320546 --- /dev/null +++ b/install/alpine-nextcloud-install.sh @@ -0,0 +1,191 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +$STD apk add nginx +msg_ok "Installed Dependencies" + +msg_info "Installing PHP/Redis" +$STD apk add php82-opcache +$STD apk add php82-redis +$STD apk add php82-apcu +$STD apk add php82-fpm +$STD apk add php82-sysvsem +$STD apk add php82-ftp +$STD apk add php82-pecl-smbclient +$STD apk add php82-pecl-imagick +$STD apk add php82-pecl-vips +$STD apk add php82-exif +$STD apk add php82-sodium +$STD apk add php82-bz2 +$STD apk add redis +msg_ok "Installed PHP/Redis" + +msg_info "Installing MySQL Database" +DB_NAME=nextcloud +DB_USER=nextcloud +DB_PASS="$(openssl rand -base64 18 | cut -c1-13)" +ADMIN_PASS="$(openssl rand -base64 18 | cut -c1-13)" +echo "" >>~/nextcloud.creds +echo -e "MySQL Admin Password: \e[32m$ADMIN_PASS\e[0m" >>~/nextcloud.creds +echo -e "Nextcloud Database Username: \e[32m$DB_USER\e[0m" >>~/nextcloud.creds +echo -e "Nextcloud Database Password: \e[32m$DB_PASS\e[0m" >>~/nextcloud.creds +echo -e "Nextcloud Database Name: \e[32m$DB_NAME\e[0m" >>~/nextcloud.creds +$STD apk add nextcloud-mysql mariadb mariadb-client +$STD mysql_install_db --user=mysql --datadir=/var/lib/mysql +$STD service mariadb start +$STD rc-update add mariadb +mysql -uroot -p"$ADMIN_PASS" -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '$ADMIN_PASS' WITH GRANT OPTION; DELETE FROM mysql.user WHERE User=''; DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1'); DROP DATABASE test; DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%'; CREATE DATABASE $DB_NAME; GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS'; GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost.localdomain' IDENTIFIED BY '$DB_PASS'; FLUSH PRIVILEGES;" +$STD apk del mariadb-client +msg_ok "Installed MySQL Database" + +msg_info "Installing Nextcloud" +ADMIN_USER=ncAdmin +echo "" >>~/nextcloud.creds +echo -e "Nextcloud Admin Username: \e[32m$ADMIN_USER\e[0m" >>~/nextcloud.creds +echo -e "Nextcloud Admin Password: \e[32m$ADMIN_PASS\e[0m (Initially enter twice)" >>~/nextcloud.creds +$STD apk add nextcloud-initscript +$STD openssl req -x509 -nodes -days 365 -newkey rsa:4096 -keyout /etc/ssl/private/nextcloud-selfsigned.key -out /etc/ssl/certs/nextcloud-selfsigned.crt -subj "/C=US/O=Nextcloud/OU=Domain Control Validated/CN=nextcloud.local" +cat <<'EOF' >/usr/share/webapps/nextcloud/config/config.php +<?php +$CONFIG = array ( + 'datadirectory' => '/var/lib/nextcloud/data', + 'logfile' => '/var/log/nextcloud/nextcloud.log', + 'logdateformat' => 'F d, Y H:i:s', + 'log_rotate_size' => 104857600, + 'apps_paths' => array ( + 0 => array ( + 'path' => '/usr/share/webapps/nextcloud/apps', + 'url' => '/apps', + 'writable' => false, + ), + 1 => array ( + 'path' => '/var/lib/nextcloud/apps', + 'url' => '/apps-appstore', + 'writable' => true, + ), + ), + 'updatechecker' => false, + 'check_for_working_htaccess' => false, + 'memcache.local' => '\\OC\\Memcache\\Redis', + 'memcache.locking' => '\\OC\\Memcache\\Redis', + 'redis' => array( + 'host' => 'localhost', + 'port' => 6379, + 'dbindex' => 0, + 'timeout' => 1.5, + ), + 'installed' => false, +); +EOF +rm -rf /etc/nginx/http.d/default.conf +cat <<'EOF' >/etc/nginx/http.d/nextcloud.conf +server { + listen [::]:80; + listen 80; + return 301 https://$host$request_uri; + server_name localhost; +} +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + server_name localhost; + root /usr/share/webapps/nextcloud; + index index.php index.html index.htm; + disable_symlinks off; + ssl_certificate /etc/ssl/certs/nextcloud-selfsigned.crt; + ssl_certificate_key /etc/ssl/private/nextcloud-selfsigned.key; + ssl_session_timeout 5m; + ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA; + ssl_prefer_server_ciphers on; + location / { + try_files $uri $uri/ /index.html; + } + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + if (!-f $document_root$fastcgi_script_name) { + return 404; + } + fastcgi_pass unix:/run/nextcloud/fastcgi.sock; # From the nextcloud-initscript package + fastcgi_index index.php; + include fastcgi.conf; + } + location ^~ /.well-known/carddav { return 301 /remote.php/dav/; } + location ^~ /.well-known/caldav { return 301 /remote.php/dav/; } + location ^~ /.well-known/webfinger { return 301 /index.php/.well-known/webfinger; } + location ^~ /.well-known/nodeinfo { return 301 /index.php/.well-known/nodeinfo; } +} +EOF +sed -i -e 's|memory_limit = 128M|memory_limit = 512M|; $aapc.enable_cli=1' /etc/php82/php.ini +sed -i -E '/^php_admin_(flag|value)\[opcache/s/^/;/' /etc/php82/php-fpm.d/nextcloud.conf +msg_ok "Installed Nextcloud" + +msg_info "Adding Additional Nextcloud Packages" +$STD apk add nextcloud-default-apps +$STD apk add nextcloud-activity +$STD apk add nextcloud-admin_audit +$STD apk add nextcloud-comments +$STD apk add nextcloud-dashboard +$STD apk add nextcloud-doc +$STD apk add nextcloud-encryption +$STD apk add nextcloud-federation +$STD apk add nextcloud-files_external +$STD apk add nextcloud-files_sharing +$STD apk add nextcloud-files_trashbin +$STD apk add nextcloud-files_versions +$STD apk add nextcloud-notifications +$STD apk add nextcloud-sharebymail +$STD apk add nextcloud-suspicious_login +$STD apk add nextcloud-support +$STD apk add nextcloud-systemtags +$STD apk add nextcloud-user_status +$STD apk add nextcloud-weather_status +msg_ok "Added Additional Nextcloud Packages" + +msg_info "Starting Services" +$STD rc-service redis start +$STD rc-update add redis default +$STD rc-service php-fpm82 start +chown -R nextcloud:www-data /var/log/nextcloud/ +$STD rc-service php-fpm82 restart +$STD rc-service nginx start +$STD rc-service nextcloud start +$STD rc-update add nginx default +$STD rc-update add nextcloud default +msg_ok "Started Services" + +msg_info "Start Nextcloud Setup-Wizard" +echo -e "export VISUAL=nano\nexport EDITOR=nano" >>/etc/profile +cd /usr/share/webapps/nextcloud +$STD su nextcloud -s /bin/sh -c "php82 occ maintenance:install \ +--database='mysql' --database-name $DB_NAME \ +--database-user '$DB_USER' --database-pass '$DB_PASS' \ +--admin-user '$ADMIN_USER' --admin-pass '$ADMIN_PASS' \ +--data-dir '/var/lib/nextcloud/data'" +$STD su nextcloud -s /bin/sh -c 'php82 occ background:cron' +rm -rf /usr/share/webapps/nextcloud/apps/serverinfo +IP4=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) +sed -i "/0 => \'localhost\',/a \ \1 => '$IP4'," /usr/share/webapps/nextcloud/config/config.php +su nextcloud -s /bin/sh -c 'php82 -f /usr/share/webapps/nextcloud/cron.php' +msg_ok "Finished Nextcloud Setup-Wizard" + +motd_ssh +customize diff --git a/install/alpine-vaultwarden-install.sh b/install/alpine-vaultwarden-install.sh new file mode 100644 index 00000000..94956b70 --- /dev/null +++ b/install/alpine-vaultwarden-install.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +$STD apk add argon2 +msg_ok "Installed Dependencies" + +msg_info "Installing Alpine-Vaultwarden" +$STD apk add vaultwarden +sed -i -e 's/# export ADMIN_TOKEN=.*/export ADMIN_TOKEN='\'''\''/' -e '/^# export ROCKET_ADDRESS=0\.0\.0\.0/s/^# //' -e 's|export WEB_VAULT_ENABLED=.*|export WEB_VAULT_ENABLED=true|' /etc/conf.d/vaultwarden +msg_ok "Installed Alpine-Vaultwarden" + +msg_info "Installing Web-Vault" +$STD apk add vaultwarden-web-vault +msg_ok "Installed Web-Vault" + +msg_info "Starting Alpine-Vaultwarden" +$STD rc-service vaultwarden start +$STD rc-update add vaultwarden default +msg_ok "Started Alpine-Vaultwarden" + +motd_ssh +customize diff --git a/install/alpine-zigbee2mqtt-install.sh b/install/alpine-zigbee2mqtt-install.sh new file mode 100644 index 00000000..a98f1da5 --- /dev/null +++ b/install/alpine-zigbee2mqtt-install.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +mkdir -p /root/.z2m +ln -s /etc/zigbee2mqtt/ /root/.z2m +chown -R root:root /etc/zigbee2mqtt /root/.z2m +sed -i -e 's/#datadir="\/var\/lib\/zigbee2mqtt"/datadir="\/etc\/zigbee2mqtt"/' -e 's/#command_user="zigbee2mqtt"/command_user="root"/' /etc/conf.d/zigbee2mqtt +$STD rc-update add zigbee2mqtt +$STD rc-service zigbee2mqtt restart +msg_ok "Installed Alpine-Zigbee2MQTT" + +motd_ssh +customize diff --git a/install/apache-cassandra-install.sh b/install/apache-cassandra-install.sh new file mode 100644 index 00000000..35c49486 --- /dev/null +++ b/install/apache-cassandra-install.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +msg_ok "Installed Dependencies" + +msg_info "Installing Eclipse Temurin (Patience)" +wget -qO- https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor >/etc/apt/trusted.gpg.d/adoptium.gpg +echo 'deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/adoptium.gpg] https://packages.adoptium.net/artifactory/deb bookworm main' >/etc/apt/sources.list.d/adoptium.list +$STD apt-get update +$STD apt-get install -y temurin-11-jdk +msg_ok "Installed Eclipse Temurin" + +msg_info "Installing Apache Cassandra" +wget -qO- https://downloads.apache.org/cassandra/KEYS | gpg --dearmor >/etc/apt/trusted.gpg.d/cassandra.gpg +echo "deb https://debian.cassandra.apache.org 41x main" >/etc/apt/sources.list.d/cassandra.sources.list +$STD apt-get update +$STD apt-get install -y cassandra cassandra-tools +sed -i -e 's/^rpc_address: localhost/#rpc_address: localhost/g' -e 's/^# rpc_interface: eth1/rpc_interface: eth0/g' /etc/cassandra/cassandra.yaml +msg_ok "Installed Apache Cassandra" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/apache-couchdb-install.sh b/install/apache-couchdb-install.sh new file mode 100644 index 00000000..94902056 --- /dev/null +++ b/install/apache-couchdb-install.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gnupg +msg_ok "Installed Dependencies" + +msg_info "Installing Apache CouchDB" +ERLANG_COOKIE=$(openssl rand -base64 32) +ADMIN_PASS="$(openssl rand -base64 18 | cut -c1-13)" +debconf-set-selections <<< "couchdb couchdb/cookie string $ERLANG_COOKIE" +debconf-set-selections <<< "couchdb couchdb/mode select standalone" +debconf-set-selections <<< "couchdb couchdb/bindaddress string 0.0.0.0" +debconf-set-selections <<< "couchdb couchdb/adminpass password $ADMIN_PASS" +debconf-set-selections <<< "couchdb couchdb/adminpass_again password $ADMIN_PASS" +curl -fsSL https://couchdb.apache.org/repo/keys.asc | gpg --dearmor -o /usr/share/keyrings/couchdb-archive-keyring.gpg +VERSION_CODENAME="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)" +echo "deb [signed-by=/usr/share/keyrings/couchdb-archive-keyring.gpg] https://apache.jfrog.io/artifactory/couchdb-deb/ ${VERSION_CODENAME} main" >/etc/apt/sources.list.d/couchdb.sources.list +$STD apt-get update +$STD apt-get install -y couchdb +echo -e "CouchDB Erlang Cookie: \e[32m$ERLANG_COOKIE\e[0m" >>~/CouchDB.creds +echo -e "CouchDB Admin Password: \e[32m$ADMIN_PASS\e[0m" >>~/CouchDB.creds +msg_ok "Installed Apache CouchDB." + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/apt-cacher-ng-install.sh b/install/apt-cacher-ng-install.sh new file mode 100644 index 00000000..b8e29316 --- /dev/null +++ b/install/apt-cacher-ng-install.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 Apt-Cacher NG" +DEBIAN_FRONTEND=noninteractive $STD apt-get -o Dpkg::Options::="--force-confold" install -y apt-cacher-ng +sed -i 's/# PassThroughPattern: .* # this would allow CONNECT to everything/PassThroughPattern: .*/' /etc/apt-cacher-ng/acng.conf +systemctl enable -q --now apt-cacher-ng +msg_ok "Installed Apt-Cacher NG" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/aria2-install.sh b/install/aria2-install.sh new file mode 100644 index 00000000..f246bc9d --- /dev/null +++ b/install/aria2-install.sh @@ -0,0 +1,98 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 Aria2" +$STD apt-get install -y aria2 +msg_ok "Installed Aria2" + +read -r -p "Would you like to add AriaNG? <y/N> " prompt +if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then + msg_info "Installing AriaNG" + $STD apt-get install -y nginx + systemctl disable -q --now nginx + wget -q "$(curl -s https://api.github.com/repos/mayswind/ariang/releases/latest | grep download | grep AllInOne.zip | cut -d\" -f4)" + $STD unzip AriaNg-*-AllInOne.zip -d /var/www + rm /etc/nginx/sites-enabled/* + cat <<EOF >/etc/nginx/conf.d/ariang.conf +server { + listen 6880 default_server; + listen [::]:6880 default_server; + + server_name _; + + root /var/www; + index index.html; + + location / { + try_files \$uri \$uri/ =404; + } +} +EOF + cp /lib/systemd/system/nginx.service /lib/systemd/system/ariang.service + msg_ok "Installed AriaNG" +fi + +msg_info "Creating Service" +mkdir /root/downloads +rpc_secret=$(openssl rand -base64 8) +echo "rpc-secret: $rpc_secret" >>~/rpc.secret +cat <<EOF >/root/aria2.daemon +dir=/root/downloads +file-allocation=falloc +max-connection-per-server=4 +max-concurrent-downloads=2 +max-overall-download-limit=0 +min-split-size=25M +rpc-allow-origin-all=true +rpc-secret=${rpc_secret} +input-file=/var/tmp/aria2c.session +save-session=/var/tmp/aria2c.session +EOF + +cat <<EOF >/etc/systemd/system/aria2.service +[Unit] +Description=Aria2c download manager +After=network.target + +[Service] +Type=simple +User=root +Group=root +ExecStartPre=/usr/bin/env touch /var/tmp/aria2c.session +ExecStart=/usr/bin/aria2c --console-log-level=warn --enable-rpc --rpc-listen-all --conf-path=/root/aria2.daemon +TimeoutStopSec=20 +Restart=on-failure + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now aria2.service +systemctl enable -q --now ariang +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +rm AriaNg-*-AllInOne.zip +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" \ No newline at end of file diff --git a/install/audiobookshelf-install.sh b/install/audiobookshelf-install.sh new file mode 100644 index 00000000..cd9346e3 --- /dev/null +++ b/install/audiobookshelf-install.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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" +curl -fsSL https://advplyr.github.io/audiobookshelf-ppa/KEY.gpg >/etc/apt/trusted.gpg.d/audiobookshelf-ppa.asc +echo "deb [signed-by=/etc/apt/trusted.gpg.d/audiobookshelf-ppa.asc] 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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/autobrr-install.sh b/install/autobrr-install.sh new file mode 100644 index 00000000..510d1c0a --- /dev/null +++ b/install/autobrr-install.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 <<EOF >>/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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/bazarr-install.sh b/install/bazarr-install.sh new file mode 100755 index 00000000..a4ee4cbb --- /dev/null +++ b/install/bazarr-install.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 "Updating Python3" +$STD apt-get install -y \ + python3 \ + python3-dev \ + python3-pip +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +msg_ok "Updated Python3" + +msg_info "Installing Bazarr" +mkdir -p /var/lib/bazarr/ +wget -q https://github.com/morpheus65535/bazarr/releases/latest/download/bazarr.zip +unzip -qq bazarr -d /opt/bazarr +chmod 775 /opt/bazarr /var/lib/bazarr/ +python3 -m pip install -q -r /opt/bazarr/requirements.txt +msg_ok "Installed Bazarr" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/bazarr.service +[Unit] +Description=Bazarr Daemon +After=syslog.target network.target + +[Service] +WorkingDirectory=/opt/bazarr/ +UMask=0002 +Restart=on-failure +RestartSec=5 +Type=simple +ExecStart=/usr/bin/python3 /opt/bazarr/bazarr.py +KillSignal=SIGINT +TimeoutStopSec=20 +SyslogIdentifier=bazarr + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now bazarr +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -rf bazarr.zip +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" \ No newline at end of file diff --git a/install/blocky-install.sh b/install/blocky-install.sh new file mode 100644 index 00000000..d3ba2b50 --- /dev/null +++ b/install/blocky-install.sh @@ -0,0 +1,290 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 Blocky" +if systemctl is-active systemd-resolved > /dev/null 2>&1; then + systemctl disable -q --now systemd-resolved +fi +mkdir /opt/blocky +RELEASE=$(curl -s https://api.github.com/repos/0xERR0R/blocky/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +wget -qO- https://github.com/0xERR0R/blocky/releases/download/v${RELEASE}/blocky_v${RELEASE}_Linux_x86_64.tar.gz | tar -xzf - -C /opt/blocky/ + +cat <<EOF >/opt/blocky/config.yml +upstream: + # these external DNS resolvers will be used. Blocky picks 2 random resolvers from the list for each query + # format for resolver: [net:]host:[port][/path]. net could be empty (default, shortcut for tcp+udp), tcp+udp, tcp, udp, tcp-tls or https (DoH). If port is empty, default port will be used (53 for udp and tcp, 853 for tcp-tls, 443 for https (Doh)) + # this configuration is mandatory, please define at least one external DNS resolver + default: + # example for tcp+udp IPv4 server (https://digitalcourage.de/) + #- 5.9.164.112 + # Cloudflare + - 1.1.1.1 + # example for DNS-over-TLS server (DoT) + #- tcp-tls:fdns1.dismail.de:853 + # example for DNS-over-HTTPS (DoH) + #- https://dns.digitale-gesellschaft.ch/dns-query + # optional: use client name (with wildcard support: * - sequence of any characters, [0-9] - range) + # or single ip address / client subnet as CIDR notation + #laptop*: + #- 123.123.123.123 + +# optional: timeout to query the upstream resolver. Default: 2s +#upstreamTimeout: 2s + +# optional: If true, blocky will fail to start unless at least one upstream server per group is reachable. Default: false +#startVerifyUpstream: true + +# optional: Determines how blocky will create outgoing connections. This impacts both upstreams, and lists. +# accepted: dual, v4, v6 +# default: dual +#connectIPVersion: dual + +# optional: custom IP address(es) for domain name (with all sub-domains). Multiple addresses must be separated by a comma +# example: query "printer.lan" or "my.printer.lan" will return 192.168.178.3 +#customDNS: + #customTTL: 1h + # optional: if true (default), return empty result for unmapped query types (for example TXT, MX or AAAA if only IPv4 address is defined). + # if false, queries with unmapped types will be forwarded to the upstream resolver + #filterUnmappedTypes: true + # optional: replace domain in the query with other domain before resolver lookup in the mapping + #rewrite: + #example.com: printer.lan + #mapping: + #printer.lan: 192.168.178.3,2001:0db8:85a3:08d3:1319:8a2e:0370:7344 + +# optional: definition, which DNS resolver(s) should be used for queries to the domain (with all sub-domains). Multiple resolvers must be separated by a comma +# Example: Query client.fritz.box will ask DNS server 192.168.178.1. This is necessary for local network, to resolve clients by host name +#conditional: + # optional: if false (default), return empty result if after rewrite, the mapped resolver returned an empty answer. If true, the original query will be sent to the upstream resolver + # Example: The query "blog.example.com" will be rewritten to "blog.fritz.box" and also redirected to the resolver at 192.168.178.1. If not found and if was set to , the original query "blog.example.com" will be sent upstream. + # Usage: One usecase when having split DNS for internal and external (internet facing) users, but not all subdomains are listed in the internal domain. + #fallbackUpstream: false + # optional: replace domain in the query with other domain before resolver lookup in the mapping + #rewrite: + #example.com: fritz.box + #mapping: + #fritz.box: 192.168.178.1 + #lan.net: 192.168.178.1,192.168.178.2 + +# optional: use black and white lists to block queries (for example ads, trackers, adult pages etc.) +blocking: + # definition of blacklist groups. Can be external link (http/https) or local file + blackLists: + ads: + - https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt + - https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts + - http://sysctl.org/cameleon/hosts + - https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt + - | + # inline definition with YAML literal block scalar style + # hosts format + someadsdomain.com + special: + - https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews/hosts + # definition of whitelist groups. Attention: if the same group has black and whitelists, whitelists will be used to disable particular blacklist entries. If a group has only whitelist entries -> this means only domains from this list are allowed, all other domains will be blocked + whiteLists: + ads: + - whitelist.txt + - | + # inline definition with YAML literal block scalar style + # hosts format + whitelistdomain.com + # this is a regex + /^banners?[_.-]/ + # definition: which groups should be applied for which client + clientGroupsBlock: + # default will be used, if no special definition for a client name exists + default: + - ads + - special + # use client name (with wildcard support: * - sequence of any characters, [0-9] - range) + # or single ip address / client subnet as CIDR notation + #laptop*: + #- ads + #192.168.178.1/24: + #- special + # which response will be sent, if query is blocked: + # zeroIp: 0.0.0.0 will be returned (default) + # nxDomain: return NXDOMAIN as return code + # comma separated list of destination IP addresses (for example: 192.100.100.15, 2001:0db8:85a3:08d3:1319:8a2e:0370:7344). Should contain ipv4 and ipv6 to cover all query types. Useful with running web server on this address to display the "blocked" page. + blockType: zeroIp + # optional: TTL for answers to blocked domains + # default: 6h + blockTTL: 1m + # optional: automatically list refresh period (in duration format). Default: 4h. + # Negative value -> deactivate automatically refresh. + # 0 value -> use default + refreshPeriod: 4h + # optional: timeout for list download (each url). Default: 60s. Use large values for big lists or slow internet connections + downloadTimeout: 4m + # optional: Download attempt timeout. Default: 60s + downloadAttempts: 5 + # optional: Time between the download attempts. Default: 1s + downloadCooldown: 10s + # optional: if failOnError, application startup will fail if at least one list can't be downloaded / opened. Default: blocking + #startStrategy: failOnError + +# optional: configuration for caching of DNS responses +caching: + # duration how long a response must be cached (min value). + # If <=0, use response's TTL, if >0 use this value, if TTL is smaller + # Default: 0 + minTime: 5m + # duration how long a response must be cached (max value). + # If <0, do not cache responses + # If 0, use TTL + # If > 0, use this value, if TTL is greater + # Default: 0 + maxTime: 30m + # Max number of cache entries (responses) to be kept in cache (soft limit). Useful on systems with limited amount of RAM. + # Default (0): unlimited + maxItemsCount: 0 + # if true, will preload DNS results for often used queries (default: names queried more than 5 times in a 2-hour time window) + # this improves the response time for often used queries, but significantly increases external traffic + # default: false + prefetching: true + # prefetch track time window (in duration format) + # default: 120 + prefetchExpires: 2h + # name queries threshold for prefetch + # default: 5 + prefetchThreshold: 5 + # Max number of domains to be kept in cache for prefetching (soft limit). Useful on systems with limited amount of RAM. + # Default (0): unlimited + #prefetchMaxItemsCount: 0 + +# optional: configuration of client name resolution +clientLookup: + # optional: this DNS resolver will be used to perform reverse DNS lookup (typically local router) + #upstream: 192.168.178.1 + # optional: some routers return multiple names for client (host name and user defined name). Define which single name should be used. + # Example: take second name if present, if not take first name + #singleNameOrder: + #- 2 + #- 1 + # optional: custom mapping of client name to IP addresses. Useful if reverse DNS does not work properly or just to have custom client names. + #clients: + #laptop: + #- 192.168.178.29 +# optional: configuration for prometheus metrics endpoint +prometheus: + # enabled if true + #enable: true + # url path, optional (default '/metrics') + #path: /metrics + +# optional: write query information (question, answer, client, duration etc.) to daily csv file +queryLog: + # optional one of: mysql, postgresql, csv, csv-client. If empty, log to console + #type: mysql + # directory (should be mounted as volume in docker) for csv, db connection string for mysql/postgresql + #target: db_user:db_password@tcp(db_host_or_ip:3306)/db_name?charset=utf8mb4&parseTime=True&loc=Local + #postgresql target: postgres://user:password@db_host_or_ip:5432/db_name + # if > 0, deletes log files which are older than ... days + #logRetentionDays: 7 + # optional: Max attempts to create specific query log writer, default: 3 + #creationAttempts: 1 + # optional: Time between the creation attempts, default: 2s + #creationCooldown: 2s + +# optional: Blocky can synchronize its cache and blocking state between multiple instances through redis. +redis: + # Server address and port + #address: redis:6379 + # Password if necessary + #password: passwd + # Database, default: 0 + #database: 2 + # Connection is required for blocky to start. Default: false + #required: true + # Max connection attempts, default: 3 + #connectionAttempts: 10 + # Time between the connection attempts, default: 1s + #connectionCooldown: 3s + +# optional: DNS listener port(s) and bind ip address(es), default 53 (UDP and TCP). Example: 53, :53, "127.0.0.1:5353,[::1]:5353" +port: 553 +# optional: Port(s) and bind ip address(es) for DoT (DNS-over-TLS) listener. Example: 853, 127.0.0.1:853 +#tlsPort: 853 +# optional: HTTPS listener port(s) and bind ip address(es), default empty = no http listener. If > 0, will be used for prometheus metrics, pprof, REST API, DoH... Example: 443, :443, 127.0.0.1:443 +#httpPort: 4000 +#httpsPort: 443 +# optional: Mininal TLS version that the DoH and DoT server will use +#minTlsServeVersion: 1.3 +# if https port > 0: path to cert and key file for SSL encryption. if not set, self-signed certificate will be generated +#certFile: server.crt +#keyFile: server.key +# optional: use this DNS server to resolve blacklist urls and upstream DNS servers. Useful if no DNS resolver is configured and blocky needs to resolve a host name. Format net:IP:port, net must be udp or tcp +#bootstrapDns: tcp+udp:1.1.1.1 + +filtering: +# optional: drop all queries with following query types. Default: empty + #queryTypes: + #- AAAA + +# optional: if path defined, use this file for query resolution (A, AAAA and rDNS). Default: empty +hostsFile: + # optional: Path to hosts file (e.g. /etc/hosts on Linux) + #filePath: /etc/hosts + # optional: TTL, default: 1h + #hostsTTL: 60m + # optional: Time between hosts file refresh, default: 1h + #refreshPeriod: 30m + # optional: Whether loopback hosts addresses (127.0.0.0/8 and ::1) should be filtered or not, default: false + #filterLoopback: true +# optional: Log level (one from debug, info, warn, error). Default: info +#logLevel: info +# optional: Log format (text or json). Default: text +#logFormat: text +# optional: log timestamps. Default: true +#logTimestamp: true +# optional: obfuscate log output (replace all alphanumeric characters with *) for user sensitive data like request domains or responses to increase privacy. Default: false +#logPrivacy: false + +# optional: add EDE error codes to dns response +#ede: + # enabled if true, Default: false + #enable: true +EOF +msg_ok "Installed Blocky" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/blocky.service +[Unit] +Description=Blocky +After=network.target +[Service] +User=root +WorkingDirectory=/opt/blocky +ExecStart=/opt/blocky/./blocky --config config.yml +[Install] +WantedBy=multi-user.target +EOF +$STD systemctl enable --now blocky +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/bunkerweb-install.sh b/install/bunkerweb-install.sh new file mode 100644 index 00000000..aeb4e587 --- /dev/null +++ b/install/bunkerweb-install.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +$STD apt-get install -y apt-transport-https +$STD apt-get install -y lsb-release +msg_ok "Installed Dependencies" + +msg_info "Installing Nginx" +wget -qO- https://nginx.org/keys/nginx_signing.key | gpg --dearmor >/usr/share/keyrings/nginx-archive-keyring.gpg +echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/debian $(lsb_release -cs) nginx" >/etc/apt/sources.list.d/nginx.list +$STD apt-get update +$STD apt-get install -y nginx=1.26.1* +msg_ok "Installed Nginx" + +RELEASE=$(curl -s https://api.github.com/repos/bunkerity/bunkerweb/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +msg_info "Installing BunkerWeb v${RELEASE} (Patience)" +curl -fsSL "https://repo.bunkerweb.io/bunkerity/bunkerweb/gpgkey" | gpg --dearmor >/etc/apt/keyrings/bunkerity_bunkerweb-archive-keyring.gpg +echo "deb [signed-by=/etc/apt/keyrings/bunkerity_bunkerweb-archive-keyring.gpg] https://repo.bunkerweb.io/bunkerity/bunkerweb/debian/ bookworm main" >/etc/apt/sources.list.d/bunkerity_bunkerweb.list +$STD apt-get update +export UI_WIZARD=1 +$STD apt-get install -y bunkerweb=${RELEASE} +cat <<EOF >/etc/apt/preferences.d/bunkerweb +Package: bunkerweb +Pin: version ${RELEASE} +Pin-Priority: 1001 +EOF +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_ok "Installed BunkerWeb v${RELEASE}" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/caddy-install.sh b/install/caddy-install.sh new file mode 100644 index 00000000..88fb8b1a --- /dev/null +++ b/install/caddy-install.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 {debian-keyring,debian-archive-keyring,apt-transport-https,gpg,curl,sudo,mc} +msg_ok "Installed Dependencies" + +msg_info "Installing Caddy" +curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg +curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' >/etc/apt/sources.list.d/caddy-stable.list +$STD apt-get update +$STD apt-get install -y caddy +msg_ok "Installed Caddy" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh new file mode 100644 index 00000000..1f42bbaf --- /dev/null +++ b/install/calibre-web-install.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Co-Author: remz1337 +# 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 imagemagick +msg_ok "Installed Dependencies" + +msg_info "Installing Python Dependencies" +$STD apt-get -y install python3-pip +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +msg_ok "Installed Python Dependencies" + +msg_info "Installing Kepubify" +mkdir -p /opt/kepubify +cd /opt/kepubify +curl -fsSLO https://github.com/pgaskin/kepubify/releases/latest/download/kepubify-linux-64bit &>/dev/null +chmod +x kepubify-linux-64bit +msg_ok "Installed Kepubify" + +msg_info "Installing Calibre-Web" +mkdir -p /opt/calibre-web +$STD wget https://github.com/janeczku/calibre-web/raw/master/library/metadata.db -P /opt/calibre-web +$STD pip install calibreweb +$STD pip install jsonschema +msg_ok "Installed Calibre-Web" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/cps.service +[Unit] +Description=Calibre-Web Server +After=network.target + +[Service] +Type=simple +WorkingDirectory=/opt/calibre-web +ExecStart=/usr/local/bin/cps +TimeoutStopSec=20 +KillMode=process +Restart=on-failure + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now cps.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/casaos-install.sh b/install/casaos-install.sh new file mode 100644 index 00000000..e7e07a61 --- /dev/null +++ b/install/casaos-install.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 CasaOS (Patience)" +DOCKER_CONFIG_PATH='/etc/docker/daemon.json' +mkdir -p $(dirname $DOCKER_CONFIG_PATH) +echo -e '{\n "log-driver": "journald"\n}' > /etc/docker/daemon.json +$STD bash <(curl -fsSL https://get.casaos.io/v0.4.1) +msg_ok "Installed CasaOS" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/changedetection-install.sh b/install/changedetection-install.sh new file mode 100644 index 00000000..d42c5bb3 --- /dev/null +++ b/install/changedetection-install.sh @@ -0,0 +1,163 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 \ + sudo \ + mc \ + git \ + build-essential \ + dumb-init \ + gconf-service \ + libjpeg-dev \ + libatk-bridge2.0-0 \ + libasound2 \ + libatk1.0-0 \ + libcairo2 \ + libcups2 \ + libdbus-1-3 \ + libexpat1 \ + libgbm-dev \ + libgbm1 \ + libgconf-2-4 \ + libgdk-pixbuf2.0-0 \ + libglib2.0-0 \ + libgtk-3-0 \ + libnspr4 \ + libnss3 \ + libpango-1.0-0 \ + libpangocairo-1.0-0 \ + qpdf \ + xdg-utils \ + xvfb \ + ca-certificates \ + gnupg +msg_ok "Installed Dependencies" + +msg_info "Updating Python3" +$STD apt-get install -y \ + python3 \ + python3-dev \ + python3-pip +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +msg_ok "Updated Python3" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing Change Detection" +mkdir /opt/changedetection +$STD pip3 install changedetection.io +msg_ok "Installed Change Detection" + +msg_info "Installing Browserless & Playwright" +mkdir /opt/browserless +$STD python3 -m pip install playwright +$STD git clone https://github.com/browserless/chrome /opt/browserless +$STD npm install --prefix /opt/browserless +$STD npm run build --prefix /opt/browserless +$STD npm prune production --prefix /opt/browserless +msg_ok "Installed Browserless & Playwright" + +msg_info "Installing Font Packages" +$STD apt-get install -y \ + fontconfig \ + libfontconfig1 \ + fonts-freefont-ttf \ + fonts-gfs-neohellenic \ + fonts-indic fonts-ipafont-gothic \ + fonts-kacst fonts-liberation \ + fonts-noto-cjk \ + fonts-noto-color-emoji \ + msttcorefonts \ + fonts-roboto \ + fonts-thai-tlwg \ + fonts-wqy-zenhei +msg_ok "Installed Font Packages" + +msg_info "Installing X11 Packages" +$STD apt-get install -y \ + libx11-6 \ + libx11-xcb1 \ + libxcb1 \ + libxcomposite1 \ + libxcursor1 \ + libxdamage1 \ + libxext6 \ + libxfixes3 \ + libxi6 \ + libxrandr2 \ + libxrender1 \ + libxss1 \ + libxtst6 +msg_ok "Installed X11 Packages" + +msg_info "Creating Services" +cat <<EOF >/etc/systemd/system/changedetection.service +[Unit] +Description=Change Detection +After=network-online.target +After=network.target browserless.service +Wants=browserless.service +[Service] +Type=simple +WorkingDirectory=/opt/changedetection +Environment=WEBDRIVER_URL=http://127.0.0.1:4444/wd/hub +Environment=PLAYWRIGHT_DRIVER_URL=ws://browserless-chrome:3000/chrome?launch={"defaultViewport":{"height":720,"width":1280},"headless":false,"stealth":true}&blockAds=true +ExecStart=changedetection.io -d /opt/changedetection -p 5000 +[Install] +WantedBy=multi-user.target +EOF + +cat <<EOF >/etc/systemd/system/browserless.service +[Unit] +Description=browserless service +After=network.target +[Service] +Environment=APP_DIR=/opt/browserless +Environment=PLAYWRIGHT_BROWSERS_PATH=/opt/browserless +Environment=CONNECTION_TIMEOUT=60000 +Environment=HOST=127.0.0.1 +Environment=LANG="C.UTF-8" +Environment=NODE_ENV=production +Environment=PORT=3000 +Environment=WORKSPACE_DIR=/opt/browserless/workspace +WorkingDirectory=/opt/browserless +ExecStart=/opt/browserless/start.sh +SyslogIdentifier=browserless +[Install] +WantedBy=default.target +EOF + +systemctl enable -q --now browserless +systemctl enable -q --now changedetection +msg_ok "Created Services" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/channels-install.sh b/install/channels-install.sh new file mode 100644 index 00000000..3c5e2d9d --- /dev/null +++ b/install/channels-install.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 chromium +$STD apt-get install -y xvfb +msg_ok "Installed Dependencies" + +if [[ "$CTTYPE" == "0" ]]; then + msg_info "Setting Up Hardware Acceleration" + $STD apt-get -y install \ + va-driver-all \ + ocl-icd-libopencl1 \ + intel-opencl-icd + chgrp video /dev/dri + chmod 755 /dev/dri + chmod 660 /dev/dri/* + $STD adduser $(id -u -n) video + $STD adduser $(id -u -n) render + msg_ok "Set Up Hardware Acceleration" +fi + +msg_info "Installing Channels DVR Server (Patience)" +cd /opt +$STD bash <(curl -fsSL https://getchannels.com/dvr/setup.sh) +sed -i -e 's/^sgx:x:104:$/render:x:104:root/' -e 's/^render:x:106:root$/sgx:x:106:/' /etc/group +msg_ok "Installed Channels DVR Server" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/cloudflared-install.sh b/install/cloudflared-install.sh new file mode 100644 index 00000000..abd45e47 --- /dev/null +++ b/install/cloudflared-install.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 Cloudflared" +mkdir -p --mode=0755 /usr/share/keyrings +VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)" +curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg >/usr/share/keyrings/cloudflare-main.gpg +echo "deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared $VERSION main" >/etc/apt/sources.list.d/cloudflared.list +$STD apt-get update +$STD apt-get install -y cloudflared +msg_ok "Installed Cloudflared" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/commafeed-install.sh b/install/commafeed-install.sh new file mode 100644 index 00000000..4806e863 --- /dev/null +++ b/install/commafeed-install.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 rsync +msg_ok "Installed Dependencies" + +msg_info "Installing Azul Zulu" +wget -qO /etc/apt/trusted.gpg.d/zulu-repo.asc "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xB1998361219BD9C9" +wget -q https://cdn.azul.com/zulu/bin/zulu-repo_1.0.0-3_all.deb +$STD dpkg -i zulu-repo_1.0.0-3_all.deb +$STD apt-get update +$STD apt-get -y install zulu17-jdk +msg_ok "Installed Azul Zulu" + +RELEASE=$(curl -sL https://api.github.com/repos/Athou/commafeed/releases/latest | grep '"tag_name":' | cut -d'"' -f4) +msg_info "Installing CommaFeed ${RELEASE}" +mkdir /opt/commafeed +wget -q https://github.com/Athou/commafeed/releases/download/${RELEASE}/commafeed-${RELEASE}-h2-jvm.zip +unzip -q commafeed-${RELEASE}-h2-jvm.zip +mv commafeed-${RELEASE}-h2/* /opt/commafeed/ +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_ok "Installed CommaFeed ${RELEASE}" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/commafeed.service +[Unit] +Description=CommaFeed Service +After=network.target + +[Service] +ExecStart=java -jar quarkus-run.jar +WorkingDirectory=/opt/commafeed/ +Restart=always + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now commafeed.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -rf commafeed-${RELEASE}-h2 commafeed-${RELEASE}-h2-jvm.zip zulu-repo_1.0.0-3_all.deb +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/cronicle-install.sh b/install/cronicle-install.sh new file mode 100644 index 00000000..c3ea5a8a --- /dev/null +++ b/install/cronicle-install.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 "Installing Node.js" +$STD bash <(curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh) +. ~/.bashrc +$STD nvm install 16.20.1 +ln -sf /root/.nvm/versions/node/v16.20.1/bin/node /usr/bin/node +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 +$STD /opt/cronicle/bin/control.sh setup +$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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/daemonsync-install.sh b/install/daemonsync-install.sh new file mode 100644 index 00000000..483e27aa --- /dev/null +++ b/install/daemonsync-install.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +customize + +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..a81749ae --- /dev/null +++ b/install/dashy-install.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +RELEASE=$(curl -s https://api.github.com/repos/Lissy93/dashy/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +msg_info "Installing Dashy ${RELEASE} (Patience)" +mkdir -p /opt/dashy +wget -qO- https://github.com/Lissy93/dashy/archive/refs/tags/${RELEASE}.tar.gz | tar -xz -C /opt/dashy --strip-components=1 +cd /opt/dashy +$STD npm install +$STD npm run build +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_ok "Installed Dashy ${RELEASE}" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/dashy.service +[Unit] +Description=dashy + +[Service] +Type=simple +WorkingDirectory=/opt/dashy +ExecStart=/usr/bin/npm start +[Install] +WantedBy=multi-user.target +EOF +systemctl -q --now enable dashy +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/debian-install.sh b/install/debian-install.sh new file mode 100644 index 00000000..bb89300e --- /dev/null +++ b/install/debian-install.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" \ No newline at end of file diff --git a/install/deconz-install.sh b/install/deconz-install.sh new file mode 100644 index 00000000..203f5191 --- /dev/null +++ b/install/deconz-install.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 Phoscon Repository" +VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)" +curl -fsSL http://phoscon.de/apt/deconz.pub.key >/etc/apt/trusted.gpg.d/deconz.pub.asc +echo "deb [arch=amd64] http://phoscon.de/apt/deconz $VERSION main" >/etc/apt/sources.list.d/deconz.list +msg_ok "Setup Phoscon Repository" + +msg_info "Installing deConz" +libssl=$(curl -fsSL "http://security.ubuntu.com/ubuntu/pool/main/o/openssl/" | grep -o 'libssl1\.1_1\.1\.1f-1ubuntu2\.2[^"]*amd64\.deb' | head -n1) +wget -qL http://security.ubuntu.com/ubuntu/pool/main/o/openssl/$libssl +$STD dpkg -i $libssl +$STD apt-get update +$STD apt-get install -y deconz +msg_ok "Installed deConz" + +msg_info "Creating Service" +cat <<EOF >/lib/systemd/system/deconz.service +[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 +EOF +systemctl enable -q --now deconz +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -rf $libssl +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/deluge-install.sh b/install/deluge-install.sh new file mode 100644 index 00000000..979b22b6 --- /dev/null +++ b/install/deluge-install.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 python3-libtorrent +msg_ok "Installed Dependencies" + +msg_info "Updating Python3" +$STD apt-get install -y \ + python3 \ + python3-dev \ + python3-pip +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +msg_ok "Updated Python3" + +msg_info "Installing Deluge" +$STD pip install deluge[all] +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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/docker-install.sh b/install/docker-install.sh new file mode 100644 index 00000000..b6b110ae --- /dev/null +++ b/install/docker-install.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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") +PORTAINER_AGENT_LATEST_VERSION=$(get_latest_release "portainer/agent") +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) +echo -e '{\n "log-driver": "journald"\n}' >/etc/docker/daemon.json +$STD sh <(curl -sSL https://get.docker.com) +msg_ok "Installed Docker $DOCKER_LATEST_VERSION" + +read -r -p "Would you like to add Portainer? <y/N> " 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 9443:9443 \ + --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" +else + read -r -p "Would you like to add the Portainer Agent? <y/N> " prompt + if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then + msg_info "Installing Portainer agent $PORTAINER_AGENT_LATEST_VERSION" + $STD docker run -d \ + -p 9001:9001 \ + --name portainer_agent \ + --restart=always \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v /var/lib/docker/volumes:/var/lib/docker/volumes \ + portainer/agent + msg_ok "Installed Portainer Agent $PORTAINER_AGENT_LATEST_VERSION" + fi +fi +read -r -p "Would you like to add Docker Compose? <y/N> " 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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/dockge-install.sh b/install/dockge-install.sh new file mode 100644 index 00000000..3cb46245 --- /dev/null +++ b/install/dockge-install.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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") +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) +echo -e '{\n "log-driver": "journald"\n}' >/etc/docker/daemon.json +$STD sh <(curl -sSL https://get.docker.com) +msg_ok "Installed Docker $DOCKER_LATEST_VERSION" + +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" + +msg_info "Installing Dockge" +mkdir -p /opt/{dockge,stacks} +wget -q -O /opt/dockge/compose.yaml https://raw.githubusercontent.com/louislam/dockge/master/compose.yaml +cd /opt/dockge +$STD docker compose up -d +msg_ok "Installed Dockge" + +read -r -p "Would you like to add Immich? <y/N> " prompt +if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then + msg_info "Adding Immich compose.yaml" + mkdir -p /opt/stacks/immich + wget -q -O /opt/stacks/immich/compose.yaml https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml + wget -q -O /opt/stacks/immich/.env https://github.com/immich-app/immich/releases/latest/download/example.env + #wget -q -O /opt/stacks/immich/hwaccel.ml.yml https://github.com/immich-app/immich/releases/latest/download/hwaccel.ml.yml + msg_ok "Added Immich compose.yaml" +fi + +read -r -p "Would you like to add Home Assistant? <y/N> " prompt +if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then + msg_info "Adding Home Assistant compose.yaml" + mkdir -p /opt/stacks/homeassistant + cat <<EOF >/opt/stacks/homeassistant/compose.yaml +version: "3" +services: + homeassistant: + container_name: homeassistant + image: ghcr.io/home-assistant/home-assistant:stable + volumes: + - ./config:/config + - /etc/localtime:/etc/localtime:ro + - /run/dbus:/run/dbus:ro + restart: unless-stopped + privileged: true + network_mode: host +EOF +msg_ok "Added Home Assistant compose.yaml" +fi + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/emby-install.sh b/install/emby-install.sh new file mode 100644 index 00000000..bc6ba9be --- /dev/null +++ b/install/emby-install.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 Hardware Acceleration" +$STD apt-get -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools} +if [[ "$CTTYPE" == "0" ]]; then + chgrp video /dev/dri + chmod 755 /dev/dri + chmod 660 /dev/dri/* + $STD adduser $(id -u -n) video + $STD adduser $(id -u -n) render +fi +msg_ok "Set Up Hardware Acceleration" + +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 +if [[ "$CTTYPE" == "0" ]]; then + sed -i -e 's/^ssl-cert:x:104:$/render:x:104:root,emby/' -e 's/^render:x:108:root,emby$/ssl-cert:x:108:/' /etc/group +else + sed -i -e 's/^ssl-cert:x:104:$/render:x:104:emby/' -e 's/^render:x:108:emby$/ssl-cert:x:108:/' /etc/group +fi +msg_ok "Installed Emby" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y 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..16475d53 --- /dev/null +++ b/install/emqx-install.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +customize + +msg_info "Cleaning up" +apt-get autoremove >/dev/null +apt-get autoclean >/dev/null +msg_ok "Cleaned" diff --git a/install/ersatztv-install.sh b/install/ersatztv-install.sh new file mode 100644 index 00000000..939880f3 --- /dev/null +++ b/install/ersatztv-install.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck +# Co-Author: MickLesk (Canbiz) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +# Source: https://github.com/ErsatzTV/ErsatzTV + +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 FFmpeg (Patience)" +echo "deb http://deb.debian.org/debian/ sid main" >/etc/apt/sources.list.d/sid.list +$STD apt update +DEBIAN_FRONTEND=noninteractive $STD apt install -t sid ffmpeg -y +rm /etc/apt/sources.list.d/sid.list +$STD apt update +msg_ok "Installed FFmpeg" + +msg_info "Installing ErsatzTV" +RELEASE=$(curl -s https://api.github.com/repos/ErsatzTV/ErsatzTV/releases | grep -oP '"tag_name": "\K[^"]+' | head -n 1) +wget -qO- "https://github.com/ErsatzTV/ErsatzTV/releases/download/${RELEASE}/ErsatzTV-${RELEASE}-linux-x64.tar.gz" | tar -xz -C /opt +mv "/opt/ErsatzTV-${RELEASE}-linux-x64" /opt/ErsatzTV +msg_ok "Installed ErsatzTV" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/ersatzTV.service +[Unit] +Description=ErsatzTV Service +After=multi-user.target + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/ErsatzTV +ExecStart=/opt/ErsatzTV/ErsatzTV +Restart=always +RestartSec=30 + +[Install] +WantedBy=multi-user.target +EOF +systemctl -q --now enable ersatzTV.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/esphome-install.sh b/install/esphome-install.sh new file mode 100644 index 00000000..301d9bbb --- /dev/null +++ b/install/esphome-install.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 "Updating Python3" +$STD apt-get install -y \ + python3 \ + python3-dev \ + python3-pip \ + python3-venv +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +msg_ok "Updated Python3" + +msg_info "Installing ESPHome" +mkdir /root/config +$STD pip install esphome tornado esptool +msg_ok "Installed ESPHome" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/esphomeDashboard.service +[Unit] +Description=ESPHome Dashboard +After=network.target + +[Service] +ExecStart=/usr/local/bin/esphome dashboard /root/config/ +Restart=always +User=root + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now esphomeDashboard.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/fenrus-install.sh b/install/fenrus-install.sh new file mode 100644 index 00000000..fa0f9500 --- /dev/null +++ b/install/fenrus-install.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Co-Author: Scorpoon +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +# Source: https://github.com/revenz/Fenrus + + + +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 sudo +$STD apt-get install -y mc +$STD apt-get install -y curl +$STD apt-get install -y git +msg_ok "Installed Dependencies" + +msg_info "Installing ASP.NET Core 7 SDK" +var_os=$(grep "^ID=" /etc/os-release | cut -d'=' -f2 | tr -d '"') +var_version=$(grep "^VERSION_ID=" /etc/os-release | cut -d'=' -f2 | tr -d '"') +if [ "${var_os}" = "debian" ]; then + wget -q "https://packages.microsoft.com/config/debian/$var_version/packages-microsoft-prod.deb" + $STD dpkg -i packages-microsoft-prod.deb + rm packages-microsoft-prod.deb +fi +$STD apt-get update +$STD apt-get install -y dotnet-sdk-7.0 +msg_ok "Installed ASP.NET Core 7 SDK" + +msg_info "Installing ${APPLICATION}" +git clone -q https://github.com/revenz/Fenrus.git /opt/${APPLICATION} +cd /opt/${APPLICATION} +$STD dotnet publish -c Release -o "/opt/${APPLICATION}/" Fenrus.csproj +msg_ok "Installed ${APPLICATION}" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/"${APPLICATION}".service +[Unit] +Description=${APPLICATION} + +[Service] +WorkingDirectory=/opt/${APPLICATION} +ExecStart=/usr/bin/dotnet Fenrus.dll --urls=http://*:5000 +SyslogIdentifier=${APPLICATION} +User=root + +[Install] +WantedBy=multi-user.target +EOF +$STD systemctl enable -q --now ${APPLICATION} +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/fhem-install.sh b/install/fhem-install.sh new file mode 100644 index 00000000..ccc078fe --- /dev/null +++ b/install/fhem-install.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 avahi-daemon +$STD apt-get install -y gnupg2 +msg_ok "Installed Dependencies" + +msg_info "Setting up Fhem Repository" +curl -sSf https://debian.fhem.de/archive.key | gpg --dearmor >/etc/apt/trusted.gpg.d/debianfhemde-archive-keyring.gpg +echo 'deb [signed-by=/etc/apt/trusted.gpg.d/debianfhemde-archive-keyring.gpg] https://debian.fhem.de/nightly/ /' >/etc/apt/sources.list.d/fhem.list +msg_ok "Set up Fhem Repository" + +msg_info "Installing Fhem" +$STD apt-get update +$STD apt-get install -y fhem +msg_info "Installed Fhem" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/flaresolverr-install.sh b/install/flaresolverr-install.sh new file mode 100644 index 00000000..93c7fdd4 --- /dev/null +++ b/install/flaresolverr-install.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Co-Author: remz1337 +# 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 gpg +$STD apt-get install -y xvfb +msg_ok "Installed Dependencies" + +msg_info "Installing Chrome" +wget -qO- https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg +echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list +$STD apt update +$STD apt install -y google-chrome-stable +msg_ok "Installed Chrome" + +msg_info "Installing FlareSolverr" +RELEASE=$(wget -q https://github.com/FlareSolverr/FlareSolverr/releases/latest -O - | grep "title>Release" | cut -d " " -f 4) +$STD wget -q https://github.com/FlareSolverr/FlareSolverr/releases/download/$RELEASE/flaresolverr_linux_x64.tar.gz +$STD tar -xzf flaresolverr_linux_x64.tar.gz -C /opt +$STD rm flaresolverr_linux_x64.tar.gz +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_ok "Installed FlareSolverr" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/flaresolverr.service +[Unit] +Description=FlareSolverr +After=network.target +[Service] +SyslogIdentifier=flaresolverr +Restart=always +RestartSec=5 +Type=simple +Environment="LOG_LEVEL=info" +Environment="CAPTCHA_SOLVER=none" +WorkingDirectory=/opt/flaresolverr +ExecStart=/opt/flaresolverr/flaresolverr +TimeoutStopSec=30 +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now flaresolverr.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/flowiseai-install.sh b/install/flowiseai-install.sh new file mode 100644 index 00000000..31807365 --- /dev/null +++ b/install/flowiseai-install.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +msg_ok "Installed Dependencies" + +msg_info "Installing Node.js" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing FlowiseAI (Patience)" +$STD npm install -g flowise +mkdir -p /opt/flowiseai +wget -q https://raw.githubusercontent.com/FlowiseAI/Flowise/main/packages/server/.env.example -O /opt/flowiseai/.env +msg_ok "Installed FlowiseAI" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/flowise.service +[Unit] +Description=FlowiseAI +After=network.target + +[Service] +EnvironmentFile=/opt/flowiseai/.env +ExecStart=npx flowise start +Restart=always + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now flowise.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/forgejo-install.sh b/install/forgejo-install.sh new file mode 100644 index 00000000..a2e28169 --- /dev/null +++ b/install/forgejo-install.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 git-lfs +msg_ok "Installed Dependencies" + +msg_info "Installing Forgejo" +mkdir -p /opt/forgejo +RELEASE=$(curl -s https://codeberg.org/api/v1/repos/forgejo/forgejo/releases/latest | grep -oP '"tag_name":\s*"\K[^"]+' | sed 's/^v//') +wget -qO /opt/forgejo/forgejo-$RELEASE-linux-amd64 "https://codeberg.org/forgejo/forgejo/releases/download/v${RELEASE}/forgejo-${RELEASE}-linux-amd64" +chmod +x /opt/forgejo/forgejo-$RELEASE-linux-amd64 +ln -sf /opt/forgejo/forgejo-$RELEASE-linux-amd64 /usr/local/bin/forgejo +msg_ok "Installed Forgejo" + +msg_info "Setting up Forgejo" +$STD adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/git git +mkdir /var/lib/forgejo +chown git:git /var/lib/forgejo +chmod 750 /var/lib/forgejo +mkdir /etc/forgejo +chown root:git /etc/forgejo +chmod 770 /etc/forgejo +msg_ok "Setup Forgejo" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/forgejo.service +[Unit] +Description=Forgejo +After=syslog.target +After=network.target +[Service] +RestartSec=2s +Type=simple +User=git +Group=git +WorkingDirectory=/var/lib/forgejo/ +ExecStart=/usr/local/bin/forgejo web --config /etc/forgejo/app.ini +Restart=always +Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/forgejo +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now forgejo +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/frigate-install.sh b/install/frigate-install.sh new file mode 100644 index 00000000..b04dd94f --- /dev/null +++ b/install/frigate-install.sh @@ -0,0 +1,273 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Co-Author: remz1337 +# 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,sudo,mc,git,gpg,automake,build-essential,xz-utils,libtool,ccache,pkg-config,libgtk-3-dev,libavcodec-dev,libavformat-dev,libswscale-dev,libv4l-dev,libxvidcore-dev,libx264-dev,libjpeg-dev,libpng-dev,libtiff-dev,gfortran,openexr,libatlas-base-dev,libssl-dev,libtbb2,libtbb-dev,libdc1394-22-dev,libopenexr-dev,libgstreamer-plugins-base1.0-dev,libgstreamer1.0-dev,gcc,gfortran,libopenblas-dev,liblapack-dev,libusb-1.0-0-dev,jq,moreutils} +msg_ok "Installed Dependencies" + +msg_info "Installing Python3 Dependencies" +$STD apt-get install -y {python3,python3-dev,python3-setuptools,python3-distutils,python3-pip} +$STD pip install --upgrade pip +msg_ok "Installed Python3 Dependencies" + +msg_info "Installing Node.js" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing go2rtc" +mkdir -p /usr/local/go2rtc/bin +cd /usr/local/go2rtc/bin +wget -qO go2rtc "https://github.com/AlexxIT/go2rtc/releases/latest/download/go2rtc_linux_amd64" +chmod +x go2rtc +$STD ln -svf /usr/local/go2rtc/bin/go2rtc /usr/local/bin/go2rtc +msg_ok "Installed go2rtc" + +msg_info "Setting Up Hardware Acceleration" +$STD apt-get -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools} +if [[ "$CTTYPE" == "0" ]]; then + chgrp video /dev/dri + chmod 755 /dev/dri + chmod 660 /dev/dri/* +fi +msg_ok "Set Up Hardware Acceleration" + +RELEASE=$(curl -s https://api.github.com/repos/blakeblackshear/frigate/releases/latest | jq -r '.tag_name') +msg_ok "Stop spinner to prevent segmentation fault" +msg_info "Installing Frigate $RELEASE (Perseverance)" +if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi +cd ~ +mkdir -p /opt/frigate/models +wget -q https://github.com/blakeblackshear/frigate/archive/refs/tags/${RELEASE}.tar.gz -O frigate.tar.gz +tar -xzf frigate.tar.gz -C /opt/frigate --strip-components 1 +rm -rf frigate.tar.gz +cd /opt/frigate +$STD pip3 wheel --wheel-dir=/wheels -r /opt/frigate/docker/main/requirements-wheels.txt +cp -a /opt/frigate/docker/main/rootfs/. / +export TARGETARCH="amd64" +echo 'libc6 libraries/restart-without-asking boolean true' | debconf-set-selections +wget -q -O /opt/frigate/docker/main/install_deps.sh https://raw.githubusercontent.com/blakeblackshear/frigate/dev/docker/main/install_deps.sh +$STD /opt/frigate/docker/main/install_deps.sh +$STD apt update +$STD ln -svf /usr/lib/btbn-ffmpeg/bin/ffmpeg /usr/local/bin/ffmpeg +$STD ln -svf /usr/lib/btbn-ffmpeg/bin/ffprobe /usr/local/bin/ffprobe +$STD pip3 install -U /wheels/*.whl +ldconfig +$STD pip3 install -r /opt/frigate/docker/main/requirements-dev.txt +$STD /opt/frigate/.devcontainer/initialize.sh +$STD make version +cd /opt/frigate/web +$STD npm install +$STD npm run build +cp -r /opt/frigate/web/dist/* /opt/frigate/web/ +cp -r /opt/frigate/config/. /config +sed -i '/^s6-svc -O \.$/s/^/#/' /opt/frigate/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/run +cat <<EOF >/config/config.yml +mqtt: + enabled: false +cameras: + test: + ffmpeg: + #hwaccel_args: preset-vaapi + inputs: + - path: /media/frigate/person-bicycle-car-detection.mp4 + input_args: -re -stream_loop -1 -fflags +genpts + roles: + - detect + - rtmp + detect: + height: 1080 + width: 1920 + fps: 5 +EOF +ln -sf /config/config.yml /opt/frigate/config/config.yml +if [[ "$CTTYPE" == "0" ]]; then + sed -i -e 's/^kvm:x:104:$/render:x:104:root,frigate/' -e 's/^render:x:105:root$/kvm:x:105:/' /etc/group +else + sed -i -e 's/^kvm:x:104:$/render:x:104:frigate/' -e 's/^render:x:105:$/kvm:x:105:/' /etc/group +fi +echo "tmpfs /tmp/cache tmpfs defaults 0 0" >> /etc/fstab +msg_ok "Installed Frigate $RELEASE" + +if grep -q -o -m1 'avx[^ ]*' /proc/cpuinfo; then + msg_ok "AVX Support Detected" + msg_info "Installing Openvino Object Detection Model (Resilience)" + $STD pip install -r /opt/frigate/docker/main/requirements-ov.txt + cd /opt/frigate/models + export ENABLE_ANALYTICS=NO + $STD /usr/local/bin/omz_downloader --name ssdlite_mobilenet_v2 --num_attempts 2 + $STD /usr/local/bin/omz_converter --name ssdlite_mobilenet_v2 --precision FP16 --mo /usr/local/bin/mo + cd / + cp -r /opt/frigate/models/public/ssdlite_mobilenet_v2 openvino-model + wget -q https://github.com/openvinotoolkit/open_model_zoo/raw/master/data/dataset_classes/coco_91cl_bkgr.txt -O openvino-model/coco_91cl_bkgr.txt + sed -i 's/truck/car/g' openvino-model/coco_91cl_bkgr.txt + cat <<EOF >>/config/config.yml +detectors: + ov: + type: openvino + device: CPU + model: + path: /openvino-model/FP16/ssdlite_mobilenet_v2.xml +model: + width: 300 + height: 300 + input_tensor: nhwc + input_pixel_format: bgr + labelmap_path: /openvino-model/coco_91cl_bkgr.txt +EOF + msg_ok "Installed Openvino Object Detection Model" +else + cat <<EOF >>/config/config.yml +model: + path: /cpu_model.tflite +EOF +fi + +msg_info "Installing Coral Object Detection Model (Patience)" +cd /opt/frigate +export CCACHE_DIR=/root/.ccache +export CCACHE_MAXSIZE=2G +wget -q https://github.com/libusb/libusb/archive/v1.0.26.zip +unzip -q v1.0.26.zip +rm v1.0.26.zip +cd libusb-1.0.26 +$STD ./bootstrap.sh +$STD ./configure --disable-udev --enable-shared +$STD make -j $(nproc --all) +cd /opt/frigate/libusb-1.0.26/libusb +mkdir -p /usr/local/lib +$STD /bin/bash ../libtool --mode=install /usr/bin/install -c libusb-1.0.la '/usr/local/lib' +mkdir -p /usr/local/include/libusb-1.0 +$STD /usr/bin/install -c -m 644 libusb.h '/usr/local/include/libusb-1.0' +ldconfig +cd / +wget -qO edgetpu_model.tflite https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess_edgetpu.tflite +wget -qO cpu_model.tflite https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess.tflite +cp /opt/frigate/labelmap.txt /labelmap.txt +wget -qO yamnet-tflite-classification-tflite-v1.tar.gz https://www.kaggle.com/api/v1/models/google/yamnet/tfLite/classification-tflite/1/download +tar xzf yamnet-tflite-classification-tflite-v1.tar.gz +rm -rf yamnet-tflite-classification-tflite-v1.tar.gz +mv 1.tflite cpu_audio_model.tflite +cp /opt/frigate/audio-labelmap.txt /audio-labelmap.txt +mkdir -p /media/frigate +wget -qO /media/frigate/person-bicycle-car-detection.mp4 https://github.com/intel-iot-devkit/sample-videos/raw/master/person-bicycle-car-detection.mp4 +msg_ok "Installed Coral Object Detection Model" + +msg_info "Building Nginx with Custom Modules" +$STD /opt/frigate/docker/main/build_nginx.sh +sed -e '/s6-notifyoncheck/ s/^#*/#/' -i /opt/frigate/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/run +sed -i 's/error_log \/dev\/stdout warn\;/error_log \/dev\/shm\/logs\/nginx\/current warn\;/' /usr/local/nginx/conf/nginx.conf +sed -i 's/access_log \/dev\/stdout main\;/access_log \/dev\/shm\/logs\/nginx\/current main\;/' /usr/local/nginx/conf/nginx.conf +ln -sf /usr/local/nginx/sbin/nginx /usr/local/bin/nginx +msg_ok "Built Nginx" + +msg_info "Installing Tempio" +sed -i 's|/rootfs/usr/local|/usr/local|g' /opt/frigate/docker/main/install_tempio.sh +$STD /opt/frigate/docker/main/install_tempio.sh +ln -sf /usr/local/tempio/bin/tempio /usr/local/bin/tempio +msg_ok "Installed Tempio" + +msg_info "Creating Services" +cat <<EOF >/etc/systemd/system/create_directories.service +[Unit] +Description=Create necessary directories for logs + +[Service] +Type=oneshot +ExecStart=/bin/bash -c '/bin/mkdir -p /dev/shm/logs/{frigate,go2rtc,nginx} && /bin/touch /dev/shm/logs/{frigate/current,go2rtc/current,nginx/current} && /bin/chmod -R 777 /dev/shm/logs' + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now create_directories +sleep 3 +cat <<EOF >/etc/systemd/system/go2rtc.service +[Unit] +Description=go2rtc service +After=network.target +After=create_directories.service +StartLimitIntervalSec=0 + +[Service] +Type=simple +Restart=always +RestartSec=1 +User=root +ExecStartPre=+rm /dev/shm/logs/go2rtc/current +ExecStart=/bin/bash -c "bash /opt/frigate/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/run 2> >(/usr/bin/ts '%%Y-%%m-%%d %%H:%%M:%%.S ' >&2) | /usr/bin/ts '%%Y-%%m-%%d %%H:%%M:%%.S '" +StandardOutput=file:/dev/shm/logs/go2rtc/current +StandardError=file:/dev/shm/logs/go2rtc/current + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now go2rtc +sleep 3 +cat <<EOF >/etc/systemd/system/frigate.service +[Unit] +Description=Frigate service +After=go2rtc.service +After=create_directories.service +StartLimitIntervalSec=0 + +[Service] +Type=simple +Restart=always +RestartSec=1 +User=root +ExecStartPre=+rm /dev/shm/logs/frigate/current +ExecStart=/bin/bash -c "bash /opt/frigate/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/run 2> >(/usr/bin/ts '%%Y-%%m-%%d %%H:%%M:%%.S ' >&2) | /usr/bin/ts '%%Y-%%m-%%d %%H:%%M:%%.S '" +StandardOutput=file:/dev/shm/logs/frigate/current +StandardError=file:/dev/shm/logs/frigate/current + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now frigate +sleep 3 +cat <<EOF >/etc/systemd/system/nginx.service +[Unit] +Description=Nginx service +After=frigate.service +After=create_directories.service +StartLimitIntervalSec=0 + +[Service] +Type=simple +Restart=always +RestartSec=1 +User=root +ExecStartPre=+rm /dev/shm/logs/nginx/current +ExecStart=/bin/bash -c "bash /opt/frigate/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/run 2> >(/usr/bin/ts '%%Y-%%m-%%d %%H:%%M:%%.S ' >&2) | /usr/bin/ts '%%Y-%%m-%%d %%H:%%M:%%.S '" +StandardOutput=file:/dev/shm/logs/nginx/current +StandardError=file:/dev/shm/logs/nginx/current + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now nginx +msg_ok "Configured Services" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/gitea-install.sh b/install/gitea-install.sh new file mode 100644 index 00000000..02c8310e --- /dev/null +++ b/install/gitea-install.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Co-author: Rogue-King +# 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 git +$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 Gitea" +RELEASE=$(wget -q https://github.com/go-gitea/gitea/releases/latest -O - | grep "title>Release" | cut -d " " -f 4 | sed 's/^v//') +wget -q https://github.com/go-gitea/gitea/releases/download/v$RELEASE/gitea-$RELEASE-linux-amd64 +mv gitea* /usr/local/bin/gitea +chmod +x /usr/local/bin/gitea +adduser --system --group --disabled-password --shell /bin/bash --home /etc/gitea gitea > /dev/null +mkdir -p /var/lib/gitea/{custom,data,log} +chown -R gitea:gitea /var/lib/gitea/ +chmod -R 750 /var/lib/gitea/ +chown root:gitea /etc/gitea +chmod 770 /etc/gitea +sudo -u gitea ln -s /var/lib/gitea/data/.ssh/ /etc/gitea/.ssh +msg_ok "Installed Gitea" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/gitea.service +[Unit] +Description=Gitea (Git with a cup of tea) +After=syslog.target +After=network.target + +[Service] +# Uncomment notify and watchdog if you want to use them +# Uncomment the next line if you have repos with lots of files and get a HTTP 500 error because of that +# LimitNOFILE=524288:524288 +RestartSec=2s +Type=simple +#Type=notify +User=gitea +Group=gitea +#The mount point we added to the container +WorkingDirectory=/var/lib/gitea +#Create directory in /run +RuntimeDirectory=gitea +ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini +Restart=always +Environment=USER=gitea HOME=/var/lib/gitea/data GITEA_WORK_DIR=/var/lib/gitea +#WatchdogSec=30s +#Capabilities to bind to low-numbered ports +#CapabilityBoundingSet=CAP_NET_BIND_SERVICE +#AmbientCapabilities=CAP_NET_BIND_SERVICE + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now gitea +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/go2rtc-install.sh b/install/go2rtc-install.sh new file mode 100644 index 00000000..8c5f1072 --- /dev/null +++ b/install/go2rtc-install.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/gokapi-install.sh b/install/gokapi-install.sh new file mode 100644 index 00000000..26fe6338 --- /dev/null +++ b/install/gokapi-install.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 Gokapi" +LATEST=$(curl -sL https://api.github.com/repos/Forceu/Gokapi/releases/latest | grep '"tag_name":' | cut -d'"' -f4) +mkdir -p /opt/gokapi/{data,config} +wget -q https://github.com/Forceu/Gokapi/releases/download/$LATEST/gokapi-linux_amd64.zip +unzip -q gokapi-linux_amd64.zip -d /opt/gokapi +rm gokapi-linux_amd64.zip +chmod +x /opt/gokapi/gokapi-linux_amd64 +msg_ok "Installed Gokapi" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/gokapi.service +[Unit] +Description=gokapi + +[Service] +Type=simple +Environment=GOKAPI_DATA_DIR=/opt/gokapi/data +Environment=GOKAPI_CONFIG_DIR=/opt/gokapi/config +ExecStart=/opt/gokapi/gokapi-linux_amd64 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now gokapi +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/gotify-install.sh b/install/gotify-install.sh new file mode 100644 index 00000000..674013f8 --- /dev/null +++ b/install/gotify-install.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 Gotify" +RELEASE=$(curl -s https://api.github.com/repos/gotify/server/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +mkdir -p /opt/gotify +cd /opt/gotify +wget -q https://github.com/gotify/server/releases/download/v${RELEASE}/gotify-linux-amd64.zip +$STD unzip gotify-linux-amd64.zip +rm -rf gotify-linux-amd64.zip +chmod +x gotify-linux-amd64 + +cat <<EOF >/etc/systemd/system/gotify.service +[Unit] +Description=Gotify +Requires=network.target +After=network.target + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/gotify +ExecStart=/opt/gotify/./gotify-linux-amd64 +Restart=always +RestartSec=3 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now gotify +msg_ok "Installed Gotify" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/grafana-install.sh b/install/grafana-install.sh new file mode 100644 index 00000000..88627730 --- /dev/null +++ b/install/grafana-install.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +systemctl start grafana-server +systemctl enable --now -q grafana-server.service +msg_ok "Installed Grafana" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/grocy-install.sh b/install/grocy-install.sh new file mode 100644 index 00000000..e47eb8bc --- /dev/null +++ b/install/grocy-install.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +msg_ok "Installed Dependencies" + +msg_info "Installing PHP8.2" +VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)" +curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg +echo -e "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $VERSION main" >/etc/apt/sources.list.d/php.list +$STD apt-get update +$STD apt-get install -y php8.2 +$STD apt-get install -y libapache2-mod-php8.2 +$STD apt-get install -y php8.2-sqlite3 +$STD apt-get install -y php8.2-gd +$STD apt-get install -y php8.2-intl +$STD apt-get install -y php8.2-mbstring +msg_ok "Installed PHP8.2" + +msg_info "Installing grocy" +latest=$(curl -s https://api.github.com/repos/grocy/grocy/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +wget -q https://github.com/grocy/grocy/releases/download/v${latest}/grocy_${latest}.zip +$STD unzip grocy_${latest}.zip -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 <<EOF >/etc/apache2/sites-available/grocy.conf +<VirtualHost *:80> + ServerAdmin webmaster@localhost + DocumentRoot /var/www/html/public + ErrorLog /var/log/apache2/error.log +<Directory /var/www/html/public> + Options Indexes FollowSymLinks MultiViews + AllowOverride All + Order allow,deny + allow from all +</Directory> +</VirtualHost> +EOF + +$STD a2dissite 000-default.conf +$STD a2ensite grocy.conf +$STD a2enmod rewrite +systemctl reload apache2 +msg_ok "Installed grocy" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +rm -rf /root/grocy_${latest}.zip +msg_ok "Cleaned" diff --git a/install/headscale-install.sh b/install/headscale-install.sh new file mode 100644 index 00000000..cead9fb7 --- /dev/null +++ b/install/headscale-install.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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/juanfont/headscale/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +msg_info "Installing ${APPLICATION} v${RELEASE}" +wget -q https://github.com/juanfont/headscale/releases/download/v${RELEASE}/headscale_${RELEASE}_linux_amd64.deb +$STD dpkg -i headscale_${RELEASE}_linux_amd64.deb +systemctl enable -q --now headscale +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_ok "Installed ${APPLICATION} v${RELEASE}" + +motd_ssh +customize + +msg_info "Cleaning up" +rm headscale_${RELEASE}_linux_amd64.deb +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/heimdall-dashboard-install.sh b/install/heimdall-dashboard-install.sh new file mode 100644 index 00000000..951bef8b --- /dev/null +++ b/install/heimdall-dashboard-install.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 composer +$STD apt-get install -y php8.2-{bz2,curl,sqlite3,zip,xml} +msg_ok "Installed Dependencies" + +RELEASE=$(curl -sX GET "https://api.github.com/repos/linuxserver/Heimdall/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]') +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_info "Installing Heimdall Dashboard ${RELEASE}" +wget -q https://github.com/linuxserver/Heimdall/archive/${RELEASE}.tar.gz +tar xzf ${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 +cd /opt/Heimdall +cp .env.example .env +$STD php artisan key:generate +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 +systemctl enable -q --now heimdall.service +cd /opt/Heimdall +COMPOSER_ALLOW_SUPERUSER=1 composer dump-autoload &>/dev/null +systemctl restart heimdall.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/hivemq-install.sh b/install/hivemq-install.sh new file mode 100644 index 00000000..5234a49b --- /dev/null +++ b/install/hivemq-install.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +msg_ok "Installed Dependencies" + +msg_info "Installing OpenJDK" +wget -qO- https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor >/etc/apt/trusted.gpg.d/adoptium.gpg +echo 'deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/adoptium.gpg] https://packages.adoptium.net/artifactory/deb bookworm main' >/etc/apt/sources.list.d/adoptium.list +$STD apt-get update +$STD apt-get install -y temurin-17-jre +msg_ok "Installed OpenJDK" + +msg_info "Installing HiveMQ CE" +RELEASE=$(curl -s https://api.github.com/repos/hivemq/hivemq-community-edition/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +wget -q https://github.com/hivemq/hivemq-community-edition/releases/download/${RELEASE}/hivemq-ce-${RELEASE}.zip +unzip -q hivemq-ce-${RELEASE}.zip +mkdir -p /opt/hivemq +mv hivemq-ce-${RELEASE}/* /opt/hivemq +useradd -d /opt/hivemq hivemq +chown -R hivemq:hivemq /opt/hivemq +chmod +x /opt/hivemq/bin/run.sh +cp /opt/hivemq/bin/init-script/hivemq.service /etc/systemd/system/hivemq.service +rm /opt/hivemq/conf/config.xml +mv /opt/hivemq/conf/examples/configuration/config-sample-tcp-and-websockets.xml /opt/hivemq/conf/config.xml +systemctl enable -q --now hivemq +msg_ok "Installed HiveMQ CE" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -rf hivemq-ce-${RELEASE}.zip +rm -rf ../hivemq-ce-${RELEASE} +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/homarr-install.sh b/install/homarr-install.sh new file mode 100644 index 00000000..c1dcf22e --- /dev/null +++ b/install/homarr-install.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 ca-certificates +$STD apt-get install -y gnupg +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js/Yarn" +$STD apt-get update +$STD apt-get install -y nodejs +$STD npm install -g npm@latest +$STD npm install -g yarn +msg_ok "Installed Node.js/Yarn" + +msg_info "Installing Homarr (Patience)" +$STD git clone -b dev https://github.com/ajnart/homarr.git /opt/homarr +cat <<EOF >/opt/homarr/.env +DATABASE_URL="file:./database/db.sqlite" +NEXTAUTH_URL="http://localhost:3000" +NEXTAUTH_SECRET="$(openssl rand -base64 32)" +NEXT_PUBLIC_DISABLE_ANALYTICS="true" +DEFAULT_COLOR_SCHEME="dark" +EOF +cd /opt/homarr +$STD yarn install +$STD yarn build +$STD yarn db:migrate +msg_ok "Installed Homarr" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/homarr.service +[Unit] +Description=Homarr Service +After=network.target + +[Service] +Type=exec +WorkingDirectory=/opt/homarr +EnvironmentFile=-/opt/homarr/.env +ExecStart=/usr/bin/yarn start + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now homarr.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/homeassistant-core-install.sh b/install/homeassistant-core-install.sh new file mode 100644 index 00000000..abaee900 --- /dev/null +++ b/install/homeassistant-core-install.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 {git,curl,sudo,mc,bluez,libffi-dev,libssl-dev,libjpeg-dev,zlib1g-dev,autoconf,build-essential,libopenjp2-7,libturbojpeg0-dev,ffmpeg,liblapack3,liblapack-dev,dbus-broker,libpcap-dev,libavdevice-dev,libavformat-dev,libavcodec-dev,libavutil-dev,libavfilter-dev,libmariadb-dev-compat,libatlas-base-dev,python3-pip,python3.12-venv} +msg_ok "Installed Dependencies" + +msg_info "Installing Home Assistant-Core" +mkdir /srv/homeassistant +cd /srv/homeassistant +python3 -m venv . +source bin/activate +$STD pip install webrtcvad +$STD python3 -m pip install wheel +$STD pip install homeassistant +$STD pip install mysqlclient +$STD pip install psycopg2-binary +mkdir -p /root/.homeassistant +msg_ok "Installed Home Assistant-Core" + +msg_info "Creating Service" +cat <<EOF >/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" +Restart=always +RestartForceExitStatus=100 +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now homeassistant +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/homeassistant-install.sh b/install/homeassistant-install.sh new file mode 100644 index 00000000..088fc4d3 --- /dev/null +++ b/install/homeassistant-install.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 "Updating Python3" +$STD apt-get install -y \ + python3 \ + python3-dev \ + python3-pip \ + python3-venv +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +msg_ok "Updated Python3" + +msg_info "Installing runlike" +$STD pip 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) +echo -e '{\n "log-driver": "journald"\n}' >/etc/docker/daemon.json +$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 9443:9443 \ + --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 ghcr.io/home-assistant/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 \ + ghcr.io/home-assistant/home-assistant:stable +mkdir /root/hass_config +msg_ok "Installed Home Assistant $CORE_LATEST_VERSION" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/homebridge-install.sh b/install/homebridge-install.sh new file mode 100644 index 00000000..76ac86fc --- /dev/null +++ b/install/homebridge-install.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 avahi-daemon +$STD apt-get install -y gnupg2 +msg_ok "Installed Dependencies" + +msg_info "Setting up Homebridge Repository" +curl -sSf https://repo.homebridge.io/KEY.gpg | gpg --dearmor >/etc/apt/trusted.gpg.d/homebridge.gpg +echo 'deb [signed-by=/etc/apt/trusted.gpg.d/homebridge.gpg] https://repo.homebridge.io stable main' >/etc/apt/sources.list.d/homebridge.list +msg_ok "Set up Homebridge Repository" + +msg_info "Installing Homebridge" +$STD apt update +$STD apt-get install -y homebridge +msg_ok "Installed Homebridge" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/homepage-install.sh b/install/homepage-install.sh new file mode 100644 index 00000000..3221324f --- /dev/null +++ b/install/homepage-install.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +$STD npm install -g pnpm +msg_ok "Installed Node.js" + +RELEASE=$(curl -s https://api.github.com/repos/gethomepage/homepage/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +msg_info "Installing Homepage v${RELEASE} (Patience)" +wget -q https://github.com/gethomepage/homepage/archive/refs/tags/v${RELEASE}.tar.gz +$STD tar -xzf v${RELEASE}.tar.gz +rm -rf v${RELEASE}.tar.gz +mkdir -p /opt/homepage/config +mv homepage-${RELEASE}/* /opt/homepage +rm -rf homepage-${RELEASE} +cd /opt/homepage +cp /opt/homepage/src/skeleton/* /opt/homepage/config +$STD pnpm install +$STD pnpm build +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_ok "Installed Homepage v${RELEASE}" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/homepage.service +[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 +EOF +systemctl enable -q --now homepage +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/homer-install.sh b/install/homer-install.sh new file mode 100644 index 00000000..cab3080c --- /dev/null +++ b/install/homer-install.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 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 <<EOF >/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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/hyperhdr-install.sh b/install/hyperhdr-install.sh new file mode 100644 index 00000000..05759f54 --- /dev/null +++ b/install/hyperhdr-install.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +msg_ok "Installed Dependencies" + +msg_info "Installing HyperHDR" +curl -fsSL https://awawa-dev.github.io/hyperhdr.public.apt.gpg.key >/usr/share/keyrings/hyperhdr.public.apt.gpg.key +chmod go+r /usr/share/keyrings/hyperhdr.public.apt.gpg.key +echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hyperhdr.public.apt.gpg.key] https://awawa-dev.github.io $(awk -F= '/VERSION_CODENAME/ {print $2}' /etc/os-release) main" >/etc/apt/sources.list.d/hyperhdr.list +$STD apt-get update +$STD apt-get install -y hyperhdr +msg_ok "Installed HyperHDR" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/hyperhdr.service +[Unit] +Description=HyperHDR Service +After=syslog.target network.target + +[Service] +Restart=on-failure +RestartSec=5 +Type=simple +ExecStart=/usr/bin/hyperhdr + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now hyperhdr +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/hyperion-install.sh b/install/hyperion-install.sh new file mode 100644 index 00000000..3ac24e5a --- /dev/null +++ b/install/hyperion-install.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +$STD apt-get install -y libpython3.11 + +msg_ok "Installed Dependencies" + +msg_info "Installing Hyperion" +wget -qO- https://releases.hyperion-project.org/hyperion.pub.key | gpg --dearmor -o /usr/share/keyrings/hyperion.pub.gpg +echo "deb [signed-by=/usr/share/keyrings/hyperion.pub.gpg] https://apt.releases.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 +customize + +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..a1edf820 --- /dev/null +++ b/install/influxdb-install.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 -qO- https://repos.influxdata.com/influxdata-archive_compat.key | gpg --dearmor > /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg +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 + wget -q https://dl.influxdata.com/chronograf/releases/chronograf_1.10.1_amd64.deb + $STD dpkg -i chronograf_1.10.1_amd64.deb +fi +$STD systemctl enable --now influxdb +msg_ok "Installed InfluxDB" + +read -r -p "Would you like to add Telegraf? <y/N> " prompt +if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + msg_info "Installing Telegraf" + $STD apt-get install -y telegraf + msg_ok "Installed Telegraf" +fi + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/iobroker-install.sh b/install/iobroker-install.sh new file mode 100644 index 00000000..8673c135 --- /dev/null +++ b/install/iobroker-install.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 ca-certificates +$STD apt-get install -y gnupg +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing ioBroker (Patience)" +$STD bash <(curl -fsSL https://iobroker.net/install.sh) +msg_ok "Installed ioBroker" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/iventoy-install.sh b/install/iventoy-install.sh new file mode 100644 index 00000000..ea58b59d --- /dev/null +++ b/install/iventoy-install.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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/ventoy/pxe/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +msg_info "Installing iVentoy v${RELEASE}" +mkdir -p /opt/iventoy/{data,iso} +wget -q https://github.com/ventoy/PXE/releases/download/v${RELEASE}/iventoy-${RELEASE}-linux-free.tar.gz +tar -C /tmp -xzf iventoy*.tar.gz +mv /tmp/iventoy*/* /opt/iventoy/ +rm -rf iventoy*.tar.gz +msg_ok "Installed iVentoy" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/iventoy.service +[Unit] +Description=iVentoy PXE Booter +Documentation=https://www.iventoy.com +Wants=network-online.target +[Service] +Type=forking +Environment=IVENTOY_API_ALL=1 +Environment=IVENTOY_AUTO_RUN=1 +Environment=LIBRARY_PATH=/opt/iventoy/lib/lin64 +Environment=LD_LIBRARY_PATH=/opt/iventoy/lib/lin64 +ExecStart=sh ./iventoy.sh -R start +WorkingDirectory=/opt/iventoy +Restart=on-failure +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now iventoy.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/jackett-install.sh b/install/jackett-install.sh new file mode 100644 index 00000000..8dd59167 --- /dev/null +++ b/install/jackett-install.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_ok "Installed Jackett" + +msg_info "Creating Service" +cat <<EOF >/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 +Environment="DisableRootWarning=true" +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now jackett.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/jellyfin-install.sh b/install/jellyfin-install.sh new file mode 100644 index 00000000..590b9cd2 --- /dev/null +++ b/install/jellyfin-install.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Setting Up Hardware Acceleration" +$STD apt-get -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools} +if [[ "$CTTYPE" == "0" ]]; then + chgrp video /dev/dri + chmod 755 /dev/dri + chmod 660 /dev/dri/* + $STD adduser $(id -u -n) video + $STD adduser $(id -u -n) render +fi +msg_ok "Set Up Hardware Acceleration" + +msg_info "Installing Jellyfin" +VERSION="$( awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release )" +# If the keyring directory is absent, create it +if [[ ! -d /etc/apt/keyrings ]]; then + mkdir -p /etc/apt/keyrings +fi +# Download the repository signing key and install it to the keyring directory +curl -fsSL https://repo.jellyfin.org/jellyfin_team.gpg.key | gpg --dearmor --yes --output /etc/apt/keyrings/jellyfin.gpg +# Install the Deb822 format jellyfin.sources entry +cat <<EOF >/etc/apt/sources.list.d/jellyfin.sources +Types: deb +URIs: https://repo.jellyfin.org/${PCT_OSTYPE} +Suites: ${VERSION} +Components: main +Architectures: amd64 +Signed-By: /etc/apt/keyrings/jellyfin.gpg +EOF +# Install Jellyfin using the metapackage (which will fetch jellyfin-server, jellyfin-web, and jellyfin-ffmpeg5) +$STD apt-get update +$STD apt-get install -y jellyfin +chown -R jellyfin:adm /etc/jellyfin +sleep 10 +systemctl restart jellyfin +if [[ "$CTTYPE" == "0" ]]; then + sed -i -e 's/^ssl-cert:x:104:$/render:x:104:root,jellyfin/' -e 's/^render:x:108:root,jellyfin$/ssl-cert:x:108:/' /etc/group +else + sed -i -e 's/^ssl-cert:x:104:$/render:x:104:jellyfin/' -e 's/^render:x:108:jellyfin$/ssl-cert:x:108:/' /etc/group +fi +msg_ok "Installed Jellyfin" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/jellyseerr-install.sh b/install/jellyseerr-install.sh new file mode 100644 index 00000000..38ae8b22 --- /dev/null +++ b/install/jellyseerr-install.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 ca-certificates +$STD apt-get install -y gnupg +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing Yarn" +$STD npm install -g yarn +msg_ok "Installed Yarn" + +msg_info "Installing Jellyseerr (Patience)" +git clone -q https://github.com/Fallenbagel/jellyseerr.git /opt/jellyseerr +cd /opt/jellyseerr +$STD git checkout main +CYPRESS_INSTALL_BINARY=0 yarn install --frozen-lockfile --network-timeout 1000000 &>/dev/null +$STD yarn install +$STD yarn build +mkdir -p /etc/jellyseerr/ +cat <<EOF >/etc/jellyseerr/jellyseerr.conf +PORT=5055 +# HOST=0.0.0.0 +# JELLYFIN_TYPE=emby +EOF +msg_ok "Installed Jellyseerr" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/jellyseerr.service +[Unit] +Description=jellyseerr Service +After=network.target + +[Service] +EnvironmentFile=/etc/jellyseerr/jellyseerr.conf +Environment=NODE_ENV=production +Type=exec +WorkingDirectory=/opt/jellyseerr +ExecStart=/usr/bin/yarn start + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now jellyseerr.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/k0s-install.sh b/install/k0s-install.sh new file mode 100644 index 00000000..8ad44b52 --- /dev/null +++ b/install/k0s-install.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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? <y/N> " 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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/kavita-install.sh b/install/kavita-install.sh new file mode 100644 index 00000000..b354f171 --- /dev/null +++ b/install/kavita-install.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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) --no-same-owner +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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/keycloak-install.sh b/install/keycloak-install.sh new file mode 100644 index 00000000..536a2bb8 --- /dev/null +++ b/install/keycloak-install.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 ca-certificates-java +$STD apt-get install -y openjdk-17-jre-headless +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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/kubo-install.sh b/install/kubo-install.sh new file mode 100644 index 00000000..390674c1 --- /dev/null +++ b/install/kubo-install.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Co-Author: ulmentflam +# 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 gpg +msg_ok "Installed Dependencies" + +msg_info "Installing IPFS" +RELEASE=$(wget -q https://github.com/ipfs/kubo/releases/latest -O - | grep "title>Release" | cut -d " " -f 4) +$STD wget -q "https://github.com/ipfs/kubo/releases/download/${RELEASE}/kubo_${RELEASE}_linux-amd64.tar.gz" +tar -xzf "kubo_${RELEASE}_linux-amd64.tar.gz" -C /usr/local +$STD ln -s /usr/local/kubo/ipfs /usr/local/bin/ipfs +$STD ipfs init +ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001 +ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080 +LXCIP=$(hostname -I | awk '{print $1}') +ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"http://${LXCIP}:5001\", \"http://localhost:3000\", \"http://127.0.0.1:5001\", \"https://webui.ipfs.io\", \"http://0.0.0.0:5001\"]" +ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]' +echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" +$STD rm "kubo_${RELEASE}_linux-amd64.tar.gz" +msg_ok "Installed IPFS" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/ipfs.service +[Unit] +Description=IPFS Daemon +After=syslog.target network.target + +[Service] +Type=simple +ExecStart=/usr/local/bin/ipfs daemon +Restart=on-failure +[Install] +WantedBy=multi-user.target +EOF +systemctl enable --now -q ipfs.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/lazylibrarian-install.sh b/install/lazylibrarian-install.sh new file mode 100644 index 00000000..ce10041e --- /dev/null +++ b/install/lazylibrarian-install.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck +# Co-Author: MountyMapleSyrup (MountyMapleSyrup) +# 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 Dependencies" +$STD apt-get install -y pip +$STD apt-get install -y python3-irc +$STD pip install jaraco.stream +$STD pip install python-Levenshtein +$STD pip install soupsieve +msg_ok "Installed Python3 Dependencies" + +msg_info "Installing LazyLibrarian" +$STD git clone https://gitlab.com/LazyLibrarian/LazyLibrarian /opt/LazyLibrarian +msg_ok "Installed LazyLibrarian" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/lazylibrarian.service +[Unit] +Description=LazyLibrarian Daemon +After=syslog.target network.target +[Service] +UMask=0002 +Type=simple +ExecStart=/usr/bin/python3 /opt/LazyLibrarian/LazyLibrarian.py +TimeoutStopSec=20 +KillMode=process +Restart=on-failure +[Install] +WantedBy=multi-user.target +EOF +systemctl enable --now -q lazylibrarian +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/lidarr-install.sh b/install/lidarr-install.sh new file mode 100644 index 00000000..0970ef18 --- /dev/null +++ b/install/lidarr-install.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 <<EOF >/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 +customize + +msg_info "Cleaning up" +rm -rf Lidarr.master.*.tar.gz +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/linkwarden-install.sh b/install/linkwarden-install.sh new file mode 100644 index 00000000..378343d5 --- /dev/null +++ b/install/linkwarden-install.sh @@ -0,0 +1,113 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +$STD apt-get install -y postgresql +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js/Yarn" +$STD apt-get update +$STD apt-get install -y nodejs +$STD npm install -g yarn +msg_ok "Installed Node.js/Yarn" + +msg_info "Clone Linkwarden Repository" +$STD git clone https://github.com/linkwarden/linkwarden.git /opt/linkwarden +cd /opt/linkwarden +msg_ok "Cloned Linkwarden Repository" + +msg_info "Setting up PostgreSQL DB" +DB_NAME=linkwardendb +DB_USER=linkwarden +DB_PASS="$(openssl rand -base64 18 | tr -d '/' | cut -c1-13)" +$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" +$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER TEMPLATE template0;" + +echo "" >>~/linkwarden.creds +echo -e "Linkwarden Database User: \e[32m$DB_USER\e[0m" >>~/linkwarden.creds +echo -e "Linkwarden Database Password: \e[32m$DB_PASS\e[0m" >>~/linkwarden.creds +echo -e "Linkwarden Database Name: \e[32m$DB_NAME\e[0m" >>~/linkwarden.creds +msg_ok "Set up PostgreSQL DB" + +read -r -p "Would you like to add Adminer? <y/N> " prompt +if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + msg_info "Installing Adminer" + $STD apt install -y adminer + $STD a2enconf adminer + systemctl reload apache2 + IP=$(hostname -I | awk '{print $1}') + echo "" >>~/linkwarden.creds + echo -e "Adminer Interface: \e[32m$IP/adminer/\e[0m" >>~/linkwarden.creds + echo -e "Adminer System: \e[32mPostgreSQL\e[0m" >>~/linkwarden.creds + echo -e "Adminer Server: \e[32mlocalhost:5432\e[0m" >>~/linkwarden.creds + echo -e "Adminer Username: \e[32m$DB_USER\e[0m" >>~/linkwarden.creds + echo -e "Adminer Password: \e[32m$DB_PASS\e[0m" >>~/linkwarden.creds + echo -e "Adminer Database: \e[32m$DB_NAME\e[0m" >>~/linkwarden.creds + msg_ok "Installed Adminer" +fi + +msg_info "Installing Linkwarden (Patience)" +RELEASE=$(curl -s https://api.github.com/repos/linkwarden/linkwarden/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +$STD yarn +$STD npx playwright install-deps +$STD yarn playwright install +IP=$(hostname -I | awk '{print $1}') +SECRET_KEY="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32)" +env_path="/opt/linkwarden/.env" +echo " +NEXTAUTH_SECRET=${SECRET_KEY} +NEXTAUTH_URL=http://${IP}:3000 +DATABASE_URL=postgresql://${DB_USER}:${DB_PASS}@localhost:5432/${DB_NAME} +" >$env_path +$STD yarn build +$STD yarn prisma migrate deploy +msg_ok "Installed Linkwarden" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/linkwarden.service +[Unit] +Description=Linkwarden Service +After=network.target + +[Service] +Type=exec +WorkingDirectory=/opt/linkwarden +ExecStart=/usr/bin/yarn start + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now linkwarden.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/lldap-install.sh b/install/lldap-install.sh new file mode 100644 index 00000000..0bdebe94 --- /dev/null +++ b/install/lldap-install.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Co-Author: remz1337 +# 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 gpg +msg_ok "Installed Dependencies" + +msg_info "Installing lldap" +source /etc/os-release +os=$ID +if [ "$os" == "ubuntu" ]; then + DISTRO="xUbuntu" +else + DISTRO="${os^}" +fi +echo "deb http://download.opensuse.org/repositories/home:/Masgalor:/LLDAP/${DISTRO}_${VERSION_ID}/ /" >/etc/apt/sources.list.d/home:Masgalor:LLDAP.list +curl -fsSL https://download.opensuse.org/repositories/home:Masgalor:LLDAP/${DISTRO}_${VERSION_ID}/Release.key | gpg --dearmor >/etc/apt/trusted.gpg.d/home_Masgalor_LLDAP.gpg +$STD apt update +$STD apt install -y lldap +systemctl enable -q --now lldap +msg_ok "Installed lldap" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/mafl-install.sh b/install/mafl-install.sh new file mode 100644 index 00000000..da27b266 --- /dev/null +++ b/install/mafl-install.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 make +$STD apt-get install -y g++ +$STD apt-get install -y gcc +$STD apt-get install -y ca-certificates +$STD apt-get install -y gnupg +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +$STD npm install -g npm@latest +$STD npm install -g yarn +msg_ok "Installed Node.js" + +RELEASE=$(curl -s https://api.github.com/repos/hywax/mafl/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +msg_info "Installing Mafl v${RELEASE}" +wget -q https://github.com/hywax/mafl/archive/refs/tags/v${RELEASE}.tar.gz +tar -xzf v${RELEASE}.tar.gz +mkdir -p /opt/mafl/data +wget -q -O /opt/mafl/data/config.yml https://raw.githubusercontent.com/hywax/mafl/main/.example/config.yml +mv mafl-${RELEASE}/* /opt/mafl +rm -rf mafl-${RELEASE} +cd /opt/mafl +export NUXT_TELEMETRY_DISABLED=true +$STD yarn install +$STD yarn build +msg_ok "Installed Mafl v${RELEASE}" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/mafl.service +[Unit] +Description=Mafl +After=network.target +StartLimitIntervalSec=0 + +[Service] +Type=simple +Restart=always +RestartSec=1 +User=root +WorkingDirectory=/opt/mafl/ +ExecStart=yarn preview + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now mafl +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/setup/magicmirror-install.sh b/install/magicmirror-install.sh similarity index 64% rename from setup/magicmirror-install.sh rename to install/magicmirror-install.sh index 3513f225..5ba0dff2 100644 --- a/setup/magicmirror-install.sh +++ b/install/magicmirror-install.sh @@ -1,87 +1,47 @@ #!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -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 -} +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -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" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y git &>/dev/null +$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 ca-certificates +$STD apt-get install -y gnupg msg_ok "Installed Dependencies" msg_info "Setting up Node.js Repository" -curl -fsSL https://deb.nodesource.com/setup_18.x | bash - &>/dev/null +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list msg_ok "Set up Node.js Repository" msg_info "Installing Node.js" -apt-get install -y nodejs &>/dev/null +$STD apt-get update +$STD apt-get install -y nodejs msg_ok "Installed Node.js" msg_info "Setting up MagicMirror Repository" -git clone https://github.com/MichMich/MagicMirror /opt/magicmirror &>/dev/null +$STD git clone https://github.com/MichMich/MagicMirror /opt/magicmirror msg_ok "Set up MagicMirror Repository" msg_info "Installing MagicMirror" -cd /opt/magicmirror &>/dev/null -npm install --only=prod --omit=dev &>/dev/null +cd /opt/magicmirror +$STD npm install --only=prod --omit=dev -cat <<EOF > /opt/magicmirror/config/config.js +cat <<EOF >/opt/magicmirror/config/config.js let config = { address: "0.0.0.0", port: 8080, @@ -188,29 +148,14 @@ WorkingDirectory=/opt/magicmirror/ ExecStart=/usr/bin/node serveronly [Install] -WantedBy=multi-user.target" > $service_path -systemctl enable --now magicmirror &>/dev/null +WantedBy=multi-user.target" >$service_path +$STD systemctl enable --now magicmirror msg_ok "Created Service" -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -chmod -x /etc/update-motd.d/* -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - +motd_ssh +customize + msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* +$STD apt-get -y autoremove +$STD apt-get -y autoclean msg_ok "Cleaned" diff --git a/install/mariadb-install.sh b/install/mariadb-install.sh new file mode 100644 index 00000000..46ecf9df --- /dev/null +++ b/install/mariadb-install.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +sed -i 's/^# *\(port *=.*\)/\1/' /etc/mysql/my.cnf +sed -i 's/^bind-address/#bind-address/g' /etc/mysql/mariadb.conf.d/50-server.cnf +msg_ok "Installed MariaDB" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/matterbridge-install.sh b/install/matterbridge-install.sh new file mode 100644 index 00000000..2d895e25 --- /dev/null +++ b/install/matterbridge-install.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck +# Co-Author: MickLesk (Canbiz) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +# Source: https://github.com/Luligu/matterbridge/ + +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 gpg +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Install Matterbridge" +mkdir -p /root/Matterbridge +$STD npm install -g matterbridge +msg_ok "Installed Matterbridge" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/matterbridge.service +[Unit] +Description=matterbridge +After=network-online.target + +[Service] +Type=simple +ExecStart=matterbridge -bridge -service +WorkingDirectory=/root/Matterbridge +StandardOutput=inherit +StandardError=inherit +Restart=always +RestartSec=10s +TimeoutStopSec=30s + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now matterbridge.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/mediamtx-install.sh b/install/mediamtx-install.sh new file mode 100644 index 00000000..66db3047 --- /dev/null +++ b/install/mediamtx-install.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 ffmpeg +msg_ok "Installed Dependencies" + +msg_info "Installing MediaMTX" +RELEASE=$(curl -s https://api.github.com/repos/bluenviron/mediamtx/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +mkdir -p /opt/mediamtx +cd /opt/mediamtx +wget -q https://github.com/bluenviron/mediamtx/releases/download/${RELEASE}/mediamtx_${RELEASE}_linux_amd64.tar.gz +tar xzf mediamtx_${RELEASE}_linux_amd64.tar.gz +rm -rf mediamtx_${RELEASE}_linux_amd64.tar.gz +msg_ok "Installed MediaMTX" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/mediamtx.service +[Unit] +Description=MediaMTX +After=syslog.target network-online.target + +[Service] +ExecStart=/opt/mediamtx/./mediamtx +WorkingDirectory=/opt/mediamtx +Restart=always + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now mediamtx.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/medusa-install.sh b/install/medusa-install.sh new file mode 100644 index 00000000..34bed0af --- /dev/null +++ b/install/medusa-install.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +$STD apt-get install -y git-core +$STD apt-get install -y mediainfo +cat <<EOF >/etc/apt/sources.list.d/non-free.list +deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware +EOF +$STD apt-get update +$STD apt-get install -y unrar +rm /etc/apt/sources.list.d/non-free.list +msg_ok "Installed Dependencies" + +msg_info "Installing Medusa" +$STD git clone https://github.com/pymedusa/Medusa.git /opt/medusa +msg_ok "Installed Medusa" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/medusa.service +[Unit] +Description=Medusa Daemon +After=network.target + +[Service] +Type=simple +ExecStart=/usr/bin/python3 /opt/medusa/start.py -q --nolaunch --datadir=/opt/medusa +TimeoutStopSec=25 +KillMode=process +Restart=on-failure + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now medusa.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/meshcentral-install.sh b/install/meshcentral-install.sh new file mode 100644 index 00000000..c482f9a2 --- /dev/null +++ b/install/meshcentral-install.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 ca-certificates +$STD apt-get install -y gnupg +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/metube-install.sh b/install/metube-install.sh new file mode 100644 index 00000000..726f3f77 --- /dev/null +++ b/install/metube-install.sh @@ -0,0 +1,98 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck +# Co-Author: MickLesk (Canbiz) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +# Source: https://github.com/alexta69/metube + +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 --no-install-recommends \ + build-essential \ + curl \ + aria2 \ + coreutils \ + gcc \ + g++ \ + musl-dev \ + sudo \ + ffmpeg \ + git \ + make \ + gnupg \ + ca-certificates \ + mc +msg_ok "Installed Dependencies" + +msg_info "Installing Python3" +$STD apt-get install -y \ + python3 \ + python3-dev \ + python3-pip \ + python3-venv +msg_ok "Installed Python3" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing MeTube" +$STD git clone https://github.com/alexta69/metube /opt/metube +cd /opt/metube/ui +$STD npm install +$STD node_modules/.bin/ng build +cd /opt/metube +$STD pip3 install pipenv +$STD pipenv install +mkdir -p /opt/metube_downloads /opt/metube_downloads/.metube /opt/metube_downloads/music /opt/metube_downloads/videos +cat <<EOF >/opt/metube/.env +DOWNLOAD_DIR=/opt/metube_downloads +STATE_DIR=/opt/metube_downloads/.metube +TEMP_DIR=/opt/metube_downloads +YTDL_OPTIONS={"trim_file_name":10} +EOF +msg_ok "Installed MeTube" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/metube.service +[Unit] +Description=Metube - YouTube Downloader +After=network.target + +[Service] +Type=simple +WorkingDirectory=/opt/metube +EnvironmentFile=/opt/metube/.env +ExecStart=/usr/local/bin/pipenv run python3 app/main.py +Restart=always +User=root + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now metube.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/mongodb-install.sh b/install/mongodb-install.sh new file mode 100644 index 00000000..6839ae51 --- /dev/null +++ b/install/mongodb-install.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gnupg +$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 MongoDB" +wget -qO- https://www.mongodb.org/static/pgp/server-7.0.asc | gpg --dearmor >/usr/share/keyrings/mongodb-server-7.0.gpg +echo "deb [signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg] http://repo.mongodb.org/apt/debian $(grep '^VERSION_CODENAME=' /etc/os-release | cut -d'=' -f2)/mongodb-org/7.0 main" >/etc/apt/sources.list.d/mongodb-org-7.0.list +$STD apt-get update +$STD apt-get install -y mongodb-org +sed -i 's/bindIp: 127.0.0.1/bindIp: 0.0.0.0/' /etc/mongod.conf +systemctl enable -q --now mongod.service +msg_ok "Installed MongoDB" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/motioneye-install.sh b/install/motioneye-install.sh new file mode 100644 index 00000000..99e24413 --- /dev/null +++ b/install/motioneye-install.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 cifs-utils +msg_ok "Installed Dependencies" + +msg_info "Updating Python3" +$STD apt-get install -y \ + python3 \ + python3-dev \ + python3-pip +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +msg_ok "Updated Python3" + +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 MotionEye" +$STD apt-get update +$STD pip install git+https://github.com/motioneye-project/motioneye.git@dev +mkdir -p /etc/motioneye +chown -R root:root /etc/motioneye +chmod -R 777 /etc/motioneye +wget -qO /etc/motioneye/motioneye.conf https://raw.githubusercontent.com/motioneye-project/motioneye/dev/motioneye/extra/motioneye.conf.sample +mkdir -p /var/lib/motioneye +msg_ok "Installed MotionEye" + +msg_info "Creating Service" +wget -qO /etc/systemd/system/motioneye.service https://raw.githubusercontent.com/motioneye-project/motioneye/dev/motioneye/extra/motioneye.systemd +systemctl enable -q --now motioneye +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/mqtt-install.sh b/install/mqtt-install.sh new file mode 100644 index 00000000..61a01fbe --- /dev/null +++ b/install/mqtt-install.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +msg_ok "Installed Dependencies" + +msg_info "Installing Mosquitto MQTT Broker" +$STD apt-get -y install mosquitto +$STD apt-get -y install mosquitto-clients +cat <<EOF >/etc/mosquitto/conf.d/default.conf +allow_anonymous false +persistence true +password_file /etc/mosquitto/passwd +listener 1883 +EOF +msg_ok "Installed Mosquitto MQTT Broker" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/myspeed-install.sh b/install/myspeed-install.sh new file mode 100644 index 00000000..45ef62a6 --- /dev/null +++ b/install/myspeed-install.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck +# Co-Author: MickLesk (Canbiz) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +# Source: https://github.com/gnmyt/myspeed + +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 \ + sudo \ + make \ + gpg \ + ca-certificates \ + mc +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing MySpeed" +RELEASE=$(wget -q https://github.com/gnmyt/myspeed/releases/latest -O - | grep "title>Release" | cut -d " " -f 5) +cd /opt +wget -q https://github.com/gnmyt/myspeed/releases/download/v$RELEASE/MySpeed-$RELEASE.zip +unzip -q MySpeed-$RELEASE.zip -d myspeed +cd myspeed +$STD npm install +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_ok "Installed MySpeed" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/myspeed.service +[Unit] +Description=MySpeed +After=network.target + +[Service] +Type=simple +ExecStart=/usr/bin/node server +Restart=always +User=root +Environment=NODE_ENV=production +WorkingDirectory=/opt/myspeed + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now myspeed.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +rm -rf /opt/MySpeed-$RELEASE.zip +$STD apt-get -y autoclean +msg_ok "Cleaned" \ No newline at end of file diff --git a/install/n8n-install.sh b/install/n8n-install.sh new file mode 100644 index 00000000..811c166d --- /dev/null +++ b/install/n8n-install.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 ca-certificates +$STD apt-get install -y gnupg +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing n8n (Patience)" +$STD npm install --global patch-package +$STD npm install --global n8n +msg_ok "Installed n8n" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/n8n.service +[Unit] +Description=n8n + +[Service] +Type=simple +Environment="N8N_SECURE_COOKIE=false" +ExecStart=n8n start +[Install] +WantedBy=multi-user.target +EOF +$STD systemctl enable --now n8n +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/navidrome-install.sh b/install/navidrome-install.sh new file mode 100644 index 00000000..42235dc8 --- /dev/null +++ b/install/navidrome-install.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +wget -q https://github.com/navidrome/navidrome/releases/download/v${RELEASE}/navidrome_${RELEASE}_linux_amd64.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 <<EOF >/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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y 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..ca1871dd --- /dev/null +++ b/install/nextcloudpi-install.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 apt-get install -y systemd-resolved +systemctl enable -q --now systemd-resolved +cat <<'EOF' >/etc/systemd/resolved.conf +[Resolve] +DNS=8.8.8.8 +FallbackDNS=8.8.4.4 +EOF +systemctl restart systemd-resolved +$STD bash <(curl -fsSL https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/install.sh) +systemctl disable -q --now systemd-resolved +$STD apt-get remove -y systemd-resolved +msg_ok "Installed NextCloudPi" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/nginxproxymanager-install.sh b/install/nginxproxymanager-install.sh new file mode 100644 index 00000000..4314e293 --- /dev/null +++ b/install/nginxproxymanager-install.sh @@ -0,0 +1,208 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 update +$STD apt-get -y install \ + sudo \ + mc \ + curl \ + gnupg \ + make \ + gcc \ + g++ \ + ca-certificates \ + apache2-utils \ + logrotate \ + build-essential \ + git +msg_ok "Installed Dependencies" + +msg_info "Installing Python Dependencies" +$STD apt-get install -y \ + python3 \ + python3-dev \ + python3-pip \ + python3-venv \ + python3-cffi \ + python3-certbot \ + python3-certbot-dns-cloudflare +$STD pip3 install certbot-dns-multi +$STD python3 -m venv /opt/certbot/ +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +msg_ok "Installed Python Dependencies" + +VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)" + +msg_info "Installing Openresty" +wget -qO - https://openresty.org/package/pubkey.gpg | gpg --dearmor -o /etc/apt/trusted.gpg.d/openresty-archive-keyring.gpg +echo -e "deb http://openresty.org/package/debian bullseye openresty" >/etc/apt/sources.list.d/openresty.list +$STD apt-get update +$STD apt-get -y install openresty +msg_ok "Installed Openresty" + +msg_info "Installing Node.js" +$STD bash <(curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh) +source ~/.bashrc +$STD nvm install 16.20.2 +ln -sf /root/.nvm/versions/node/v16.20.2/bin/node /usr/bin/node +msg_ok "Installed Node.js" + +msg_info "Installing pnpm" +$STD npm install -g pnpm@8.15 +msg_ok "Installed pnpm" + +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) }') + +read -r -p "Would you like to install an older version (v2.10.4)? <y/N> " prompt +if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then + msg_info "Downloading Nginx Proxy Manager v2.10.4" + wget -q https://codeload.github.com/NginxProxyManager/nginx-proxy-manager/tar.gz/v2.10.4 -O - | tar -xz + cd ./nginx-proxy-manager-2.10.4 + msg_ok "Downloaded Nginx Proxy Manager v2.10.4" +else + msg_info "Downloading Nginx Proxy Manager v${RELEASE}" + wget -q https://codeload.github.com/NginxProxyManager/nginx-proxy-manager/tar.gz/v${RELEASE} -O - | tar -xz + cd ./nginx-proxy-manager-${RELEASE} + msg_ok "Downloaded Nginx Proxy Manager v${RELEASE}" +fi +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 +if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then + sed -i "s|\"version\": \"0.0.0\"|\"version\": \"2.10.4\"|" backend/package.json + sed -i "s|\"version\": \"0.0.0\"|\"version\": \"2.10.4\"|" frontend/package.json +else + sed -i "s|\"version\": \"0.0.0\"|\"version\": \"$RELEASE\"|" backend/package.json + sed -i "s|\"version\": \"0.0.0\"|\"version\": \"$RELEASE\"|" frontend/package.json +fi +sed -i 's|"fork-me": ".*"|"fork-me": "Proxmox VE Helper-Scripts"|' frontend/js/i18n/messages.json +sed -i "s|https://github.com.*source=nginx-proxy-manager|https://helper-scripts.com|g" frontend/js/app/ui/footer/main.ejs +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 + 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 "Set up Enviroment" + +msg_info "Building Frontend" +cd ./frontend +$STD pnpm install +$STD pnpm upgrade +$STD pnpm run build +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 +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 +$STD pnpm install +msg_ok "Initialized Backend" + +msg_info "Creating Service" +cat <<'EOF' >/lib/systemd/system/npm.service +[Unit] +Description=Nginx Proxy Manager +After=network.target +Wants=openresty.service + +[Service] +Type=simple +Environment=NODE_ENV=production +ExecStartPre=-mkdir -p /tmp/nginx/body /data/letsencrypt-acme-challenge +ExecStart=/usr/bin/node index.js --abort_on_uncaught_exception --max_old_space_size=250 +WorkingDirectory=/app +Restart=on-failure + +[Install] +WantedBy=multi-user.target +EOF +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Starting Services" +sed -i 's/user npm/user root/g; s/^pid/#pid/g' /usr/local/openresty/nginx/conf/nginx.conf +sed -r -i 's/^([[:space:]]*)su npm npm/\1#su npm npm/g;' /etc/logrotate.d/nginx-proxy-manager +sed -i 's/include-system-site-packages = false/include-system-site-packages = true/g' /opt/certbot/pyvenv.cfg +systemctl enable -q --now openresty +systemctl enable -q --now npm +msg_ok "Started Services" + +msg_info "Cleaning up" +rm -rf ../nginx-proxy-manager-* +systemctl restart openresty +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/nocodb-install.sh b/install/nocodb-install.sh new file mode 100644 index 00000000..612d7983 --- /dev/null +++ b/install/nocodb-install.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 NocoDB" +mkdir -p /opt/nocodb +cd /opt/nocodb +curl -s http://get.nocodb.com/linux-x64 -o nocodb -L +chmod +x nocodb +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=/opt/nocodb/./nocodb + +[Install] +WantedBy=multi-user.target" >$service_path +systemctl enable -q --now nocodb.service &>/dev/null +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/node-red-install.sh b/install/node-red-install.sh new file mode 100644 index 00000000..8ca280be --- /dev/null +++ b/install/node-red-install.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 ca-certificates +$STD apt-get install -y gnupg +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing Node-Red" +$STD npm install -g --unsafe-perm node-red +echo "journalctl -f -n 100 -u nodered -o cat" >/usr/bin/node-red-log +chmod +x /usr/bin/node-red-log +echo "systemctl stop nodered" >/usr/bin/node-red-stop +chmod +x /usr/bin/node-red-stop +echo "systemctl start nodered" >/usr/bin/node-red-start +chmod +x /usr/bin/node-red-start +echo "systemctl restart nodered" >/usr/bin/node-red-restart +chmod +x /usr/bin/node-red-restart +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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/notifiarr-install.sh b/install/notifiarr-install.sh new file mode 100644 index 00000000..a90217c0 --- /dev/null +++ b/install/notifiarr-install.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +msg_ok "Installed Dependencies" + +msg_info "Installing Notifiarr" +$STD groupadd notifiarr +$STD useradd -g notifiarr notifiarr +wget -qO- https://packagecloud.io/golift/pkgs/gpgkey | gpg --dearmor >/usr/share/keyrings/golift-archive-keyring.gpg +echo "deb [signed-by=/usr/share/keyrings/golift-archive-keyring.gpg] https://packagecloud.io/golift/pkgs/ubuntu focal main" >/etc/apt/sources.list.d/golift.list +$STD apt-get update +$STD apt-get install -y notifiarr +msg_ok "Installed Notifiarr" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/ntfy-install.sh b/install/ntfy-install.sh new file mode 100644 index 00000000..578e8966 --- /dev/null +++ b/install/ntfy-install.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +$STD apt-get install -y apt-transport-https +msg_ok "Installed Dependencies" + +msg_info "Installing ntfy" +mkdir -p /etc/apt/keyrings +curl -fsSL https://archive.heckel.io/apt/pubkey.txt | gpg --dearmor -o /etc/apt/keyrings/archive.heckel.io.gpg +echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/archive.heckel.io.gpg] https://archive.heckel.io/apt debian main" >/etc/apt/sources.list.d/archive.heckel.io.list +$STD apt-get update +$STD apt-get install -y ntfy +systemctl enable -q --now ntfy +msg_ok "Installed ntfy" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/octoprint-install.sh b/install/octoprint-install.sh new file mode 100644 index 00000000..878762fa --- /dev/null +++ b/install/octoprint-install.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 libyaml-dev +$STD apt-get install -y build-essential +msg_ok "Installed Dependencies" + +msg_info "Updating Python3" +$STD apt-get install -y \ + python3 \ + python3-dev \ + python3-pip \ + python3-venv + +$STD apt-get install -y python3-setuptools +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +msg_ok "Updated Python3" + +msg_info "Creating user octoprint" +useradd -m -s /bin/bash -p $(openssl passwd -1 octoprint) octoprint +usermod -aG sudo,tty,dialout octoprint +chown -R octoprint:octoprint /opt +echo "octoprint ALL=NOPASSWD: $(command -v systemctl) restart octoprint, $(command -v reboot), $(command -v poweroff)" > /etc/sudoers.d/octoprint +msg_ok "Created user octoprint" + +msg_info "Installing OctoPrint" +$STD sudo -u octoprint bash << EOF +mkdir /opt/octoprint +cd /opt/octoprint +python3 -m venv . +source bin/activate +pip install --upgrade pip +pip install wheel +pip install octoprint +EOF +msg_ok "Installed OctoPrint" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/octoprint.service +[Unit] +Description=The snappy web interface for your 3D printer +After=network-online.target +Wants=network-online.target + +[Service] +Environment="LC_ALL=C.UTF-8" +Environment="LANG=C.UTF-8" +Type=exec +User=octoprint +ExecStart=/opt/octoprint/bin/octoprint serve + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now octoprint.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/omada-install.sh b/install/omada-install.sh new file mode 100644 index 00000000..8bd0f1f9 --- /dev/null +++ b/install/omada-install.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 jsvc +msg_ok "Installed Dependencies" + +msg_info "Installing Azul Zulu" +wget -qO /etc/apt/trusted.gpg.d/zulu-repo.asc "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xB1998361219BD9C9" +wget -q https://cdn.azul.com/zulu/bin/zulu-repo_1.0.0-3_all.deb +$STD dpkg -i zulu-repo_1.0.0-3_all.deb +$STD apt-get update +$STD apt-get -y install zulu8-jdk +msg_ok "Installed Azul Zulu" + +msg_info "Installing MongoDB" +libssl=$(curl -fsSL "http://security.ubuntu.com/ubuntu/pool/main/o/openssl/" | grep -o 'libssl1\.1_1\.1\.1f-1ubuntu2\.2[^"]*amd64\.deb' | head -n1) +wget -qL http://security.ubuntu.com/ubuntu/pool/main/o/openssl/$libssl +$STD dpkg -i $libssl +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 MongoDB" + +latest_url=$(curl -fsSL "https://www.tp-link.com/en/support/download/omada-software-controller/" | grep -o 'https://.*x64.deb' | head -n1) +latest_version=$(basename "$latest_url") + +msg_info "Installing Omada Controller" +wget -qL ${latest_url} +$STD dpkg -i ${latest_version} +msg_ok "Installed Omada Controller" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -rf ${latest_version} mongodb-org-server_3.6.23_amd64.deb zulu-repo_1.0.0-3_all.deb $libssl +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/setup/ombi-install.sh b/install/ombi-install.sh similarity index 100% rename from setup/ombi-install.sh rename to install/ombi-install.sh diff --git a/install/omv-install.sh b/install/omv-install.sh new file mode 100644 index 00000000..2fb700ae --- /dev/null +++ b/install/omv-install.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +msg_ok "Installed Dependencies" + +msg_info "Installing OpenMediaVault (Patience)" +wget -qO- https://packages.openmediavault.org/public/archive.key | gpg --dearmor >"/etc/apt/trusted.gpg.d/openmediavault-archive-keyring.gpg" + +cat <<EOF >/etc/apt/sources.list.d/openmediavault.list +deb [signed-by=/etc/apt/trusted.gpg.d/openmediavault-archive-keyring.gpg] http://packages.openmediavault.org/public sandworm main +EOF + +export LANG=C.UTF-8 +export DEBIAN_FRONTEND=noninteractive +export APT_LISTCHANGES_FRONTEND=none +$STD apt-get update +apt-get -y --auto-remove --show-upgraded --allow-downgrades --allow-change-held-packages --no-install-recommends --option DPkg::Options::="--force-confdef" --option DPkg::Options::="--force-confold" install openmediavault-keyring openmediavault &>/dev/null +omv-confdbadm populate &>/dev/null +msg_ok "Installed OpenMediaVault" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/openhab-install.sh b/install/openhab-install.sh new file mode 100644 index 00000000..40661c6c --- /dev/null +++ b/install/openhab-install.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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" +wget -qO /etc/apt/trusted.gpg.d/zulu-repo.asc "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xB1998361219BD9C9" +wget -q https://cdn.azul.com/zulu/bin/zulu-repo_1.0.0-3_all.deb +$STD dpkg -i zulu-repo_1.0.0-3_all.deb +$STD apt-get update +$STD apt-get -y install zulu17-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 +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 +systemctl enable -q --now openhab.service +msg_ok "Installed openHAB" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/openobserve-install.sh b/install/openobserve-install.sh new file mode 100644 index 00000000..7fff763e --- /dev/null +++ b/install/openobserve-install.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 OpenObserve" +mkdir -p /opt/openobserve/data +LATEST=$(curl -sL https://api.github.com/repos/openobserve/openobserve/releases/latest | grep '"tag_name":' | cut -d'"' -f4) +$STD tar zxvf <(curl -fsSL https://github.com/openobserve/openobserve/releases/download/$LATEST/openobserve-${LATEST}-linux-amd64.tar.gz) -C /opt/openobserve + +cat <<EOF >/opt/openobserve/data/.env +ZO_ROOT_USER_EMAIL = "admin@example.com" +ZO_ROOT_USER_PASSWORD = "$(openssl rand -base64 18 | cut -c1-13)" +ZO_DATA_DIR = "/opt/openobserve/data" +ZO_HTTP_PORT = "5080" +EOF +msg_ok "Installed OpenObserve" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/openobserve.service +[Unit] +Description=OpenObserve +After=network.target + +[Service] +Type=simple +EnvironmentFile=/opt/openobserve/data/.env +ExecStart=/opt/openobserve/openobserve +ExecStop=killall -QUIT openobserve +Restart=on-failure + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now openobserve +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/overseerr-install.sh b/install/overseerr-install.sh new file mode 100644 index 00000000..dd65cd67 --- /dev/null +++ b/install/overseerr-install.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 ca-certificates +$STD apt-get install -y gnupg +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing Yarn" +$STD npm install -g yarn +msg_ok "Installed Yarn" + +msg_info "Installing Overseerr (Patience)" +git clone -q https://github.com/sct/overseerr.git /opt/overseerr +cd /opt/overseerr +$STD yarn install +$STD yarn build +msg_ok "Installed Overseerr" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/overseerr.service +[Unit] +Description=Overseerr Service +After=network.target + +[Service] +Type=exec +WorkingDirectory=/opt/overseerr +ExecStart=/usr/bin/yarn start + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now overseerr.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/owncast-install.sh b/install/owncast-install.sh new file mode 100644 index 00000000..ca6f30c3 --- /dev/null +++ b/install/owncast-install.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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" + +msg_info "Installing Owncast" +mkdir /opt/owncast +cd /opt/owncast +wget -q $(curl -s https://api.github.com/repos/owncast/owncast/releases/latest | grep download | grep linux-64bit | cut -d\" -f4) +$STD unzip owncast*.zip +rm owncast*.zip +msg_ok "Installed Owncast" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/owncast.service +[Unit] +Description=Owncast +After=syslog.target network-online.target + +[Service] +ExecStart=/opt/owncast/./owncast +WorkingDirectory=/opt/owncast +Restart=always + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now owncast.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/pairdrop-install.sh b/install/pairdrop-install.sh new file mode 100644 index 00000000..75070cd7 --- /dev/null +++ b/install/pairdrop-install.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing PairDrop" +git clone -q https://github.com/schlagmichdoch/PairDrop.git /opt/pairdrop +cd /opt/pairdrop +$STD npm install +msg_ok "Installed PairDrop" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/pairdrop.service +[Unit] +Description=PairDrop Service +After=network.target + +[Service] +ExecStart=npm start +WorkingDirectory=/opt/pairdrop +Restart=always + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now pairdrop.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/paperless-ngx-install.sh b/install/paperless-ngx-install.sh new file mode 100644 index 00000000..7edabf2b --- /dev/null +++ b/install/paperless-ngx-install.sh @@ -0,0 +1,226 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 --no-install-recommends \ + redis \ + postgresql \ + build-essential \ + imagemagick \ + fonts-liberation \ + optipng \ + gnupg \ + libpq-dev \ + libmagic-dev \ + mime-support \ + libzbar0 \ + poppler-utils \ + default-libmysqlclient-dev \ + automake \ + libtool \ + pkg-config \ + git \ + curl \ + libtiff-dev \ + libpng-dev \ + libleptonica-dev \ + sudo \ + mc +msg_ok "Installed Dependencies" + +msg_info "Installing Python3 Dependencies" +$STD apt-get install -y --no-install-recommends \ + python3 \ + python3-pip \ + python3-dev \ + python3-setuptools \ + python3-wheel +msg_ok "Installed Python3 Dependencies" + +msg_info "Installing OCR Dependencies (Patience)" +$STD apt-get install -y --no-install-recommends \ + unpaper \ + ghostscript \ + icc-profiles-free \ + qpdf \ + liblept5 \ + libxml2 \ + pngquant \ + zlib1g \ + tesseract-ocr \ + tesseract-ocr-eng +msg_ok "Installed OCR Dependencies" + +msg_info "Installing JBIG2" +$STD git clone https://github.com/agl/jbig2enc /opt/jbig2enc +cd /opt/jbig2enc +$STD bash ./autogen.sh +$STD bash ./configure +$STD make +$STD make install +rm -rf /opt/jbig2enc +msg_ok "Installed JBIG2" + +msg_info "Installing Paperless-ngx (Patience)" +Paperlessngx=$(wget -q https://github.com/paperless-ngx/paperless-ngx/releases/latest -O - | grep "title>Release" | cut -d " " -f 5) +cd /opt +$STD wget https://github.com/paperless-ngx/paperless-ngx/releases/download/$Paperlessngx/paperless-ngx-$Paperlessngx.tar.xz +$STD tar -xf paperless-ngx-$Paperlessngx.tar.xz -C /opt/ +mv paperless-ngx paperless +rm paperless-ngx-$Paperlessngx.tar.xz +cd /opt/paperless +$STD pip install --upgrade pip +$STD pip install -r requirements.txt +curl -s -o /opt/paperless/paperless.conf https://raw.githubusercontent.com/paperless-ngx/paperless-ngx/main/paperless.conf.example +mkdir -p {consume,data,media,static} +sed -i -e 's|#PAPERLESS_REDIS=redis://localhost:6379|PAPERLESS_REDIS=redis://localhost:6379|' /opt/paperless/paperless.conf +sed -i -e "s|#PAPERLESS_CONSUMPTION_DIR=../consume|PAPERLESS_CONSUMPTION_DIR=/opt/paperless/consume|" /opt/paperless/paperless.conf +sed -i -e "s|#PAPERLESS_DATA_DIR=../data|PAPERLESS_DATA_DIR=/opt/paperless/data|" /opt/paperless/paperless.conf +sed -i -e "s|#PAPERLESS_MEDIA_ROOT=../media|PAPERLESS_MEDIA_ROOT=/opt/paperless/media|" /opt/paperless/paperless.conf +sed -i -e "s|#PAPERLESS_STATICDIR=../static|PAPERLESS_STATICDIR=/opt/paperless/static|" /opt/paperless/paperless.conf +echo "${Paperlessngx}" >/opt/${APPLICATION}_version.txt +msg_ok "Installed Paperless-ngx" + +msg_info "Installing Natural Language Toolkit (Patience)" +$STD python3 -m nltk.downloader -d /usr/share/nltk_data all +msg_ok "Installed Natural Language Toolkit" + +msg_info "Setting up PostgreSQL database" +DB_NAME=paperlessdb +DB_USER=paperless +DB_PASS="$(openssl rand -base64 18 | cut -c1-13)" +SECRET_KEY="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32)" +$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" +$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;" +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';" +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';" +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC'" +echo "" >>~/paperless.creds +echo -e "Paperless-ngx Database User: \e[32m$DB_USER\e[0m" >>~/paperless.creds +echo -e "Paperless-ngx Database Password: \e[32m$DB_PASS\e[0m" >>~/paperless.creds +echo -e "Paperless-ngx Database Name: \e[32m$DB_NAME\e[0m" >>~/paperless.creds +sed -i -e 's|#PAPERLESS_DBHOST=localhost|PAPERLESS_DBHOST=localhost|' /opt/paperless/paperless.conf +sed -i -e 's|#PAPERLESS_DBPORT=5432|PAPERLESS_DBPORT=5432|' /opt/paperless/paperless.conf +sed -i -e "s|#PAPERLESS_DBNAME=paperless|PAPERLESS_DBNAME=$DB_NAME|" /opt/paperless/paperless.conf +sed -i -e "s|#PAPERLESS_DBUSER=paperless|PAPERLESS_DBUSER=$DB_USER|" /opt/paperless/paperless.conf +sed -i -e "s|#PAPERLESS_DBPASS=paperless|PAPERLESS_DBPASS=$DB_PASS|" /opt/paperless/paperless.conf +sed -i -e "s|#PAPERLESS_SECRET_KEY=change-me|PAPERLESS_SECRET_KEY=$SECRET_KEY|" /opt/paperless/paperless.conf +cd /opt/paperless/src +$STD python3 manage.py migrate +msg_ok "Set up PostgreSQL database" + +read -r -p "Would you like to add Adminer? <y/N> " prompt +if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + msg_info "Installing Adminer" + $STD apt install -y adminer + $STD a2enconf adminer + systemctl reload apache2 + IP=$(hostname -I | awk '{print $1}') + echo "" >>~/paperless.creds + echo -e "Adminer Interface: \e[32m$IP/adminer/\e[0m" >>~/paperless.creds + echo -e "Adminer System: \e[32mPostgreSQL\e[0m" >>~/paperless.creds + echo -e "Adminer Server: \e[32mlocalhost:5432\e[0m" >>~/paperless.creds + echo -e "Adminer Username: \e[32m$DB_USER\e[0m" >>~/paperless.creds + echo -e "Adminer Password: \e[32m$DB_PASS\e[0m" >>~/paperless.creds + echo -e "Adminer Database: \e[32m$DB_NAME\e[0m" >>~/paperless.creds + msg_ok "Installed Adminer" +fi + +msg_info "Setting up admin Paperless-ngx User & Password" +## From https://github.com/linuxserver/docker-paperless-ngx/blob/main/root/etc/cont-init.d/99-migrations +cat <<EOF | python3 /opt/paperless/src/manage.py shell +from django.contrib.auth import get_user_model +UserModel = get_user_model() +user = UserModel.objects.create_user('admin', password='$DB_PASS') +user.is_superuser = True +user.is_staff = True +user.save() +EOF +echo "" >>~/paperless.creds +echo -e "Paperless-ngx WebUI User: \e[32madmin\e[0m" >>~/paperless.creds +echo -e "Paperless-ngx WebUI Password: \e[32m$DB_PASS\e[0m" >>~/paperless.creds +echo "" >>~/paperless.creds +msg_ok "Set up admin Paperless-ngx User & Password" + +msg_info "Creating Services" +cat <<EOF >/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 + +cat <<EOF >/etc/systemd/system/paperless-task-queue.service +[Unit] +Description=Paperless Celery Workers +Requires=redis.service +After=postgresql.service + +[Service] +WorkingDirectory=/opt/paperless/src +ExecStart=celery --app paperless worker --loglevel INFO + +[Install] +WantedBy=multi-user.target +EOF + +cat <<EOF >/etc/systemd/system/paperless-consumer.service +[Unit] +Description=Paperless consumer +Requires=redis.service + +[Service] +WorkingDirectory=/opt/paperless/src +ExecStart=python3 manage.py document_consumer + +[Install] +WantedBy=multi-user.target +EOF + +cat <<EOF >/etc/systemd/system/paperless-webserver.service +[Unit] +Description=Paperless webserver +After=network.target +Wants=network.target +Requires=redis.service + +[Service] +WorkingDirectory=/opt/paperless/src +ExecStart=/usr/local/bin/gunicorn -c /opt/paperless/gunicorn.conf.py paperless.asgi:application + +[Install] +WantedBy=multi-user.target +EOF + +sed -i -e 's/rights="none" pattern="PDF"/rights="read|write" pattern="PDF"/' /etc/ImageMagick-6/policy.xml + +systemctl daemon-reload +$STD systemctl enable --now paperless-consumer paperless-webserver paperless-scheduler paperless-task-queue.service +msg_ok "Created Services" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -rf /opt/paperless/docker +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/pbs-install.sh b/install/pbs-install.sh new file mode 100644 index 00000000..5f5dc017 --- /dev/null +++ b/install/pbs-install.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 Proxmox Backup Server" +wget -q https://enterprise.proxmox.com/debian/proxmox-release-bookworm.gpg -O /etc/apt/trusted.gpg.d/proxmox-release-bookworm.gpg +cat <<EOF >>/etc/apt/sources.list +deb http://download.proxmox.com/debian/pbs bookworm pbs-no-subscription +EOF +$STD apt-get update +$STD apt-get install -y proxmox-backup-server +msg_ok "Installed Proxmox Backup Server" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/peanut-install.sh b/install/peanut-install.sh new file mode 100644 index 00000000..f32e764f --- /dev/null +++ b/install/peanut-install.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Co-Author: remz1337 +# 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 gpg +msg_ok "Installed Dependencies" + +msg_info "Installing Node.js" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Installing NUT" +$STD apt-get install -y nut-client +msg_ok "Installed NUT" + +msg_info "Installing Peanut" +RELEASE=$(curl -sL https://api.github.com/repos/Brandawg93/PeaNUT/releases/latest | grep '"tag_name":' | cut -d'"' -f4) +wget -qO peanut.tar.gz https://api.github.com/repos/Brandawg93/PeaNUT/tarball/${RELEASE} +mkdir -p /opt/peanut +tar -xzf peanut.tar.gz -C /opt/peanut --strip-components 1 +rm peanut.tar.gz +cd /opt/peanut +$STD npm install -g pnpm +$STD pnpm i +$STD pnpm run build +cp -r .next/static .next/standalone/.next/ +msg_ok "Installed Peanut" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/peanut.service +[Unit] +Description=Peanut +After=network.target +[Service] +SyslogIdentifier=peanut +Restart=always +RestartSec=5 +Type=simple +Environment="NODE_ENV=production" +Environment="NUT_HOST=localhost" +Environment="NUT_PORT=3493" +Environment="WEB_HOST=0.0.0.0" +Environment="WEB_PORT=3000" +WorkingDirectory=/opt/peanut +ExecStart=node /opt/peanut/.next/standalone/server.js +TimeoutStopSec=30 +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now peanut.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" \ No newline at end of file diff --git a/install/petio-install.sh b/install/petio-install.sh new file mode 100644 index 00000000..0de03f15 --- /dev/null +++ b/install/petio-install.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gnupg +$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 MongoDB 4.4" +wget -qO- https://www.mongodb.org/static/pgp/server-4.4.asc | gpg --dearmor >/usr/share/keyrings/mongodb-server-4.4.gpg +# Determine OS ID +OS_ID=$(grep '^ID=' /etc/os-release | cut -d'=' -f2) + +if [ "$OS_ID" = "debian" ]; then +echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-4.4.gpg ] http://repo.mongodb.org/apt/debian $(grep '^VERSION_CODENAME=' /etc/os-release | cut -d'=' -f2)/mongodb-org/4.4 main" > /etc/apt/sources.list.d/mongodb-org-4.4.list +else +echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-4.4.gpg ] https://repo.mongodb.org/apt/ubuntu $(grep '^VERSION_CODENAME=' /etc/os-release | cut -d'=' -f2)/mongodb-org/4.4 multiverse" > /etc/apt/sources.list.d/mongodb-org-4.4.list +fi + +$STD apt-get update +$STD apt-get install -y mongodb-org +sed -i 's/bindIp: 127.0.0.1/bindIp: 0.0.0.0/' /etc/mongod.conf +systemctl enable -q --now mongod.service +msg_ok "MongoDB 4.4 Installed" + + +msg_info "Installing Petio" +useradd -M --shell=/bin/false petio +mkdir /opt/Petio +wget -q https://petio.tv/releases/latest -O petio-latest.zip +$STD unzip -q petio-latest.zip -d /opt/Petio +rm -rf petio-latest.zip +chown -R petio:petio /opt/Petio +msg_ok "Installed Petio" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/petio.service +[Unit] +Description=Petio a content request system +After=network.target mongod.service + +[Service] +Type=simple +User=petio +Restart=on-failure +RestartSec=1 +ExecStart=/opt/Petio/bin/petio-linux + +[Install] +WantedBy=multi-user.target + + +EOF +systemctl enable -q --now petio.service +msg_ok "Created Service" + + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/photoprism-install.sh b/install/photoprism-install.sh new file mode 100644 index 00000000..8e0df7ab --- /dev/null +++ b/install/photoprism-install.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 exiftool +$STD apt-get install -y ffmpeg +$STD apt-get install -y libheif1 +$STD apt-get install -y libpng-dev +$STD apt-get install -y libjpeg-dev +$STD apt-get install -y libtiff-dev +$STD apt-get install -y imagemagick +$STD apt-get install -y darktable +$STD apt-get install -y rawtherapee +$STD apt-get install -y libvips42 + +echo 'export PATH=/usr/local:$PATH' >>~/.bashrc +export PATH=/usr/local:$PATH +msg_ok "Installed Dependencies" + +msg_info "Installing PhotoPrism (Patience)" +mkdir -p /opt/photoprism/{cache,config,photos/originals,photos/import,storage,temp} +wget -q -cO - https://dl.photoprism.app/pkg/linux/amd64.tar.gz | tar -xz -C /opt/photoprism --strip-components=1 +if [[ ${PCT_OSTYPE} == "ubuntu" ]]; then + wget -q -cO - https://dl.photoprism.app/dist/libheif/libheif-jammy-amd64-v1.17.1.tar.gz | tar -xzf - -C /usr/local --strip-components=1 +else + wget -q -cO - https://dl.photoprism.app/dist/libheif/libheif-bookworm-amd64-v1.17.1.tar.gz | tar -xzf - -C /usr/local --strip-components=1 +fi +ldconfig +cat <<EOF >/opt/photoprism/config/.env +PHOTOPRISM_AUTH_MODE='password' +PHOTOPRISM_ADMIN_PASSWORD='changeme' +PHOTOPRISM_HTTP_HOST='0.0.0.0' +PHOTOPRISM_HTTP_PORT='2342' +PHOTOPRISM_SITE_CAPTION='https://tteck.github.io/Proxmox/' +PHOTOPRISM_STORAGE_PATH='/opt/photoprism/storage' +PHOTOPRISM_ORIGINALS_PATH='/opt/photoprism/photos/originals' +PHOTOPRISM_IMPORT_PATH='/opt/photoprism/photos/import' +EOF +ln -sf /opt/photoprism/bin/photoprism /usr/local/bin/photoprism +msg_ok "Installed PhotoPrism" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/photoprism.service +[Unit] +Description=PhotoPrism service +After=network.target + +[Service] +Type=forking +User=root +WorkingDirectory=/opt/photoprism +EnvironmentFile=/opt/photoprism/config/.env +ExecStart=/opt/photoprism/bin/photoprism up -d +ExecStop=/opt/photoprism/bin/photoprism down + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now photoprism +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/pialert-install.sh b/install/pialert-install.sh new file mode 100644 index 00000000..d08f16f7 --- /dev/null +++ b/install/pialert-install.sh @@ -0,0 +1,102 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 \ + sudo \ + mc \ + curl \ + apt-utils \ + avahi-utils \ + lighttpd \ + sqlite3 \ + mmdb-bin \ + arp-scan \ + dnsutils \ + net-tools \ + nbtscan \ + libwww-perl \ + nmap \ + zip \ + aria2 \ + wakeonlan +msg_ok "Installed Dependencies" + +msg_info "Installing PHP Dependencies" +$STD apt-get -y install \ + php \ + php-cgi \ + php-fpm \ + php-curl \ + php-xml \ + php-sqlite3 +$STD lighttpd-enable-mod fastcgi-php +service lighttpd force-reload +msg_ok "Installed PHP Dependencies" + +msg_info "Installing Python Dependencies" +$STD apt-get -y install \ + python3-pip \ + python3-requests +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +$STD pip3 install mac-vendor-lookup +$STD pip3 install fritzconnection +$STD pip3 install cryptography +$STD pip3 install pyunifi +msg_ok "Installed Python Dependencies" + +msg_info "Installing Pi.Alert" +curl -sL https://github.com/leiweibau/Pi.Alert/raw/main/tar/pialert_latest.tar | tar xvf - -C /opt >/dev/null 2>&1 +rm -rf /var/lib/ieee-data /var/www/html/index.html +sed -i -e 's#^sudo cp -n /usr/share/ieee-data/.* /var/lib/ieee-data/#\# &#' -e '/^sudo mkdir -p 2_backup$/s/^/# /' -e '/^sudo cp \*.txt 2_backup$/s/^/# /' -e '/^sudo cp \*.csv 2_backup$/s/^/# /' /opt/pialert/back/update_vendors.sh +mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.html.old +ln -s /usr/share/ieee-data/ /var/lib/ +ln -s /opt/pialert/install/index.html /var/www/html/index.html +ln -s /opt/pialert/front /var/www/html/pialert +chmod go+x /opt/pialert /opt/pialert/back/shoutrrr/x86/shoutrrr +chgrp -R www-data /opt/pialert/db /opt/pialert/front/reports /opt/pialert/config /opt/pialert/config/pialert.conf +chmod -R 775 /opt/pialert/db /opt/pialert/db/temp /opt/pialert/config /opt/pialert/front/reports +touch /opt/pialert/log/pialert.vendors.log /opt/pialert/log/pialert.IP.log /opt/pialert/log/pialert.1.log /opt/pialert/log/pialert.cleanup.log /opt/pialert/log/pialert.webservices.log +src_dir="/opt/pialert/log" +dest_dir="/opt/pialert/front/php/server" +for file in pialert.vendors.log pialert.IP.log pialert.1.log pialert.cleanup.log pialert.webservices.log; do + ln -s "$src_dir/$file" "$dest_dir/$file" +done +sed -i 's#PIALERT_PATH\s*=\s*'\''/home/pi/pialert'\''#PIALERT_PATH = '\''/opt/pialert'\''#' /opt/pialert/config/pialert.conf +sed -i 's/$HOME/\/opt/g' /opt/pialert/install/pialert.cron +crontab /opt/pialert/install/pialert.cron +echo "bash -c \"\$(wget -qLO - https://github.com/leiweibau/Pi.Alert/raw/main/install/pialert_update.sh)\" -s --lxc" >/usr/bin/update +chmod +x /usr/bin/update +echo "python3 /opt/pialert/back/pialert.py 1" >/usr/bin/scan +chmod +x /usr/bin/scan +echo "/opt/pialert/back/pialert-cli set_permissions --lxc" >/usr/bin/permissions +chmod +x /usr/bin/permissions +echo "/opt/pialert/back/pialert-cli set_sudoers --lxc" >/usr/bin/sudoers +chmod +x /usr/bin/sudoers +msg_ok "Installed Pi.Alert" + +msg_info "Start Pi.Alert Scan (Patience)" +$STD python3 /opt/pialert/back/pialert.py update_vendors +$STD python3 /opt/pialert/back/pialert.py internet_IP +$STD python3 /opt/pialert/back/pialert.py 1 +msg_ok "Finished Pi.Alert Scan" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/pihole-install.sh b/install/pihole-install.sh new file mode 100644 index 00000000..7f79ff8c --- /dev/null +++ b/install/pihole-install.sh @@ -0,0 +1,110 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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" +mkdir -p /etc/pihole/ +cat <<EOF >/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 +# View script https://install.pi-hole.net +$STD bash <(curl -fsSL https://install.pi-hole.net) --unattended +msg_ok "Installed Pi-hole" + +read -r -p "Would you like to add Unbound? <y/N> " prompt +if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then + msg_info "Installing Unbound" + $STD apt-get install -y unbound + cat <<EOF >/etc/unbound/unbound.conf.d/pi-hole.conf +server: + verbosity: 0 + interface: 0.0.0.0 + port: 5335 + do-ip6: no + do-ip4: yes + do-udp: yes + do-tcp: yes + num-threads: 1 + hide-identity: yes + hide-version: yes + harden-glue: yes + harden-dnssec-stripped: yes + harden-referral-path: yes + use-caps-for-id: no + harden-algo-downgrade: no + qname-minimisation: yes + aggressive-nsec: yes + rrset-roundrobin: yes + cache-min-ttl: 300 + cache-max-ttl: 14400 + msg-cache-slabs: 8 + rrset-cache-slabs: 8 + infra-cache-slabs: 8 + key-cache-slabs: 8 + serve-expired: yes + root-hints: /var/lib/unbound/root.hints + serve-expired-ttl: 3600 + edns-buffer-size: 1232 + prefetch: yes + prefetch-key: yes + target-fetch-policy: "3 2 1 1 1" + unwanted-reply-threshold: 10000000 + rrset-cache-size: 256m + msg-cache-size: 128m + so-rcvbuf: 1m + private-address: 192.168.0.0/16 + private-address: 169.254.0.0/16 + private-address: 172.16.0.0/12 + private-address: 10.0.0.0/8 + private-address: fd00::/8 + private-address: fe80::/10 +EOF + mkdir -p /etc/dnsmasq.d/ + cat <<EOF >/etc/dnsmasq.d/99-edns.conf +edns-packet-max=1232 +EOF + wget -qO /var/lib/unbound/root.hints https://www.internic.net/domain/named.root + sed -i -e 's/PIHOLE_DNS_1=8.8.8.8/PIHOLE_DNS_1=127.0.0.1#5335/' -e 's/PIHOLE_DNS_2=8.8.4.4/#PIHOLE_DNS_2=8.8.4.4/' /etc/pihole/setupVars.conf + systemctl enable -q --now unbound + systemctl restart pihole-FTL.service + msg_ok "Installed Unbound" +fi + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/pingvin-install.sh b/install/pingvin-install.sh new file mode 100644 index 00000000..4430cc21 --- /dev/null +++ b/install/pingvin-install.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gnupg +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +$STD npm install pm2 -g +msg_ok "Installed Node.js" + +msg_info "Installing Pingvin Share (Patience)" +git clone -q https://github.com/stonith404/pingvin-share /opt/pingvin-share +cd /opt/pingvin-share +$STD git fetch --tags +$STD git checkout $(git describe --tags `git rev-list --tags --max-count=1`) +cd backend +$STD npm install +$STD npm run build +$STD pm2 start --name="pingvin-share-backend" npm -- run prod +cd ../frontend +sed -i '/"admin.config.smtp.allow-unauthorized-certificates":\|admin.config.smtp.allow-unauthorized-certificates.description":/,+1d' ./src/i18n/translations/fr-FR.ts +$STD npm install +$STD npm run build +$STD pm2 start --name="pingvin-share-frontend" npm -- run start +$STD pm2 startup +msg_ok "Installed Pingvin Share" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/plex-install.sh b/install/plex-install.sh new file mode 100644 index 00000000..d456be02 --- /dev/null +++ b/install/plex-install.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +msg_ok "Installed Dependencies" + +msg_info "Setting Up Hardware Acceleration" +$STD apt-get -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools} +if [[ "$CTTYPE" == "0" ]]; then + chgrp video /dev/dri + chmod 755 /dev/dri + chmod 660 /dev/dri/* + $STD adduser $(id -u -n) video + $STD adduser $(id -u -n) render +fi +msg_ok "Set Up Hardware Acceleration" + +msg_info "Setting Up Plex Media Server Repository" +wget -qO- https://downloads.plex.tv/plex-keys/PlexSign.key >/usr/share/keyrings/PlexSign.asc +echo "deb [signed-by=/usr/share/keyrings/PlexSign.asc] 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 +if [[ "$CTTYPE" == "0" ]]; then + sed -i -e 's/^ssl-cert:x:104:plex$/render:x:104:root,plex/' -e 's/^render:x:108:root$/ssl-cert:x:108:plex/' /etc/group +else + sed -i -e 's/^ssl-cert:x:104:plex$/render:x:104:plex/' -e 's/^render:x:108:$/ssl-cert:x:108:/' /etc/group +fi +msg_ok "Installed Plex Media Server" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/pocketbase-install.sh b/install/pocketbase-install.sh new file mode 100644 index 00000000..29bf8813 --- /dev/null +++ b/install/pocketbase-install.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 Pocketbase" +RELEASE=$(curl -s https://api.github.com/repos/pocketbase/pocketbase/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +wget -q https://github.com/pocketbase/pocketbase/releases/download/v${RELEASE}/pocketbase_${RELEASE}_linux_amd64.zip -O /tmp/pocketbase.zip +mkdir -p /opt/pocketbase/{pb_public,pb_migrations,pb_hooks} +unzip -q -o /tmp/pocketbase.zip -d /opt/pocketbase + +cat <<EOF >/etc/systemd/system/pocketbase.service +[Unit] +Description = pocketbase + +[Service] +Type = simple +LimitNOFILE = 4096 +Restart = always +RestartSec = 5s +StandardOutput = append:/opt/pocketbase/errors.log +StandardError = append:/opt/pocketbase/errors.log +ExecStart = /opt/pocketbase/pocketbase serve --http=0.0.0.0:8080 + +[Install] +WantedBy = multi-user.target +EOF + +systemctl enable -q --now pocketbase.service +msg_ok "Installed Pocketbase" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/podman-homeassistant-install.sh b/install/podman-homeassistant-install.sh new file mode 100644 index 00000000..a82d852e --- /dev/null +++ b/install/podman-homeassistant-install.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/podman-install.sh b/install/podman-install.sh new file mode 100644 index 00000000..1ef11fdd --- /dev/null +++ b/install/podman-install.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/postgresql-install.sh b/install/postgresql-install.sh new file mode 100644 index 00000000..3cf51532 --- /dev/null +++ b/install/postgresql-install.sh @@ -0,0 +1,151 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 up PostgreSQL Repository" +VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)" +echo "deb http://apt.postgresql.org/pub/repos/apt ${VERSION}-pgdg main" >/etc/apt/sources.list.d/pgdg.list +curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor --output /etc/apt/trusted.gpg.d/postgresql.gpg +msg_ok "Setup PostgreSQL Repository" + +msg_info "Installing PostgreSQL" +$STD apt-get update +$STD apt-get install -y postgresql + +cat <<EOF >/etc/postgresql/16/main/pg_hba.conf +# PostgreSQL Client Authentication Configuration File +local all postgres peer +# TYPE DATABASE USER ADDRESS METHOD +# "local" is for Unix domain socket connections only +local all all peer +# IPv4 local connections: +host all all 127.0.0.1/32 scram-sha-256 +host all all 0.0.0.0/24 md5 +# IPv6 local connections: +host all all ::1/128 scram-sha-256 +host all all 0.0.0.0/0 md5 +# Allow replication connections from localhost, by a user with the +# replication privilege. +local replication all peer +host replication all 127.0.0.1/32 scram-sha-256 +host replication all ::1/128 scram-sha-256 +EOF + +cat <<EOF >/etc/postgresql/16/main/postgresql.conf +# ----------------------------- +# PostgreSQL configuration file +# ----------------------------- + +#------------------------------------------------------------------------------ +# FILE LOCATIONS +#------------------------------------------------------------------------------ + +data_directory = '/var/lib/postgresql/16/main' +hba_file = '/etc/postgresql/16/main/pg_hba.conf' +ident_file = '/etc/postgresql/16/main/pg_ident.conf' +external_pid_file = '/var/run/postgresql/16-main.pid' + +#------------------------------------------------------------------------------ +# CONNECTIONS AND AUTHENTICATION +#------------------------------------------------------------------------------ + +# - Connection Settings - + +listen_addresses = '*' +port = 5432 +max_connections = 100 +unix_socket_directories = '/var/run/postgresql' + +# - SSL - + +ssl = on +ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem' +ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key' + +#------------------------------------------------------------------------------ +# RESOURCE USAGE (except WAL) +#------------------------------------------------------------------------------ + +shared_buffers = 128MB +dynamic_shared_memory_type = posix + +#------------------------------------------------------------------------------ +# WRITE-AHEAD LOG +#------------------------------------------------------------------------------ + +max_wal_size = 1GB +min_wal_size = 80MB + +#------------------------------------------------------------------------------ +# REPORTING AND LOGGING +#------------------------------------------------------------------------------ + +# - What to Log - + +log_line_prefix = '%m [%p] %q%u@%d ' +log_timezone = 'Etc/UTC' + +#------------------------------------------------------------------------------ +# PROCESS TITLE +#------------------------------------------------------------------------------ + +cluster_name = '16/main' + +#------------------------------------------------------------------------------ +# CLIENT CONNECTION DEFAULTS +#------------------------------------------------------------------------------ + +# - Locale and Formatting - + +datestyle = 'iso, mdy' +timezone = 'Etc/UTC' +lc_messages = 'C' +lc_monetary = 'C' +lc_numeric = 'C' +lc_time = 'C' +default_text_search_config = 'pg_catalog.english' + +#------------------------------------------------------------------------------ +# CONFIG FILE INCLUDES +#------------------------------------------------------------------------------ + +include_dir = 'conf.d' +EOF + +sudo systemctl restart postgresql +msg_ok "Installed PostgreSQL" + +read -r -p "Would you like to add Adminer? <y/N> " 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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/prometheus-install.sh b/install/prometheus-install.sh new file mode 100644 index 00000000..5d2e95cd --- /dev/null +++ b/install/prometheus-install.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +rm -rf ../prometheus-${RELEASE}.linux-amd64 ../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..39a56fac --- /dev/null +++ b/install/prowlarr-install.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 <<EOF >/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 +customize + +msg_info "Cleaning up" +rm -rf Prowlarr.master.*.tar.gz +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/qbittorrent-install.sh b/install/qbittorrent-install.sh new file mode 100644 index 00000000..a1c0064f --- /dev/null +++ b/install/qbittorrent-install.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +mkdir -p /.config/qBittorrent/ +cat <<EOF >/.config/qBittorrent/qBittorrent.conf +[Preferences] +WebUI\Password_PBKDF2="@ByteArray(amjeuVrF3xRbgzqWQmes5A==:XK3/Ra9jUmqUc4RwzCtrhrkQIcYczBl90DJw2rT8DFVTss4nxpoRhvyxhCf87ahVE3SzD8K9lyPdpyUCfmVsUg==)" +WebUI\Port=8090 +WebUI\UseUPnP=false +WebUI\Username=admin +EOF +msg_ok "qbittorrent-nox" + +msg_info "Creating Service" +cat <<EOF >/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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/rabbitmq-install.sh b/install/rabbitmq-install.sh new file mode 100644 index 00000000..5824c0f5 --- /dev/null +++ b/install/rabbitmq-install.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck +# Co-Author: MickLesk (Canbiz) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +# Source: https://www.rabbitmq.com/ + +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 \ + sudo \ + lsb-release \ + curl \ + gnupg \ + apt-transport-https \ + make \ + mc +msg_ok "Installed Dependencies" + +msg_info "Adding RabbitMQ signing key" +wget -qO- "https://keys.openpgp.org/vks/v1/by-fingerprint/0A9AF2115F4687BD29803A206B73A36E6026DFCA" | gpg --dearmor >/usr/share/keyrings/com.rabbitmq.team.gpg +wget -qO- "https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key" | gpg --dearmor >/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg +wget -qO- "https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.9F4587F226208342.key" | gpg --dearmor >/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg +msg_ok "Signing keys added" + +msg_info "Adding RabbitMQ repository" +cat <<EOF >/etc/apt/sources.list.d/rabbitmq.list +## Provides modern Erlang/OTP releases from a Cloudsmith mirror +deb [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/deb/debian $(lsb_release -cs) main +deb-src [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/deb/debian $(lsb_release -cs) main + +## Provides RabbitMQ from a Cloudsmith mirror +deb [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/deb/debian $(lsb_release -cs) main +deb-src [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/deb/debian $(lsb_release -cs) main +EOF +msg_ok "RabbitMQ repository added" + +msg_info "Updating package list" +$STD apt-get update -y +msg_ok "Package list updated" + +msg_info "Installing Erlang & RabbitMQ server" +$STD apt-get install -y erlang-base \ + erlang-asn1 erlang-crypto erlang-eldap erlang-ftp erlang-inets \ + erlang-mnesia erlang-os-mon erlang-parsetools erlang-public-key \ + erlang-runtime-tools erlang-snmp erlang-ssl \ + erlang-syntax-tools erlang-tftp erlang-tools erlang-xmerl \ + rabbitmq-server +msg_ok "RabbitMQ server installed" + +msg_info "Starting RabbitMQ service" +systemctl enable -q --now rabbitmq-server +msg_ok "RabbitMQ service started" + +msg_info "Enabling RabbitMQ management plugin" +$STD rabbitmq-plugins enable rabbitmq_management +$STD rabbitmqctl enable_feature_flag all +msg_ok "RabbitMQ management plugin enabled" + +msg_info "Create User" +$STD rabbitmqctl add_user proxmox proxmox +$STD rabbitmqctl set_user_tags proxmox administrator +$STD rabbitmqctl set_permissions -p / proxmox ".*" ".*" ".*" +msg_ok "Created User" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/radarr-install.sh b/install/radarr-install.sh new file mode 100644 index 00000000..dc074251 --- /dev/null +++ b/install/radarr-install.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 <<EOF >/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 +customize + +msg_info "Cleaning up" +rm -rf Radarr.master.*.tar.gz +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/rdtclient-install.sh b/install/rdtclient-install.sh new file mode 100644 index 00000000..652998aa --- /dev/null +++ b/install/rdtclient-install.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 ASP.NET Core Runtime" +wget -q https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb +$STD dpkg -i packages-microsoft-prod.deb +rm packages-microsoft-prod.deb +$STD apt-get update +$STD apt-get install -y dotnet-sdk-8.0 +msg_ok "Installed ASP.NET Core Runtime" + +msg_info "Installing rdtclient" +wget -q https://github.com/rogerfar/rdt-client/releases/latest/download/RealDebridClient.zip +unzip -qq RealDebridClient.zip -d /opt/rdtc +rm RealDebridClient.zip +cd /opt/rdtc +mkdir -p data/{db,downloads} +sed -i 's#/data/db/#/opt/rdtc&#g' /opt/rdtc/appsettings.json +msg_ok "Installed rdtclient" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/rdtc.service +[Unit] +Description=RdtClient Service + +[Service] +WorkingDirectory=/opt/rdtc +ExecStart=/usr/bin/dotnet RdtClient.Web.dll +SyslogIdentifier=RdtClient +User=root + +[Install] +WantedBy=multi-user.target +EOF +$STD systemctl enable -q --now rdtc +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/readarr-install.sh b/install/readarr-install.sh new file mode 100644 index 00000000..c3afc66d --- /dev/null +++ b/install/readarr-install.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 <<EOF >/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 +customize + +msg_info "Cleaning up" +rm -rf Readarr.develop.*.tar.gz +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/readeck-install.sh b/install/readeck-install.sh new file mode 100644 index 00000000..dbc1d5e8 --- /dev/null +++ b/install/readeck-install.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 Readeck" +LATEST=$(curl -s https://codeberg.org/readeck/readeck/releases/ | grep -oP '(?<=Version )\d+\.\d+\.\d+' | head -1) +mkdir -p /opt/readeck +cd /opt/readeck +wget -q -O readeck https://codeberg.org/readeck/readeck/releases/download/${LATEST}/readeck-${LATEST}-linux-amd64 +chmod a+x readeck +msg_ok "Installed Readeck" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/readeck.service +[Unit] +Description=Readeck Service +After=network.target + +[Service] +Environment=READECK_SERVER_HOST=0.0.0.0 +Environment=READECK_SERVER_PORT=8000 +ExecStart=/opt/readeck/./readeck serve +WorkingDirectory=/opt/readeck +Restart=always + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now readeck.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/redis-install.sh b/install/redis-install.sh new file mode 100644 index 00000000..488d787a --- /dev/null +++ b/install/redis-install.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +$STD apt-get install -y lsb-release +msg_ok "Installed Dependencies" + +msg_info "Installing Redis" +wget -qO- https://packages.redis.io/gpg | gpg --dearmor >/usr/share/keyrings/redis-archive-keyring.gpg +echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" >/etc/apt/sources.list.d/redis.list +$STD apt-get update +$STD apt-get install -y redis +sed -i 's/^bind .*/bind 0.0.0.0/' /etc/redis/redis.conf +systemctl enable -q --now redis-server.service +msg_ok "Installed Redis" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/rtsptoweb-install.sh b/install/rtsptoweb-install.sh new file mode 100644 index 00000000..d8e5ecab --- /dev/null +++ b/install/rtsptoweb-install.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 RTSPtoWeb" +$STD git clone https://github.com/deepch/RTSPtoWeb /opt/rtsptoweb +cat <<EOF >>/opt/rtsptoweb/start +#!/bin/bash +cd /opt/rtsptoweb && GO111MODULE=on go run *.go +EOF +chmod +x /opt/rtsptoweb/start +msg_ok "Installed RTSPtoWeb" + +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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/runtipi-install.sh b/install/runtipi-install.sh new file mode 100644 index 00000000..f39bb3af --- /dev/null +++ b/install/runtipi-install.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 Runtipi (Patience)" +DOCKER_CONFIG_PATH='/etc/docker/daemon.json' +mkdir -p "$(dirname "$DOCKER_CONFIG_PATH")" +echo -e '{\n "log-driver": "journald"\n}' > "$DOCKER_CONFIG_PATH" +cd /opt +wget -q https://raw.githubusercontent.com/runtipi/runtipi/master/scripts/install.sh +chmod +x install.sh +$STD ./install.sh +chmod 666 /opt/runtipi/state/settings.json +msg_ok "Installed Runtipi" + +motd_ssh +customize + +msg_info "Cleaning up" +rm /opt/install.sh +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/sabnzbd-install.sh b/install/sabnzbd-install.sh new file mode 100644 index 00000000..efeb7c0f --- /dev/null +++ b/install/sabnzbd-install.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 par2 +$STD apt-get install -y p7zip-full +cat <<EOF >/etc/apt/sources.list.d/non-free.list +deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware +EOF +$STD apt-get update +$STD apt-get install -y unrar +rm /etc/apt/sources.list.d/non-free.list +msg_ok "Installed Dependencies" + +msg_info "Updating Python3" +$STD apt-get install -y \ + python3-dev \ + python3-pip +$STD apt-get install -y python3-setuptools +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +msg_ok "Updated Python3" + +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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/scrypted-install.sh b/install/scrypted-install.sh new file mode 100644 index 00000000..ad71ba92 --- /dev/null +++ b/install/scrypted-install.sh @@ -0,0 +1,136 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 -y install software-properties-common apt-utils +$STD apt-get -y update +$STD apt-get -y upgrade +$STD apt-get install -y avahi-daemon +$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 \ + ca-certificates \ + gpg +msg_ok "Installed Dependencies" + +msg_info "Setting Up Hardware Acceleration" +$STD apt-get -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools} +if [[ "$CTTYPE" == "0" ]]; then + chgrp video /dev/dri + chmod 755 /dev/dri + chmod 660 /dev/dri/* + $STD adduser $(id -u -n) video + $STD adduser $(id -u -n) render +fi +msg_ok "Set Up Hardware Acceleration" + +msg_info "Installing GStreamer (Patience)" +$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" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Updating Python3" +$STD apt-get install -y \ + python3 \ + python3-dev \ + python3-pip +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +msg_ok "Updated Python3" + +msg_info "Installing Python3 Dependencies" +$STD apt-get -y install \ + python3-gi \ + python3-gst-1.0 \ + python3-matplotlib \ + python3-numpy \ + python3-opencv \ + python3-pil \ + 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 Dependencies" + +msg_info "Installing Scrypted" +$STD npx -y scrypted@latest install-server + +if [[ "$CTTYPE" == "0" ]]; then + sed -i -e 's/^sgx:x:104:$/render:x:104:root/' -e 's/^render:x:106:root$/sgx:x:106:/' /etc/group +else + sed -i -e 's/^sgx:x:104:$/render:x:104:/' -e 's/^render:x:106:$/sgx:x:106:/' /etc/group +fi +msg_ok "Installed Scrypted" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/scrypted.service +[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 +EOF +systemctl enable -q --now scrypted.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/sftpgo-install.sh b/install/sftpgo-install.sh new file mode 100644 index 00000000..809ac74c --- /dev/null +++ b/install/sftpgo-install.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +$STD apt-get install -y sqlite3 +msg_ok "Installed Dependencies" + +msg_info "Installing Golang" +set +o pipefail +RELEASE=$(curl -s https://go.dev/dl/ | grep -o "go.*\linux-amd64.tar.gz" | head -n 1) +wget -q https://golang.org/dl/$RELEASE +tar -xzf $RELEASE -C /usr/local +$STD ln -s /usr/local/go/bin/go /usr/local/bin/go +set -o pipefail +msg_ok "Installed Golang" + +msg_info "Installing SFTPGo" +curl -sS https://ftp.osuosl.org/pub/sftpgo/apt/gpg.key | gpg --dearmor -o /usr/share/keyrings/sftpgo-archive-keyring.gpg +echo "deb [signed-by=/usr/share/keyrings/sftpgo-archive-keyring.gpg] https://ftp.osuosl.org/pub/sftpgo/apt bookworm main" >/etc/apt/sources.list.d/sftpgo.list +$STD apt-get update +$STD apt-get install -y sftpgo +msg_ok "Installed SFTPGo" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -rf $RELEASE +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/shinobi-install.sh b/install/shinobi-install.sh new file mode 100644 index 00000000..82545835 --- /dev/null +++ b/install/shinobi-install.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 sudo git mc +$STD apt-get install -y make zip net-tools +$STD apt-get install -y gcc g++ cmake +$STD apt-get install -y ca-certificates +$STD apt-get install -y gnupg +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$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 "Cloning 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" +sqluser="root" +sqlpass="root" +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 +mysql -u "$sqluser" -p"$sqlpass" -e "source sql/user.sql" || true +msg_ok "Installed Database" + +msg_info "Installing Shinobi" +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 +$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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/smokeping-install.sh b/install/smokeping-install.sh new file mode 100644 index 00000000..0df5c842 --- /dev/null +++ b/install/smokeping-install.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 SmokePing" +$STD apt-get install -y smokeping +cat <<EOF >/etc/smokeping/config.d/Targets +*** Targets *** +probe = FPing +menu = Top +title = Network Latency Grapher +remark = Welcome to SmokePing. ++ Local +menu = Local +title = Local Network (ICMP) +++ LocalMachine +menu = Local Machine +title = This host +host = localhost ++ DNS +menu = DNS latency +title = DNS latency (ICMP) +++ Google +title = Google +host = 8.8.8.8 +++ Cloudflare +title = Cloudflare +host = 1.1.1.1 +++ Quad9 +title = Quad9 +host = 9.9.9.9 +++ OpenDNS +title = OpenDNS +host = 208.67.222.222 ++ HTTP +menu = HTTP latency +title = HTTP latency (ICMP) +++ Github +host = github.com +++ Discord +host = discord.com +++ Google +host = google.com +++ Cloudflare +host = cloudflare.com +++ Amazon +host = amazon.com +++ Netflix +host = netflix.com +EOF +systemctl restart smokeping +msg_ok "Installed SmokePing" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/sonarr-install.sh b/install/sonarr-install.sh new file mode 100644 index 00000000..79060e79 --- /dev/null +++ b/install/sonarr-install.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 Sonarr v4" +mkdir -p /var/lib/sonarr/ +chmod 775 /var/lib/sonarr/ +wget -q -O SonarrV4.tar.gz 'https://services.sonarr.tv/v1/download/main/latest?version=4&os=linux&arch=x64' +tar -xzf SonarrV4.tar.gz +mv Sonarr /opt +rm -rf SonarrV4.tar.gz + +msg_ok "Installed Sonarr v4" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/sonarr.service +[Unit] +Description=Sonarr Daemon +After=syslog.target network.target +[Service] +Type=simple +ExecStart=/opt/Sonarr/Sonarr -nobrowser -data=/var/lib/sonarr/ +TimeoutStopSec=20 +KillMode=process +Restart=on-failure +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now sonarr.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/spoolman-install.sh b/install/spoolman-install.sh new file mode 100644 index 00000000..dc2bc31d --- /dev/null +++ b/install/spoolman-install.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck +# Co-Author: MickLesk (Canbiz) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +# Source: https://github.com/Donkie/Spoolman + +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 \ + build-essential \ + curl \ + sudo \ + make \ + libpq-dev \ + gpg \ + ca-certificates \ + mc +msg_ok "Installed Dependencies" + +msg_info "Installing Python3" +$STD apt-get install -y \ + python3-dev \ + python3-setuptools \ + python3-wheel \ + python3-pip +msg_ok "Installed Python3" + +msg_info "Installing Spoolman" +cd /opt +RELEASE=$(wget -q https://github.com/Donkie/Spoolman/releases/latest -O - | grep "title>Release" | cut -d " " -f 4) +cd /opt +wget -q https://github.com/Donkie/Spoolman/releases/download/$RELEASE/spoolman.zip +unzip -q spoolman.zip -d spoolman +rm -rf spoolman.zip +cd spoolman +$STD pip3 install -r requirements.txt +cp .env.example .env +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_ok "Installed Spoolman" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/spoolman.service +[Unit] +Description=Spoolman +After=network.target +[Service] +Type=simple +WorkingDirectory=/opt/spoolman +EnvironmentFile=/opt/spoolman/.env +ExecStart=uvicorn spoolman.main:app --host 0.0.0.0 --port 7912 +Restart=always +User=root +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now spoolman.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/stirling-pdf-install.sh b/install/stirling-pdf-install.sh new file mode 100644 index 00000000..88456a66 --- /dev/null +++ b/install/stirling-pdf-install.sh @@ -0,0 +1,121 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 \ + sudo \ + mc \ + git \ + automake \ + autoconf \ + libtool \ + libleptonica-dev \ + pkg-config \ + zlib1g-dev \ + make \ + g++ \ + unpaper \ + ocrmypdf +msg_ok "Installed Dependencies" + +msg_info "Installing LibreOffice Components" +$STD apt-get install -y \ + libreoffice-writer \ + libreoffice-calc \ + libreoffice-impress +msg_ok "Installed LibreOffice Components" + +msg_info "Installing Python Dependencies" +$STD apt-get install -y \ + python3 \ + python3-pip +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +$STD pip3 install \ + uno \ + opencv-python-headless \ + unoconv \ + pngquant \ + WeasyPrint +msg_ok "Installed Python Dependencies" + +msg_info "Installing Azul Zulu" +wget -qO /etc/apt/trusted.gpg.d/zulu-repo.asc "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xB1998361219BD9C9" +wget -q https://cdn.azul.com/zulu/bin/zulu-repo_1.0.0-3_all.deb +$STD dpkg -i zulu-repo_1.0.0-3_all.deb +$STD apt-get update +$STD apt-get -y install zulu17-jdk +msg_ok "Installed Azul Zulu" + +msg_info "Installing JBIG2" +$STD git clone https://github.com/agl/jbig2enc /opt/jbig2enc +cd /opt/jbig2enc +$STD bash ./autogen.sh +$STD bash ./configure +$STD make +$STD make install +msg_ok "Installed JBIG2" + +msg_info "Installing Language Packs (Patience)" +$STD apt-get install -y 'tesseract-ocr-*' +msg_ok "Installed Language Packs" + +msg_info "Installing Stirling-PDF (Additional Patience)" +RELEASE=$(curl -s https://api.github.com/repos/Stirling-Tools/Stirling-PDF/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +wget -q https://github.com/Stirling-Tools/Stirling-PDF/archive/refs/tags/v$RELEASE.tar.gz +tar -xzf v$RELEASE.tar.gz +cd Stirling-PDF-$RELEASE +chmod +x ./gradlew +$STD ./gradlew build +mkdir -p /opt/Stirling-PDF +touch /opt/Stirling-PDF/.env +mv ./build/libs/Stirling-PDF-*.jar /opt/Stirling-PDF/ +mv scripts /opt/Stirling-PDF/ +ln -s /opt/Stirling-PDF/Stirling-PDF-$RELEASE.jar /opt/Stirling-PDF/Stirling-PDF.jar +ln -s /usr/share/tesseract-ocr/5/tessdata/ /usr/share/tessdata +msg_ok "Installed Stirling-PDF v$RELEASE" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/stirlingpdf.service +[Unit] +Description=Stirling-PDF service +After=syslog.target network.target + +[Service] +SuccessExitStatus=143 + +User=root +Group=root + +Type=simple +EnvironmentFile=/opt/Stirling-PDF/.env +WorkingDirectory=/opt/Stirling-PDF +ExecStart=/usr/bin/java -jar Stirling-PDF.jar +ExecStop=/bin/kill -15 %n + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now stirlingpdf.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -rf v$RELEASE.tar.gz /zulu-repo_1.0.0-3_all.deb +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/syncthing-install.sh b/install/syncthing-install.sh new file mode 100644 index 00000000..11b45673 --- /dev/null +++ b/install/syncthing-install.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 -sL -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/.local/state/syncthing/config.xml +systemctl restart syncthing@root.service +msg_ok "Installed Syncthing" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/tandoor-install.sh b/install/tandoor-install.sh new file mode 100644 index 00000000..53f88333 --- /dev/null +++ b/install/tandoor-install.sh @@ -0,0 +1,147 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck +# Co-Author: MickLesk (Canbiz) +# 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 --no-install-recommends \ + build-essential \ + libpq-dev \ + libmagic-dev \ + libzbar0 \ + nginx \ + libsasl2-dev \ + libldap2-dev \ + libssl-dev \ + gpg \ + curl \ + sudo \ + git \ + make \ + mc +msg_ok "Installed Dependencies" + +msg_info "Updating Python3" +$STD apt-get install -y \ + python3 \ + python3-dev \ + python3-setuptools \ + python3-pip +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +msg_ok "Updated Python3" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +$STD npm install -g yarn +msg_ok "Installed Node.js" + +msg_info "Installing Tandoor (Patience)" +$STD git clone https://github.com/vabene1111/recipes.git -b master /opt/tandoor +mkdir -p /opt/tandoor/{config,api,mediafiles,staticfiles} +$STD pip3 install -r /opt/tandoor/requirements.txt +cd /opt/tandoor/vue +$STD yarn install +$STD yarn build +wget -q https://raw.githubusercontent.com/vabene1111/recipes/develop/.env.template -O /opt/tandoor/.env +DB_NAME=db_recipes +DB_USER=tandoor +DB_ENCODING=utf8 +DB_TIMEZONE=UTC +secret_key=$(openssl rand -base64 45 | sed 's/\//\\\//g') +DB_PASS="$(openssl rand -base64 18 | cut -c1-13)" +sed -i -e "s|SECRET_KEY=.*|SECRET_KEY=$secret_key|g" \ + -e "s|POSTGRES_HOST=.*|POSTGRES_HOST=localhost|g" \ + -e "s|POSTGRES_PASSWORD=.*|POSTGRES_PASSWORD=$DB_PASS|g" \ + -e "s|POSTGRES_DB=.*|POSTGRES_DB=$DB_NAME|g" \ + -e "s|POSTGRES_USER=.*|POSTGRES_USER=$DB_USER|g" \ + -e "\$a\STATIC_URL=/staticfiles/" /opt/tandoor/.env +msg_ok "Installed Tandoor" + +msg_info "Install/Set up PostgreSQL Database" +curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg +echo "deb https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" >/etc/apt/sources.list.d/pgdg.list +$STD apt-get update +$STD apt-get install -y postgresql-16 +$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" +$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER TEMPLATE template0;" +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';" +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';" +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC'" +echo "" >>~/tandoor.creds +echo -e "Tandoor Database Name: \e[32m$DB_NAME\e[0m" >>~/tandoor.creds +echo -e "Tandoor Database User: \e[32m$DB_USER\e[0m" >>~/tandoor.creds +echo -e "Tandoor Database Password: \e[32m$DB_PASS\e[0m" >>~/tandoor.creds +export $(cat /opt/tandoor/.env |grep "^[^#]" | xargs) +/usr/bin/python3 /opt/tandoor/manage.py migrate >/dev/null 2>&1 +/usr/bin/python3 /opt/tandoor/manage.py collectstatic --no-input >/dev/null 2>&1 +/usr/bin/python3 /opt/tandoor/manage.py collectstatic_js_reverse >/dev/null 2>&1 +msg_ok "Set up PostgreSQL Database" + +msg_info "Creating Services" +cat <<EOF >/etc/systemd/system/gunicorn_tandoor.service +[Unit] +Description=gunicorn daemon for tandoor +After=network.target + +[Service] +Type=simple +Restart=always +RestartSec=3 +WorkingDirectory=/opt/tandoor +EnvironmentFile=/opt/tandoor/.env +ExecStart=/usr/local/bin/gunicorn --error-logfile /tmp/gunicorn_err.log --log-level debug --capture-output --bind unix:/opt/tandoor/tandoor.sock recipes.wsgi:application + +[Install] +WantedBy=multi-user.target +EOF + +cat << 'EOF' >/etc/nginx/conf.d/tandoor.conf +server { + listen 8002; + #access_log /var/log/nginx/access.log; + #error_log /var/log/nginx/error.log; + client_max_body_size 128M; + # serve media files + location /static/ { + alias /opt/tandoor/staticfiles/; + } + + location /media/ { + alias /opt/tandoor/mediafiles/; + } + + location / { + proxy_set_header Host $http_host; + proxy_pass http://unix:/opt/tandoor/tandoor.sock; + } +} +EOF +systemctl reload nginx +systemctl enable -q --now gunicorn_tandoor +msg_ok "Created Services" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/tasmoadmin-install.sh b/install/tasmoadmin-install.sh new file mode 100644 index 00000000..f0302945 --- /dev/null +++ b/install/tasmoadmin-install.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 php8.2 +$STD apt-get install -y libapache2-mod-php +$STD apt-get install -y php8.2-curl +$STD apt-get install -y php8.2-zip +$STD apt-get install -y php8.2-mbstring +$STD apt-get install -y php8.2-xml +$STD apt-get install -y git +msg_ok "Installed Dependencies" + +msg_info "Installing TasmoAdmin" +wget -q https://github.com/TasmoAdmin/TasmoAdmin/releases/download/v3.1.1/tasmoadmin_v3.1.1.tar.gz +tar -xzf tasmoadmin_v3.1.1.tar.gz -C /var/www/ +rm -rf tasmoadmin_v3.1.1.tar.gz /etc/php/8.2/apache2/conf.d/10-opcache.ini +chown -R www-data:www-data /var/www/tasmoadmin +chmod 777 /var/www/tasmoadmin/tmp /var/www/tasmoadmin/data +cat <<EOF >/etc/apache2/sites-available/tasmoadmin.conf +<VirtualHost *:9999> + ServerName tasmoadmin + ServerAdmin webmaster@localhost + DocumentRoot /var/www/tasmoadmin + <Directory /var/www/tasmoadmin> + AllowOverride All + Order allow,deny + allow from all + </Directory> + ErrorLog /var/log/apache2/error.log + LogLevel warn + CustomLog /var/log/apache2/access.log combined + ServerSignature On +</VirtualHost> +EOF +sed -i '6iListen 9999' /etc/apache2/ports.conf +$STD a2ensite tasmoadmin +$STD a2enmod rewrite +systemctl reload apache2 +systemctl restart apache2 +msg_ok "Installed TasmoAdmin" +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/tautulli-install.sh b/install/tautulli-install.sh new file mode 100644 index 00000000..23408390 --- /dev/null +++ b/install/tautulli-install.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 pip +msg_ok "Installed Dependencies" + +msg_info "Updating Python3" +$STD apt-get install -y \ + python3 \ + python3-dev \ + python3-pip +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +msg_ok "Updated Python3" + +msg_info "Installing Tautulli" +cd /opt +$STD git clone https://github.com/Tautulli/Tautulli.git +$STD pip install -q -r /opt/Tautulli/requirements.txt +$STD pip install pyopenssl +msg_ok "Installed Tautulli" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/tautulli.service +[Unit] +Description=Tautulli +After=syslog.target network.target + +[Service] +WorkingDirectory=/opt/Tautulli/ +Restart=on-failure +RestartSec=5 +Type=simple +ExecStart=/usr/bin/python3 /opt/Tautulli/Tautulli.py +KillSignal=SIGINT +TimeoutStopSec=20 +SyslogIdentifier=tautulli + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now tautulli +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/tdarr-install.sh b/install/tdarr-install.sh new file mode 100644 index 00000000..dccd9428 --- /dev/null +++ b/install/tdarr-install.sh @@ -0,0 +1,104 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 handbrake-cli +msg_ok "Installed Dependencies" + +msg_info "Setting Up Hardware Acceleration" +$STD apt-get -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools} +if [[ "$CTTYPE" == "0" ]]; then + chgrp video /dev/dri + chmod 755 /dev/dri + chmod 660 /dev/dri/* + $STD adduser $(id -u -n) video + $STD adduser $(id -u -n) render +fi +msg_ok "Set Up Hardware Acceleration" + +msg_info "Installing Tdarr" +mkdir -p /opt/tdarr +cd /opt/tdarr +RELEASE=$(curl -s https://f000.backblazeb2.com/file/tdarrs/versions.json | grep -oP '(?<="Tdarr_Updater": ")[^"]+' | grep linux_x64 | head -n 1) +wget -q $RELEASE +$STD unzip Tdarr_Updater.zip +rm -rf Tdarr_Updater.zip +chmod +x Tdarr_Updater +./Tdarr_Updater &>/dev/null +if [[ "$CTTYPE" == "0" ]]; then + sed -i -e 's/^sgx:x:104:$/render:x:104:root/' -e 's/^render:x:106:root$/sgx:x:106:/' /etc/group +else + sed -i -e 's/^sgx:x:104:$/render:x:104:/' -e 's/^render:x:106:$/sgx:x:106:/' /etc/group +fi + +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 +customize + +msg_info "Cleaning up" +rm -rf Tdarr_Updater.zip +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/technitiumdns-install.sh b/install/technitiumdns-install.sh new file mode 100644 index 00000000..12ea927d --- /dev/null +++ b/install/technitiumdns-install.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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/12/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-8.0 +msg_ok "Installed ASP.NET Core Runtime" + +msg_info "Installing Technitium DNS" +$STD bash <(curl -fsSL https://download.technitium.com/dns/install.sh) +msg_ok "Installed Technitium DNS" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/threadfin-install.sh b/install/threadfin-install.sh new file mode 100644 index 00000000..5fb8211d --- /dev/null +++ b/install/threadfin-install.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 sudo +$STD apt-get install -y mc +$STD apt-get install -y curl +$STD apt-get install -y ffmpeg +$STD apt-get install -y vlc +msg_ok "Installed Dependencies" + +msg_info "Installing Threadfin" +mkdir -p /opt/threadfin +wget -q -O /opt/threadfin/threadfin 'https://github.com/Threadfin/Threadfin/releases/latest/download/Threadfin_linux_amd64' +chmod +x /opt/threadfin/threadfin + +msg_ok "Installed Threadfin" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/threadfin.service +[Unit] +Description=Threadfin: M3U Proxy for Plex DVR and Emby/Jellyfin Live TV +After=syslog.target network.target +[Service] +Type=simple +WorkingDirectory=/opt/threadfin +ExecStart=/opt/threadfin/threadfin +TimeoutStopSec=20 +KillMode=process +Restart=on-failure +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now threadfin.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/traccar-install.sh b/install/traccar-install.sh new file mode 100644 index 00000000..f68d365e --- /dev/null +++ b/install/traccar-install.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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/traccar/traccar/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +msg_info "Installing Traccar v${RELEASE}" +wget -q https://github.com/traccar/traccar/releases/download/v${RELEASE}/traccar-linux-64-${RELEASE}.zip +$STD unzip traccar-linux-64-${RELEASE}.zip +$STD ./traccar.run +systemctl enable -q --now traccar +rm -rf README.txt traccar-linux-64-${RELEASE}.zip traccar.run +msg_ok "Installed Traccar v${RELEASE}" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/traefik-install.sh b/install/traefik-install.sh new file mode 100644 index 00000000..f418b68b --- /dev/null +++ b/install/traefik-install.sh @@ -0,0 +1,115 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +$STD apt-get install -y apt-transport-https +msg_ok "Installed Dependencies" + +RELEASE=$(curl -s https://api.github.com/repos/traefik/traefik/releases | grep -oP '"tag_name":\s*"v\K[\d.]+?(?=")' | sort -V | tail -n 1) +msg_info "Installing Traefik v${RELEASE}" +mkdir -p /etc/traefik/{conf.d,ssl} +wget -q https://github.com/traefik/traefik/releases/download/v${RELEASE}/traefik_v${RELEASE}_linux_amd64.tar.gz +tar -C /tmp -xzf traefik*.tar.gz +mv /tmp/traefik /usr/bin/ +rm -rf traefik*.tar.gz +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_ok "Installed Traefik v${RELEASE}" + +msg_info "Creating Traefik configuration" +cat <<EOF >/etc/traefik/traefik.yaml +providers: + file: + directory: /etc/traefik/conf.d/ + +entryPoints: + web: + address: ':80' + http: + redirections: + entryPoint: + to: websecure + scheme: https + websecure: + address: ':443' + http: + tls: + certResolver: letsencrypt + traefik: + address: ':8080' + +certificatesResolvers: + letsencrypt: + acme: + email: "foo@bar.com" + storage: /etc/traefik/ssl/acme.json + tlsChallenge: {} + +api: + dashboard: true + insecure: true + +log: + filePath: /var/log/traefik/traefik.log + format: json + level: INFO + +accessLog: + filePath: /var/log/traefik/traefik-access.log + format: json + filters: + statusCodes: + - "200" + - "400-599" + retryAttempts: true + minDuration: "10ms" + bufferingSize: 0 + fields: + headers: + defaultMode: drop + names: + User-Agent: keep +EOF +msg_ok "Created Traefik configuration" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/traefik.service +[Unit] +Description=Traefik is an open-source Edge Router that makes publishing your services a fun and easy experience + +[Service] +Type=notify +ExecStart=/usr/bin/traefik --configFile=/etc/traefik/traefik.yaml +Restart=on-failure +ExecReload=/bin/kill -USR1 \$MAINPID + +[Install] +WantedBy=multi-user.target +EOF + +systemctl enable -q --now traefik.service +msg_ok "Created Service" + + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/transmission-install.sh b/install/transmission-install.sh new file mode 100644 index 00000000..2550bb00 --- /dev/null +++ b/install/transmission-install.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/trilium-install.sh b/install/trilium-install.sh new file mode 100644 index 00000000..d2e7ae3f --- /dev/null +++ b/install/trilium-install.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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/TriliumNext/Notes/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') + +msg_info "Installing TriliumNext" +wget -q https://github.com/TriliumNext/Notes/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 TriliumNext" + +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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y 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..841dd3f3 --- /dev/null +++ b/install/ubuntu-install.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/umami-install.sh b/install/umami-install.sh new file mode 100644 index 00000000..8fd103b2 --- /dev/null +++ b/install/umami-install.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gpg +$STD apt-get install -y postgresql +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +$STD npm install -g yarn +msg_ok "Installed Node.js" + +msg_info "Setting up postgresql" +DB_NAME=umamidb +DB_USER=umami +DB_PASS="$(openssl rand -base64 18 | cut -c1-13)" +SECRET_KEY="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32)" +$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" +$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;" +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';" +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';" +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC'" +echo "" >~/umami.creds +echo "Umami Database Credentials" >>~/umami.creds +echo "" >>~/umami.creds +echo -e "umami Database User: \e[32m$DB_USER\e[0m" >>~/umami.creds +echo -e "umami Database Password: \e[32m$DB_PASS\e[0m" >>~/umami.creds +echo -e "umami Database Name: \e[32m$DB_NAME\e[0m" >>~/umami.creds +msg_ok "Set up postgresql" + +msg_info "Installing Umami (Patience)" +git clone -q https://github.com/umami-software/umami.git /opt/umami +cd /opt/umami +$STD yarn install +echo -e "DATABASE_URL=postgresql://$DB_USER:$DB_PASS@localhost:5432/$DB_NAME" >>/opt/umami/.env +$STD yarn run build +msg_ok "Installed Umami" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/umami.service +echo "[Unit] +Description=umami + +[Service] +Type=simple +Restart=always +User=root +WorkingDirectory=/opt/umami +ExecStart=/usr/bin/yarn run start + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now umami.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/umbrel-install.sh b/install/umbrel-install.sh new file mode 100644 index 00000000..f0411f49 --- /dev/null +++ b/install/umbrel-install.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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) +echo -e '{\n "log-driver": "journald"\n}' > /etc/docker/daemon.json +$STD bash <(curl -fsSL https://umbrel.sh) +systemctl daemon-reload +$STD systemctl enable --now umbrel-startup.service +msg_ok "Installed Umbrel" + +motd_ssh +customize + +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..5341ee58 --- /dev/null +++ b/install/unifi-install.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 gnupg +msg_ok "Installed Dependencies" + +msg_info "Installing Eclipse Temurin JRE" +wget -qO- https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor >/etc/apt/trusted.gpg.d/adoptium.gpg +echo "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/adoptium.gpg] https://packages.adoptium.net/artifactory/deb bookworm main" >/etc/apt/sources.list.d/adoptium.list +$STD apt-get update +$STD apt-get install -y temurin-17-jre +msg_ok "Installed Eclipse Temurin JRE" + +msg_info "Installing MongoDB" +wget -qO- https://www.mongodb.org/static/pgp/server-7.0.asc | gpg --dearmor >/usr/share/keyrings/mongodb-server-7.0.gpg +echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] http://repo.mongodb.org/apt/debian bookworm/mongodb-org/7.0 main" >/etc/apt/sources.list.d/mongodb-org-7.0.list +$STD apt-get update +$STD apt-get install -y mongodb-org +msg_ok "Installed MongoDB" + +msg_info "Installing UniFi Network Server" +wget -qO /etc/apt/trusted.gpg.d/unifi-repo.gpg https://dl.ui.com/unifi/unifi-repo.gpg +echo "deb [ arch=amd64 signed-by=/etc/apt/trusted.gpg.d/unifi-repo.gpg] https://www.ui.com/downloads/unifi/debian stable ubiquiti" >/etc/apt/sources.list.d/100-ubnt-unifi.list +$STD apt-get update +$STD apt-get install -y unifi +msg_ok "Installed UniFi Network Server" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/unmanic-install.sh b/install/unmanic-install.sh new file mode 100644 index 00000000..70b73dc8 --- /dev/null +++ b/install/unmanic-install.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +$STD apt-get install -y python3-pip +msg_ok "Installed Dependencies" + +if [[ "$CTTYPE" == "0" ]]; then + msg_info "Setting Up Hardware Acceleration" + $STD apt-get -y install \ + va-driver-all \ + ocl-icd-libopencl1 \ + intel-opencl-icd + chgrp video /dev/dri + chmod 755 /dev/dri + chmod 660 /dev/dri/* + $STD adduser $(id -u -n) video + $STD adduser $(id -u -n) render + msg_ok "Set Up Hardware Acceleration" +fi + +msg_info "Installing Unmanic" +$STD pip3 install unmanic +sed -i -e 's/^sgx:x:104:$/render:x:104:root/' -e 's/^render:x:106:root$/sgx:x:106:/' /etc/group +msg_ok "Installed Unmanic" + +msg_info "Creating Service" +cat << EOF >/etc/systemd/system/unmanic.service +[Unit] +Description=Unmanic - Library Optimiser +After=network-online.target +StartLimitInterval=200 +StartLimitBurst=3 + +[Service] +Type=simple +ExecStart=/usr/local/bin/unmanic +Restart=always +RestartSec=30 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable --now -q unmanic.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/uptimekuma-install.sh b/install/uptimekuma-install.sh new file mode 100644 index 00000000..4a429191 --- /dev/null +++ b/install/uptimekuma-install.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 ca-certificates +$STD apt-get install -y gnupg +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD 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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/vaultwarden-install.sh b/install/vaultwarden-install.sh new file mode 100644 index 00000000..c76297e3 --- /dev/null +++ b/install/vaultwarden-install.sh @@ -0,0 +1,119 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 update +$STD apt-get -qqy install \ + git \ + build-essential \ + pkgconf \ + libssl-dev \ + libmariadb-dev-compat \ + libpq-dev \ + curl \ + sudo \ + argon2 \ + mc +msg_ok "Installed Dependencies" + +WEBVAULT=$(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) }') + +VAULT=$(curl -s https://api.github.com/repos/dani-garcia/vaultwarden/releases/latest | + grep "tag_name" | + awk '{print substr($2, 2, length($2)-3) }') + +msg_info "Installing Rust" +wget -qL https://sh.rustup.rs +$STD bash index.html -y --profile minimal +echo 'export PATH=~/.cargo/bin:$PATH' >>~/.bashrc +export PATH=~/.cargo/bin:$PATH +rm index.html +msg_ok "Installed Rust" + +msg_info "Building Vaultwarden ${VAULT} (Patience)" +$STD git clone https://github.com/dani-garcia/vaultwarden +cd vaultwarden +$STD cargo build --features "sqlite,mysql,postgresql" --release +msg_ok "Built Vaultwarden ${VAULT}" + +$STD addgroup --system vaultwarden +$STD adduser --system --home /opt/vaultwarden --shell /usr/sbin/nologin --no-create-home --gecos 'vaultwarden' --ingroup vaultwarden --disabled-login --disabled-password vaultwarden +mkdir -p /opt/vaultwarden/bin +mkdir -p /opt/vaultwarden/data +cp target/release/vaultwarden /opt/vaultwarden/bin/ + +msg_info "Downloading Web-Vault ${WEBVAULT}" +$STD curl -fsSLO https://github.com/dani-garcia/bw_web_builds/releases/download/$WEBVAULT/bw_web_$WEBVAULT.tar.gz +$STD tar -xzf bw_web_$WEBVAULT.tar.gz -C /opt/vaultwarden/ +msg_ok "Downloaded Web-Vault ${WEBVAULT}" + +cat <<EOF >/opt/vaultwarden/.env +ADMIN_TOKEN='' +ROCKET_ADDRESS=0.0.0.0 +DATA_FOLDER=/opt/vaultwarden/data +DATABASE_MAX_CONNS=10 +WEB_VAULT_FOLDER=/opt/vaultwarden/web-vault +WEB_VAULT_ENABLED=true +EOF + +msg_info "Creating Service" +chown -R vaultwarden:vaultwarden /opt/vaultwarden/ +chown root:root /opt/vaultwarden/bin/vaultwarden +chmod +x /opt/vaultwarden/bin/vaultwarden +chown -R root:root /opt/vaultwarden/web-vault/ +chmod +r /opt/vaultwarden/.env + +service_path="/etc/systemd/system/vaultwarden.service" +echo "[Unit] +Description=Bitwarden Server (Powered by Vaultwarden) +Documentation=https://github.com/dani-garcia/vaultwarden +After=network.target +[Service] +User=vaultwarden +Group=vaultwarden +EnvironmentFile=-/opt/vaultwarden/.env +ExecStart=/opt/vaultwarden/bin/vaultwarden +LimitNOFILE=65535 +LimitNPROC=4096 +PrivateTmp=true +PrivateDevices=true +ProtectHome=true +ProtectSystem=strict +DevicePolicy=closed +ProtectControlGroups=yes +ProtectKernelModules=yes +ProtectKernelTunables=yes +RestrictNamespaces=yes +RestrictRealtime=yes +MemoryDenyWriteExecute=yes +LockPersonality=yes +WorkingDirectory=/opt/vaultwarden +ReadWriteDirectories=/opt/vaultwarden/data +AmbientCapabilities=CAP_NET_BIND_SERVICE +[Install] +WantedBy=multi-user.target" >$service_path +systemctl daemon-reload +$STD systemctl enable --now vaultwarden.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/wastebin-install.sh b/install/wastebin-install.sh new file mode 100644 index 00000000..b9faec80 --- /dev/null +++ b/install/wastebin-install.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck +# Co-Author: MickLesk (Canbiz) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +# Source: https://github.com/matze/wastebin + +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 Wastebin" +RELEASE=$(curl -s https://api.github.com/repos/matze/wastebin/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +wget -q https://github.com/matze/wastebin/releases/download/${RELEASE}/wastebin_${RELEASE}_x86_64-unknown-linux-musl.tar.zst +tar -xf wastebin_${RELEASE}_x86_64-unknown-linux-musl.tar.zst +rm -rf wastebin_${RELEASE}_x86_64-unknown-linux-musl.tar.zst +mkdir -p /opt/wastebin +mv wastebin /opt/wastebin/ +chmod +x /opt/wastebin/wastebin +msg_ok "Installed Wastebin" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/wastebin.service +[Unit] +Description=Start Wastebin Service +After=network.target + +[Service] +WorkingDirectory=/opt/wastebin +ExecStart=/opt/wastebin/wastebin + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now wastebin.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/watchyourlan-install.sh b/install/watchyourlan-install.sh new file mode 100644 index 00000000..c54342c5 --- /dev/null +++ b/install/watchyourlan-install.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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,sudo,mc,gpg,arp-scan,ieee-data,libwww-perl} +msg_ok "Installed Dependencies" + +msg_info "Installing WatchYourLAN" +RELEASE=$(curl -s https://api.github.com/repos/aceberg/WatchYourLAN/releases/latest | grep -o '"tag_name": *"[^"]*"' | cut -d '"' -f 4) +wget -q https://github.com/aceberg/WatchYourLAN/releases/download/$RELEASE/watchyourlan_${RELEASE}_linux_amd64.deb +$STD dpkg -i watchyourlan_${RELEASE}_linux_amd64.deb +rm watchyourlan_${RELEASE}_linux_amd64.deb +mkdir /data +cat <<EOF >/data/config.yaml +arp_timeout: "500" +auth: false +auth_expire: 7d +auth_password: "" +auth_user: "" +color: dark +dbpath: /data/db.sqlite +guiip: 0.0.0.0 +guiport: "8840" +history_days: "30" +iface: eth0 +ignoreip: "no" +loglevel: verbose +shoutrrr_url: "" +theme: solar +timeout: 60 +EOF +msg_ok "Installed WatchYourLAN" + +msg_info "Creating Service" +sed -i 's|/etc/watchyourlan/config.yaml|/data/config.yaml|' /lib/systemd/system/watchyourlan.service +systemctl enable -q --now watchyourlan.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/whisparr-install.sh b/install/whisparr-install.sh new file mode 100644 index 00000000..16d20893 --- /dev/null +++ b/install/whisparr-install.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 <<EOF >/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 +customize + +msg_info "Cleaning up" +rm -rf Whisparr.develop.*.tar.gz +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/whoogle-install.sh b/install/whoogle-install.sh new file mode 100644 index 00000000..f3516d32 --- /dev/null +++ b/install/whoogle-install.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 "Updating Python3" +$STD apt-get install -y \ + python3 \ + python3-dev \ + python3-pip +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +msg_ok "Updated Python3" + +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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/wikijs-install.sh b/install/wikijs-install.sh new file mode 100644 index 00000000..fe95122e --- /dev/null +++ b/install/wikijs-install.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 ca-certificates +$STD apt-get install -y gnupg +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$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 <<EOF >/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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/wireguard-install.sh b/install/wireguard-install.sh new file mode 100644 index 00000000..1b12dfbf --- /dev/null +++ b/install/wireguard-install.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 WireGuard" +$STD apt-get install -y wireguard wireguard-tools net-tools iptables +iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE +DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confnew" install -y iptables-persistent &>/dev/null +$STD netfilter-persistent reload +msg_ok "Installed WireGuard" + +msg_info "Installing WGDashboard" +git clone -q https://github.com/donaldzou/WGDashboard.git /etc/wgdashboard +cd /etc/wgdashboard/src +chmod u+x wgd.sh +$STD ./wgd.sh install +echo "net.ipv4.ip_forward=1" >>/etc/sysctl.conf +$STD sysctl -p /etc/sysctl.conf +msg_ok "Installed WGDashboard" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/wg-dashboard.service +[Unit] +After=syslog.target network-online.target +Wants=wg-quick.target +ConditionPathIsDirectory=/etc/wireguard + +[Service] +Type=forking +PIDFile=/etc/wgdashboard/src/gunicorn.pid +WorkingDirectory=/etc/wgdashboard/src +ExecStart=/etc/wgdashboard/src/wgd.sh start +ExecStop=/etc/wgdashboard/src/wgd.sh stop +ExecReload=/etc/wgdashboard/src/wgd.sh restart +TimeoutSec=120 +PrivateTmp=yes +Restart=always + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now wg-dashboard.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/yunohost-install.sh b/install/yunohost-install.sh new file mode 100644 index 00000000..75cdc55c --- /dev/null +++ b/install/yunohost-install.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 lsb-release +$STD apt-get install -y ca-certificates +msg_ok "Installed Dependencies" + +msg_info "Installing YunoHost (Patience)" +touch /etc/.pve-ignore.resolv.conf +curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg +$STD bash <(curl -fsSL https://install.yunohost.org) -a +msg_ok "Installed YunoHost" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/zabbix-install.sh b/install/zabbix-install.sh new file mode 100644 index 00000000..c7123dea --- /dev/null +++ b/install/zabbix-install.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 Zabbix" +wget -q https://repo.zabbix.com/zabbix/7.0/debian/pool/main/z/zabbix-release/zabbix-release_7.0-1+debian12_all.deb +$STD dpkg -i zabbix-release_7.0-1+debian12_all.deb +rm zabbix-release_7.0-1+debian12_all.deb +$STD apt-get update +$STD apt-get install -y zabbix-server-pgsql zabbix-frontend-php php8.2-pgsql zabbix-apache-conf zabbix-sql-scripts zabbix-agent +msg_ok "Installed Zabbix" + +msg_info "Setting up PostgreSQL" +$STD apt-get install -y postgresql +DB_NAME=zabbixdb +DB_USER=zabbix +DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13) +$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" +$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;" +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';" +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';" +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC'" +zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u $DB_USER psql $DB_NAME &>/dev/null +sed -i "s/^DBName=.*/DBName=$DB_NAME/" /etc/zabbix/zabbix_server.conf +sed -i "s/^DBUser=.*/DBUser=$DB_USER/" /etc/zabbix/zabbix_server.conf +sed -i "s/^# DBPassword=.*/DBPassword=$DB_PASS/" /etc/zabbix/zabbix_server.conf +echo "" >~/zabbix.creds +echo "zabbix Database Credentials" >>~/zabbix.creds +echo "" >>~/zabbix.creds +echo -e "zabbix Database User: \e[32m$DB_USER\e[0m" >>~/zabbix.creds +echo -e "zabbix Database Password: \e[32m$DB_PASS\e[0m" >>~/zabbix.creds +echo -e "zabbix Database Name: \e[32m$DB_NAME\e[0m" >>~/zabbix.creds +msg_ok "Set up PostgreSQL" + +msg_info "Starting Services" +systemctl restart zabbix-server zabbix-agent apache2 +systemctl enable -q zabbix-server zabbix-agent apache2 +msg_ok "Started Services" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/zigbee2mqtt-install.sh b/install/zigbee2mqtt-install.sh new file mode 100644 index 00000000..55acdcbc --- /dev/null +++ b/install/zigbee2mqtt-install.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 +$STD apt-get install -y ca-certificates +$STD apt-get install -y gnupg +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Installed Node.js" + +msg_info "Setting up Zigbee2MQTT Repository" +$STD git clone --depth 1 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 fetch origin dev:dev +$STD git checkout dev +$STD git pull +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 +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/zoraxy-install.sh b/install/zoraxy-install.sh new file mode 100644 index 00000000..73787ed1 --- /dev/null +++ b/install/zoraxy-install.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 Golang" +set +o pipefail +RELEASE=$(curl -s https://go.dev/dl/ | grep -o "go.*\linux-amd64.tar.gz" | head -n 1) +wget -q https://golang.org/dl/$RELEASE +$STD tar -xzf $RELEASE -C /usr/local +$STD ln -s /usr/local/go/bin/go /usr/local/bin/go +set -o pipefail +msg_ok "Installed Golang" + +msg_info "Installing Zoraxy (Patience)" +$STD git clone https://github.com/tobychui/zoraxy /opt/zoraxy +cd /opt/zoraxy/src +$STD go mod tidy +$STD go build +msg_ok "Installed Zoraxy" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/zoraxy.service +[Unit] +Description=General purpose request proxy and forwarding tool +After=syslog.target network-online.target + +[Service] +ExecStart=/opt/zoraxy/src/./zoraxy +WorkingDirectory=/opt/zoraxy/src/ +Restart=always + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now zoraxy.service +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -rf $RELEASE +$STD apt-get -y autoremove +$STD apt-get -y 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..c1966ed4 --- /dev/null +++ b/install/zwave-js-ui-install.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 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 +customize + +msg_info "Cleaning up" +rm zwave-js-ui-${RELEASE}-linux.zip +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/misc/add-netbird-lxc.sh b/misc/add-netbird-lxc.sh new file mode 100644 index 00000000..05427106 --- /dev/null +++ b/misc/add-netbird-lxc.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + _ __ __ ____ _ __ + / | / /__ / /_/ __ )(_)________/ / + / |/ / _ \/ __/ __ / / ___/ __ / + / /| / __/ /_/ /_/ / / / / /_/ / +/_/ |_/\___/\__/_____/_/_/ \__,_/ + +EOF +} +header_info +set -e +while true; do + read -p "This will add NetBird to an existing LXC Container ONLY. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac +done +header_info +echo "Loading..." +function msg() { + local TEXT="$1" + echo -e "$TEXT" +} + +NODE=$(hostname) +MSG_MAX_LENGTH=0 +while read -r line; do + TAG=$(echo "$line" | awk '{print $1}') + ITEM=$(echo "$line" | awk '{print substr($0,36)}') + OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + CTID_MENU+=("$TAG" "$ITEM " "OFF") +done < <(pct list | awk 'NR>1') + +while [ -z "${CTID:+x}" ]; do + CTID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Containers on $NODE" --radiolist \ + "\nSelect a container to add NetBird to:\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit +done + +CTID_CONFIG_PATH=/etc/pve/lxc/${CTID}.conf +cat <<EOF >>$CTID_CONFIG_PATH +lxc.cgroup2.devices.allow: c 10:200 rwm +lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file +EOF +header_info +msg "Installing NetBird..." +pct exec "$CTID" -- bash -c ' +apt install -y ca-certificates gpg &>/dev/null +wget -qO- https://pkgs.netbird.io/debian/public.key | gpg --dearmor >/usr/share/keyrings/netbird-archive-keyring.gpg +echo "deb [signed-by=/usr/share/keyrings/netbird-archive-keyring.gpg] https://pkgs.netbird.io/debian stable main" >/etc/apt/sources.list.d/netbird.list +apt-get update &>/dev/null +apt-get install -y netbird-ui &>/dev/null +' || exit +msg "\e[1;32m ✔ Installed NetBird.\e[0m" +sleep 2 +msg "\e[1;31m Reboot ${CTID} LXC to apply the changes, then run netbird up in the LXC console\e[0m" diff --git a/misc/add-tailscale-lxc.sh b/misc/add-tailscale-lxc.sh index ba0e37a2..13307333 100644 --- a/misc/add-tailscale-lxc.sh +++ b/misc/add-tailscale-lxc.sh @@ -1,45 +1,72 @@ #!/usr/bin/env bash -echo -e "\e[1;33mThis script will add Tailscale to an existing LXC Container ONLY\e[0m" -while true; do - read -p "Did you replace 106 with your LXC ID? Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE -function error_exit() { - trap - ERR - local reason="Unknown failure occured." - local msg="${1:-$reason}" - local flag="\e[1;31m‼ ERROR\e[0m $EXIT@$LINE" - echo -e "$flag $msg" 1>&2 - exit $EXIT +function header_info { +clear +cat <<"EOF" + ______ _ __ __ + /_ __/___ _(_) /_____________ _/ /__ + / / / __ `/ / / ___/ ___/ __ `/ / _ \ + / / / /_/ / / (__ ) /__/ /_/ / / __/ +/_/ \__,_/_/_/____/\___/\__,_/_/\___/ + +EOF } +header_info +set -e +while true; do + read -p "This will add Tailscale to an existing LXC Container ONLY. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac +done +header_info +echo "Loading..." function msg() { local TEXT="$1" echo -e "$TEXT" } -CTID=$1 +NODE=$(hostname) +MSG_MAX_LENGTH=0 +while read -r line; do + TAG=$(echo "$line" | awk '{print $1}') + ITEM=$(echo "$line" | awk '{print substr($0,36)}') + OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + CTID_MENU+=("$TAG" "$ITEM " "OFF") +done < <(pct list | awk 'NR>1') + +while [ -z "${CTID:+x}" ]; do + CTID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Containers on $NODE" --radiolist \ + "\nSelect a container to add Tailscale to:\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit +done + CTID_CONFIG_PATH=/etc/pve/lxc/${CTID}.conf -cat <<EOF >> $CTID_CONFIG_PATH +cat <<EOF >>$CTID_CONFIG_PATH lxc.cgroup2.devices.allow: c 10:200 rwm lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file EOF +header_info +msg "Installing Tailscale..." +pct exec "$CTID" -- bash -c ' +ID=$(grep "^ID=" /etc/os-release | cut -d"=" -f2) +VER=$(grep "^VERSION_CODENAME=" /etc/os-release | cut -d"=" -f2) +wget -qO- https://pkgs.tailscale.com/stable/$ID/$VER.noarmor.gpg >/usr/share/keyrings/tailscale-archive-keyring.gpg +echo "deb [signed-by=/usr/share/keyrings/tailscale-archive-keyring.gpg] https://pkgs.tailscale.com/stable/$ID $VER main" >/etc/apt/sources.list.d/tailscale.list +apt-get update &>/dev/null +apt-get install -y tailscale &>/dev/null +' || exit +msg "\e[1;32m ✔ Installed Tailscale\e[0m" -msg "⏳ Installing Tailscale..." -lxc-attach -n $CTID -- bash -c "$(curl -fsSL https://tailscale.com/install.sh)" &>/dev/null || exit -msg "⌛ Installed Tailscale" -sleep 2 -msg "\e[1;32m ✔ Completed Successfully!\e[0m" msg "\e[1;31m Reboot ${CTID} LXC to apply the changes, then run tailscale up in the LXC console\e[0m" diff --git a/misc/all-templates.sh b/misc/all-templates.sh new file mode 100644 index 00000000..ab430e7c --- /dev/null +++ b/misc/all-templates.sh @@ -0,0 +1,209 @@ +#!/usr/bin/env bash +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + ___ ____ ______ __ __ + / _ | / / / /_ __/__ __ _ ___ / /__ _/ /____ ___ + / __ |/ / / / / / -_) ' \/ _ \/ / _ `/ __/ -_|_-< +/_/ |_/_/_/ /_/ \__/_/_/_/ .__/_/\_,_/\__/\__/___/ + /_/ +EOF +} + +set -eEuo pipefail +shopt -s expand_aliases +alias die='EXIT=$? LINE=$LINENO error_exit' +trap die ERR +function error_exit() { + trap - ERR + local DEFAULT='Unknown failure occured.' + local REASON="\e[97m${1:-$DEFAULT}\e[39m" + local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" + msg "$FLAG $REASON" 1>&2 + [ ! -z ${CTID-} ] && cleanup_ctid + exit $EXIT +} +function warn() { + local REASON="\e[97m$1\e[39m" + local FLAG="\e[93m[WARNING]\e[39m" + msg "$FLAG $REASON" +} +function info() { + local REASON="$1" + local FLAG="\e[36m[INFO]\e[39m" + msg "$FLAG $REASON" +} +function msg() { + local TEXT="$1" + echo -e "$TEXT" +} +function cleanup_ctid() { + if pct status $CTID &>/dev/null; then + if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then + pct stop $CTID + fi + pct destroy $CTID + fi +} + +# Stop Proxmox VE Monitor-All if running +if systemctl is-active -q ping-instances.service; then + systemctl stop ping-instances.service +fi +header_info +echo "Loading..." +pveam update >/dev/null 2>&1 +whiptail --backtitle "Proxmox VE Helper Scripts" --title "All Templates" --yesno "This will allow for the creation of one of the many Template LXC Containers. Proceed?" 10 68 || exit +TEMPLATE_MENU=() +MSG_MAX_LENGTH=0 +while read -r TAG ITEM; do + OFFSET=2 + ((${#ITEM} + OFFSET > MSG_MAX_LENGTH)) && MSG_MAX_LENGTH=${#ITEM}+OFFSET + TEMPLATE_MENU+=("$ITEM" "$TAG " "OFF") +done < <(pveam available) +TEMPLATE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "All Template LXCs" --radiolist "\nSelect a Template LXC to create:\n" 16 $((MSG_MAX_LENGTH + 58)) 10 "${TEMPLATE_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"') || exit +[ -z "$TEMPLATE" ] && { + whiptail --backtitle "Proxmox VE Helper Scripts" --title "No Template LXC Selected" --msgbox "It appears that no Template LXC container was selected" 10 68 + msg "Done" + exit +} + +# Setup script environment +NAME=$(echo "$TEMPLATE" | grep -oE '^[^-]+-[^-]+') +PASS="$(openssl rand -base64 8)" +CTID=$(pvesh get /cluster/nextid) +PCT_OPTIONS=" + -features keyctl=1,nesting=1 + -hostname $NAME + -tags proxmox-helper-scripts + -onboot 0 + -cores 2 + -memory 2048 + -password $PASS + -net0 name=eth0,bridge=vmbr0,ip=dhcp + -unprivileged 1 + " +DEFAULT_PCT_OPTIONS=( + -arch $(dpkg --print-architecture) +) + +# Set the CONTENT and CONTENT_LABEL variables +function select_storage() { + local CLASS=$1 + local CONTENT + local CONTENT_LABEL + case $CLASS in + container) + CONTENT='rootdir' + CONTENT_LABEL='Container' + ;; + template) + CONTENT='vztmpl' + CONTENT_LABEL='Container template' + ;; + *) false || die "Invalid storage class." ;; + esac + + # Query all storage locations + local -a MENU + while read -r line; do + local TAG=$(echo $line | awk '{print $1}') + local TYPE=$(echo $line | awk '{printf "%-10s", $2}') + local FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') + local ITEM=" Type: $TYPE Free: $FREE " + local OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + MENU+=("$TAG" "$ITEM" "OFF") + done < <(pvesm status -content $CONTENT | awk 'NR>1') + + # Select storage location + if [ $((${#MENU[@]} / 3)) -eq 0 ]; then + warn "'$CONTENT_LABEL' needs to be selected for at least one storage location." + die "Unable to detect valid storage location." + elif [ $((${#MENU[@]} / 3)) -eq 1 ]; then + printf ${MENU[0]} + else + local STORAGE + while [ -z "${STORAGE:+x}" ]; do + STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Storage Pools" --radiolist \ + "Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${MENU[@]}" 3>&1 1>&2 2>&3) || die "Menu aborted." + done + printf $STORAGE + fi +} +header_info +# Get template storage +TEMPLATE_STORAGE=$(select_storage template) || exit +info "Using '$TEMPLATE_STORAGE' for template storage." + +# Get container storage +CONTAINER_STORAGE=$(select_storage container) || exit +info "Using '$CONTAINER_STORAGE' for container storage." + +# Download template +msg "Downloading LXC template (Patience)..." +pveam download $TEMPLATE_STORAGE $TEMPLATE >/dev/null || die "A problem occured while downloading the LXC template." + +# Create variable for 'pct' options +PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}}) +[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=(-rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8}) + +# Create LXC +msg "Creating LXC container..." +pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null || + die "A problem occured while trying to create container." + +# Save password +echo "$NAME password: ${PASS}" >>~/$NAME.creds # file is located in the Proxmox root directory + +# Start container +msg "Starting LXC Container..." +pct start "$CTID" +sleep 5 + +# Get container IP +set +eEuo pipefail +max_attempts=5 +attempt=1 +IP="" +while [[ $attempt -le $max_attempts ]]; do + IP=$(pct exec $CTID ip a show dev eth0 | grep -oP 'inet \K[^/]+') + if [[ -n $IP ]]; then + break + else + warn "Attempt $attempt: IP address not found. Pausing for 5 seconds..." + sleep 5 + ((attempt++)) + fi +done + +if [[ -z $IP ]]; then + warn "Maximum number of attempts reached. IP address not found." + IP="NOT FOUND" +fi + +set -eEuo pipefail +# Start Proxmox VE Monitor-All if available +if [[ -f /etc/systemd/system/ping-instances.service ]]; then + systemctl start ping-instances.service +fi + +# Success message +header_info +echo +info "LXC container '$CTID' was successfully created, and its IP address is ${IP}." +echo +info "Proceed to the LXC console to complete the setup." +echo +info "login: root" +info "password: $PASS" +echo diff --git a/misc/alpine-install.func b/misc/alpine-install.func new file mode 100644 index 00000000..3820d637 --- /dev/null +++ b/misc/alpine-install.func @@ -0,0 +1,120 @@ +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 + STD="" + else STD="silent"; fi + silent() { "$@" >/dev/null 2>&1; } + if [ "$DISABLEIPV6" == "yes" ]; then + $STD sysctl -w net.ipv6.conf.all.disable_ipv6=1 + echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf + $STD rc-update add sysctl default + 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 + 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? <y/N> " 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 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 + sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config + $STD /etc/init.d/sshd start + fi +} + +customize() { + if [[ "$PASSWORD" == "" ]]; then + msg_info "Customizing Container" + bash -c "passwd -d root" >/dev/null 2>&1 + msg_ok "Customized Container" + fi +} diff --git a/misc/build.func b/misc/build.func new file mode 100644 index 00000000..b650a6c0 --- /dev/null +++ b/misc/build.func @@ -0,0 +1,652 @@ +variables() { + NSAPP=$(echo ${APP,,} | tr -d ' ') # This function sets the NSAPP variable by converting the value of the APP variable to lowercase and removing any spaces. + var_install="${NSAPP}-install" # sets the var_install variable by appending "-install" to the value of NSAPP. + INTEGER='^[0-9]+([.][0-9]+)?$' # it defines the INTEGER regular expression pattern. +} + +# This function sets various color variables using ANSI escape codes for formatting text in the terminal. +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=" " +} + +# This function enables error handling in the script by setting options and defining a trap for the ERR signal. +catch_errors() { + set -Eeuo pipefail + trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +} + +# This function is called when an error occurs. It receives the exit code, line number, and command that caused the error, and displays an error message. +error_handler() { + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi + printf "\e[?25h" + 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" +} + +# This function displays a spinner. +spinner() { + local chars="/-\|" + local spin_i=0 + printf "\e[?25l" + while true; do + printf "\r \e[36m%s\e[0m" "${chars:spin_i++%${#chars}:1}" + sleep 0.1 + done +} + +# This function displays an informational message with a yellow color. +msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg} " + spinner & + SPINNER_PID=$! +} + +# This function displays a success message with a green color. +msg_ok() { + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi + printf "\e[?25h" + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" +} + +# This function displays a error message with a red color. +msg_error() { + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi + printf "\e[?25h" + local msg="$1" + echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" +} + +# Check if the shell is using bash +shell_check() { + if [[ "$(basename "$SHELL")" != "bash" ]]; then + clear + msg_error "Your default shell is currently not set to Bash. To use these scripts, please switch to the Bash shell." + echo -e "\nExiting..." + sleep 2 + exit + fi +} + +# Run as root only +root_check() { + if [[ "$(id -u)" -ne 0 || $(ps -o comm= -p $PPID) == "sudo" ]]; then + clear + msg_error "Please run this script as root." + echo -e "\nExiting..." + sleep 2 + exit + fi +} + +# This function checks the version of Proxmox Virtual Environment (PVE) and exits if the version is not supported. +pve_check() { + if ! pveversion | grep -Eq "pve-manager/8.[1-3]"; then + msg_error "This version of Proxmox Virtual Environment is not supported" + echo -e "Requires Proxmox Virtual Environment Version 8.1 or later." + echo -e "Exiting..." + sleep 2 + exit +fi +} + +# This function checks the system architecture and exits if it's not "amd64". +arch_check() { + if [ "$(dpkg --print-architecture)" != "amd64" ]; then + echo -e "\n ${CROSS} This script will not work with PiMox! \n" + echo -e "\n Visit https://github.com/asylumexp/Proxmox for ARM64 support. \n" + echo -e "Exiting..." + sleep 2 + exit + fi +} + +# This function checks if the script is running through SSH and prompts the user to confirm if they want to proceed or exit. +ssh_check() { + if command -v pveversion >/dev/null 2>&1 && [ -n "${SSH_CLIENT:+x}" ]; then + if whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SSH DETECTED" --yesno "It's advisable to utilize the Proxmox shell rather than SSH, as there may be potential complications with variable retrieval. Proceed using SSH?" 10 72; then + whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "Proceed using SSH" "You've chosen to proceed using SSH. If any issues arise, please run the script in the Proxmox shell before creating a repository issue." 10 72 + else + clear + echo "Exiting due to SSH usage. Please consider using the Proxmox shell." + exit + fi + fi +} + +# This function displays the default values for various settings. +echo_default() { + echo -e "${DGN}Using Distribution: ${BGN}$var_os${CL}" + 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 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 IP Address: ${BGN}Default${CL}" + echo -e "${DGN}Using Apt-Cacher IP 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}" +} + +# This function is called when the user decides to exit the script. It clears the screen and displays an exit message. +exit-script() { + clear + echo -e "⚠ User exited script \n" + exit +} + +# This function allows the user to configure advanced settings for the script. +advanced_settings() { + whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "Here is an instructional tip:" "To make a selection, use the Spacebar." 8 58 + whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "Default distribution for $APP" "${var_os} ${var_version} \n \nIf the default Linux distribution is not adhered to, script support will be discontinued. \n" 10 58 + if [ "$var_os" != "alpine" ]; then + var_os="" + while [ -z "$var_os" ]; do + if var_os=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "DISTRIBUTION" --radiolist "Choose Distribution:" 10 58 2 \ + "debian" "" OFF \ + "ubuntu" "" OFF \ + 3>&1 1>&2 2>&3); then + if [ -n "$var_os" ]; then + echo -e "${DGN}Using Distribution: ${BGN}$var_os${CL}" + fi + else + exit-script + fi + done + fi + + if [ "$var_os" == "debian" ]; then + var_version="" + while [ -z "$var_version" ]; do + if var_version=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "DEBIAN VERSION" --radiolist "Choose Version" 10 58 2 \ + "11" "Bullseye" OFF \ + "12" "Bookworm" OFF \ + 3>&1 1>&2 2>&3); then + if [ -n "$var_version" ]; then + echo -e "${DGN}Using $var_os Version: ${BGN}$var_version${CL}" + fi + else + exit-script + fi + done + fi + + if [ "$var_os" == "ubuntu" ]; then + var_version="" + while [ -z "$var_version" ]; do + if var_version=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UBUNTU VERSION" --radiolist "Choose Version" 10 58 3 \ + "20.04" "Focal" OFF \ + "22.04" "Jammy" OFF \ + "24.04" "Noble" OFF \ + 3>&1 1>&2 2>&3); then + if [ -n "$var_version" ]; then + echo -e "${DGN}Using $var_os Version: ${BGN}$var_version${CL}" + fi + else + exit-script + fi + done + fi + + CT_TYPE="" + while [ -z "$CT_TYPE" ]; do + if CT_TYPE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "CONTAINER TYPE" --radiolist "Choose Type" 10 58 2 \ + "1" "Unprivileged" OFF \ + "0" "Privileged" OFF \ + 3>&1 1>&2 2>&3); then + if [ -n "$CT_TYPE" ]; then + echo -e "${DGN}Using Container Type: ${BGN}$CT_TYPE${CL}" + fi + else + exit-script + fi + done + + while true; do + if PW1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --passwordbox "\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 + if [[ "$PW1" == *" "* ]]; then + whiptail --msgbox "Password cannot contain spaces. Please try again." 8 58 + elif [ ${#PW1} -lt 5 ]; then + whiptail --msgbox "Password must be at least 5 characters long. Please try again." 8 58 + else + if PW2=$(whiptail --backtitle "Proxmox VE Helper Scripts" --passwordbox "\nVerify Root Password" 9 58 --title "PASSWORD VERIFICATION" 3>&1 1>&2 2>&3); then + if [[ "$PW1" == "$PW2" ]]; then + PW="-password $PW1" + echo -e "${DGN}Using Root Password: ${BGN}********${CL}" + break + else + whiptail --msgbox "Passwords do not match. Please try again." 8 58 + fi + else + exit-script + fi + fi + else + PW1="Automatic Login" + PW="" + echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" + break + fi + else + exit-script + fi + done + + + if CT_ID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 + + while true; do + NET=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Static IPv4 CIDR Address (/24)" 8 58 dhcp --title "IP ADDRESS" 3>&1 1>&2 2>&3) + exit_status=$? + if [ $exit_status -eq 0 ]; then + if [ "$NET" = "dhcp" ]; then + echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" + break + else + if [[ "$NET" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}/([0-9]|[1-2][0-9]|3[0-2])$ ]]; then + echo -e "${DGN}Using IP Address: ${BGN}$NET${CL}" + break + else + whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox "$NET is an invalid IPv4 CIDR address. Please enter a valid IPv4 CIDR address or 'dhcp'" 8 58 + fi + fi + else + exit-script + fi + done + + if [ "$NET" != "dhcp" ]; then + while true; do + GATE1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Enter gateway IP address" 8 58 --title "Gateway IP" 3>&1 1>&2 2>&3) + if [ -z "$GATE1" ]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox "Gateway IP address cannot be empty" 8 58 + elif [[ ! "$GATE1" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox "Invalid IP address format" 8 58 + else + GATE=",gw=$GATE1" + echo -e "${DGN}Using Gateway IP Address: ${BGN}$GATE1${CL}" + break + fi + done + else + GATE="" + echo -e "${DGN}Using Gateway IP Address: ${BGN}Default${CL}" + fi + + if [ "$var_os" == "alpine" ]; then + APT_CACHER="" + APT_CACHER_IP="" + else + if APT_CACHER_IP=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set APT-Cacher IP (leave blank for default)" 8 58 --title "APT-Cacher IP" 3>&1 1>&2 2>&3); then + APT_CACHER="${APT_CACHER_IP:+yes}" + echo -e "${DGN}Using APT-Cacher IP Address: ${BGN}${APT_CACHER_IP:-Default}${CL}" + else + exit-script + fi + fi + + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 [[ "$PW" == -password* ]]; then + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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}" + else + SSH="no" + echo -e "${DGN}Enable Root SSH Access: ${BGN}$SSH${CL}" + fi + + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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() { + pve_check + shell_check + root_check + arch_check + ssh_check + + if systemctl is-active -q ping-instances.service; then + systemctl -q stop ping-instances.service + fi + NEXTID=$(pvesh get /cluster/nextid) + timezone=$(cat /etc/timezone) + header_info + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then + clear + echo -e "⚠ User exited script \n" + exit + fi + SPINNER_PID="" + install_script + fi + + if ! command -v pveversion >/dev/null 2>&1; then + if ! (whiptail --backtitle "Proxmox VE Helper Scripts" --title "${APP} LXC UPDATE" --yesno "Support/Update functions for ${APP} LXC. Proceed?" 10 58); then + clear + echo -e "⚠ User exited script \n" + exit + fi + SPINNER_PID="" + update_script + fi +} + +# This function collects user settings and integrates all the collected information. +build_container() { +# if [ "$VERB" == "yes" ]; then set -x; fi + + if [ "$CT_TYPE" == "1" ]; then + FEATURES="keyctl=1,nesting=1" + else + FEATURES="nesting=1" + fi + + + TEMP_DIR=$(mktemp -d) + pushd $TEMP_DIR >/dev/null + if [ "$var_os" == "alpine" ]; then + export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/alpine-install.func)" + else + export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/install.func)" + fi + export CACHER="$APT_CACHER" + export CACHER_IP="$APT_CACHER_IP" + export tz="$timezone" + export DISABLEIPV6="$DISABLEIP6" + export APPLICATION="$APP" + export app="$NSAPP" + export PASSWORD="$PW" + export VERBOSE="$VERB" + export SSH_ROOT="${SSH}" + export CTID="$CT_ID" + export CTTYPE="$CT_TYPE" + export PCT_OSTYPE="$var_os" + export PCT_OSVERSION="$var_version" + export PCT_DISK_SIZE="$DISK_SIZE" + export PCT_OPTIONS=" + -features $FEATURES + -hostname $HN + -tags proxmox-helper-scripts + $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 + " + # This executes create_lxc.sh and creates the container and .conf file + 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 <<EOF >>$LXC_CONFIG +# USB passthrough +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 + + if [ "$CT_TYPE" == "0" ]; then + if [[ "$APP" == "Channels" || "$APP" == "Emby" || "$APP" == "Frigate" || "$APP" == "Jellyfin" || "$APP" == "Plex" || "$APP" == "Scrypted" || "$APP" == "Tdarr" || "$APP" == "Unmanic" ]]; then + cat <<EOF >>$LXC_CONFIG +# VAAPI hardware transcoding +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 + else + if [[ "$APP" == "Channels" || "$APP" == "Emby" || "$APP" == "Frigate" || "$APP" == "Jellyfin" || "$APP" == "Plex" || "$APP" == "Scrypted" || "$APP" == "Tdarr" || "$APP" == "Unmanic" ]]; then + if [[ -e "/dev/dri/renderD128" ]]; then + if [[ -e "/dev/dri/card0" ]]; then + cat <<EOF >>$LXC_CONFIG +# VAAPI hardware transcoding +dev0: /dev/dri/card0,gid=44 +dev1: /dev/dri/renderD128,gid=104 +EOF + else + cat <<EOF >>$LXC_CONFIG +# VAAPI hardware transcoding +dev0: /dev/dri/card1,gid=44 +dev1: /dev/dri/renderD128,gid=104 +EOF + fi + fi + fi + fi + + # This starts the container and executes <app>-install.sh + msg_info "Starting LXC Container" + pct start "$CTID" + msg_ok "Started LXC Container" + if [ "$var_os" == "alpine" ]; then + sleep 3 + pct exec "$CTID" -- /bin/sh -c 'cat <<EOF >/etc/apk/repositories +http://dl-cdn.alpinelinux.org/alpine/latest-stable/main +http://dl-cdn.alpinelinux.org/alpine/latest-stable/community +#http://dl-cdn.alpinelinux.org/alpine/v3.19/main +#http://dl-cdn.alpinelinux.org/alpine/v3.19/community +EOF' + pct exec "$CTID" -- ash -c "apk add bash >/dev/null" + fi + lxc-attach -n "$CTID" -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit + +} + +# This function sets the description of the container. +description() { + IP=$(pct exec "$CTID" ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) + pct set "$CTID" -description "<div align='center'><a href='https://Helper-Scripts.com' target='_blank' rel='noopener noreferrer'><img src='https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/logo-81x112.png'/></a> + + # ${APP} LXC + + <a href='https://ko-fi.com/proxmoxhelperscripts'><img src='https://img.shields.io/badge/☕-Buy me a coffee-blue' /></a> + </div>" + if [[ -f /etc/systemd/system/ping-instances.service ]]; then + systemctl start ping-instances.service + fi +} diff --git a/misc/clean-lxcs.sh b/misc/clean-lxcs.sh new file mode 100644 index 00000000..17f4fe74 --- /dev/null +++ b/misc/clean-lxcs.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info() { + clear + cat <<"EOF" + ________ __ _ ________ + / ____/ /__ ____ _____ / / | |/ / ____/ + / / / / _ \/ __ `/ __ \ / / | / / +/ /___/ / __/ /_/ / / / / / /___/ / /___ +\____/_/\___/\__,_/_/ /_/ /_____/_/|_\____/ + +EOF +} +BL=$(echo "\033[36m") +RD=$(echo "\033[01;31m") +CM='\xE2\x9C\x94\033' +GN=$(echo "\033[1;92m") +CL=$(echo "\033[m") +header_info +echo "Loading..." +whiptail --backtitle "Proxmox VE Helper Scripts" --title "Proxmox VE LXC Updater" --yesno "This Will Clean logs, cache and update apt lists on selected LXC Containers. Proceed?" 10 58 || exit +NODE=$(hostname) +EXCLUDE_MENU=() +MSG_MAX_LENGTH=0 +while read -r TAG ITEM; do + OFFSET=2 + ((${#ITEM} + OFFSET > MSG_MAX_LENGTH)) && MSG_MAX_LENGTH=${#ITEM}+OFFSET + EXCLUDE_MENU+=("$TAG" "$ITEM " "OFF") +done < <(pct list | awk 'NR>1') +excluded_containers=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Containers on $NODE" --checklist "\nSelect containers to skip from cleaning:\n" \ + 16 $((MSG_MAX_LENGTH + 23)) 6 "${EXCLUDE_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"') || exit + +function clean_container() { + container=$1 + header_info + name=$(pct exec "$container" hostname) + echo -e "${BL}[Info]${GN} Cleaning ${name} ${CL} \n" + pct exec $container -- bash -c "apt-get -y --purge autoremove && apt-get -y autoclean && bash <(curl -fsSL https://github.com/tteck/Proxmox/raw/main/misc/clean.sh) && rm -rf /var/lib/apt/lists/* && apt-get update" +} +for container in $(pct list | awk '{if(NR>1) print $1}'); do + if [[ " ${excluded_containers[@]} " =~ " $container " ]]; then + header_info + echo -e "${BL}[Info]${GN} Skipping ${BL}$container${CL}" + sleep 1 + else + os=$(pct config "$container" | awk '/^ostype/ {print $2}') + if [ "$os" != "debian" ] && [ "$os" != "ubuntu" ]; then + header_info + echo -e "${BL}[Info]${GN} Skipping ${name} ${RD}$container is not Debian or Ubuntu ${CL} \n" + sleep 1 + continue + fi + + status=$(pct status $container) + template=$(pct config $container | grep -q "template:" && echo "true" || echo "false") + if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then + echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n" + pct start $container + echo -e "${BL}[Info]${GN} Waiting For${BL} $container${CL}${GN} To Start ${CL} \n" + sleep 5 + clean_container $container + echo -e "${BL}[Info]${GN} Shutting down${BL} $container ${CL} \n" + pct shutdown $container & + elif [ "$status" == "status: running" ]; then + clean_container $container + fi + fi +done + +wait +header_info +echo -e "${GN} Finished, Selected Containers Cleaned. ${CL} \n" diff --git a/misc/clean.sh b/misc/clean.sh new file mode 100644 index 00000000..4f692366 --- /dev/null +++ b/misc/clean.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info() { + clear + cat <<"EOF" + ________ __ _ ________ + / ____/ /__ ____ _____ / / | |/ / ____/ + / / / / _ \/ __ `/ __ \ / / | / / +/ /___/ / __/ /_/ / / / / / /___/ / /___ +\____/_/\___/\__,_/_/ /_/ /_____/_/|_\____/ + +EOF +} +BL=$(echo "\033[36m") +GN=$(echo "\033[1;92m") +CL=$(echo "\033[m") +name=$(hostname) +header_info +echo -e "${BL}[Info]${GN} Cleaning $name${CL} \n" +cache=$(find /var/cache/ -type f) +if [[ -z "$cache" ]]; then + echo -e "It appears there are no cached files on your system. \n" + sleep 2 +else + find /var/cache -type f -delete + echo "Successfully Removed Cache" + sleep 2 +fi +header_info +echo -e "${BL}[Info]${GN} Cleaning $name${CL} \n" +logs=$(find /var/log/ -type f) +if [[ -z "$logs" ]]; then + echo -e "It appears there are no logs on your system. \n" + sleep 2 +else + find /var/log -type f -delete + echo "Successfully Removed Logs" + sleep 2 +fi +header_info +echo -e "${BL}[Info]${GN} Cleaning $name${CL} \n" +echo -e "${GN}Populating apt lists${CL} \n" diff --git a/misc/code-server.sh b/misc/code-server.sh new file mode 100644 index 00000000..0eb46dcf --- /dev/null +++ b/misc/code-server.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + cat <<"EOF" + ______ __ _____ + / ____/___ ____/ /__ / ___/___ ______ _____ _____ + / / / __ \/ __ / _ \ \__ \/ _ \/ ___/ | / / _ \/ ___/ +/ /___/ /_/ / /_/ / __/ ___/ / __/ / | |/ / __/ / +\____/\____/\__,_/\___/ /____/\___/_/ |___/\___/_/ + +EOF +} +IP=$(hostname -I | awk '{print $1}') +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}" +APP="Code Server" +hostname="$(hostname)" +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail +shopt -s expand_aliases +alias die='EXIT=$? LINE=$LINENO error_exit' +trap die ERR + +function error_exit() { + trap - ERR + local reason="Unknown failure occured." + local msg="${1:-$reason}" + local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" + echo -e "$flag $msg" 1>&2 + exit $EXIT +} +clear +header_info +if command -v pveversion >/dev/null 2>&1; then echo -e "⚠️ Can't Install on Proxmox "; exit; fi +if [ -e /etc/alpine-release ]; then echo -e "⚠️ Can't Install on Alpine"; exit; fi +while true; do + read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac +done + +function msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." +} + +function msg_ok() { + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" +} + +msg_info "Installing Dependencies" +apt-get update &>/dev/null +apt-get install -y curl &>/dev/null +apt-get install -y git &>/dev/null +msg_ok "Installed Dependencies" + +VERSION=$(curl -s https://api.github.com/repos/coder/code-server/releases/latest | + grep "tag_name" | + awk '{print substr($2, 3, length($2)-4) }') + +msg_info "Installing Code-Server v${VERSION}" +curl -fOL https://github.com/coder/code-server/releases/download/v$VERSION/code-server_${VERSION}_amd64.deb &>/dev/null +dpkg -i code-server_${VERSION}_amd64.deb &>/dev/null +rm -rf code-server_${VERSION}_amd64.deb +mkdir -p ~/.config/code-server/ +systemctl enable -q --now code-server@$USER +cat <<EOF >~/.config/code-server/config.yaml +bind-addr: 0.0.0.0:8680 +auth: none +password: +cert: false +EOF +systemctl restart code-server@$USER +msg_ok "Installed Code-Server v${VERSION} on $hostname" + +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://$IP:8680${CL} \n" diff --git a/misc/container-restore-from-backup.sh b/misc/container-restore-from-backup.sh new file mode 100644 index 00000000..c491e18a --- /dev/null +++ b/misc/container-restore-from-backup.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +clear +if command -v pveversion >/dev/null 2>&1; then echo -e "⚠️ Can't Run from the Proxmox Shell"; exit; fi +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}" +APP="Home Assistant Container" +while true; do + read -p "This will restore ${APP} from a backup. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac +done +clear +function header_info { + cat <<"EOF" + __ __ ___ _ __ __ + / / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____ / /_ + / /_/ / __ \/ __ `__ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ `/ __ \/ __/ + / __ / /_/ / / / / / / __/ / ___ |(__ |__ ) (__ ) /_/ /_/ / / / / /_ +/_/ /_/\____/_/ /_/ /_/\___/ /_/ |_/____/____/_/____/\__/\__,_/_/ /_/\__/ + RESTORE FROM BACKUP +EOF +} + +header_info + +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}" +} +if [ -z "$(ls -A /var/lib/docker/volumes/hass_config/_data/backups/)" ]; then + msg_error "No backups found! \n" + exit 1 +fi +DIR=/var/lib/docker/volumes/hass_config/_data/restore +if [ -d "$DIR" ]; then + msg_ok "Restore Directory Exists." +else + mkdir -p /var/lib/docker/volumes/hass_config/_data/restore + msg_ok "Created Restore Directory." +fi +cd /var/lib/docker/volumes/hass_config/_data/backups/ +PS3="Please enter your choice: " +files="$(ls -A .)" +select filename in ${files}; do + msg_ok "You selected ${BL}${filename}${CL}" + break +done +msg_info "Stopping Home Assistant" +docker stop homeassistant &>/dev/null +msg_ok "Stopped Home Assistant" +msg_info "Restoring Home Assistant using ${filename}" +tar xvf ${filename} -C /var/lib/docker/volumes/hass_config/_data/restore &>/dev/null +cd /var/lib/docker/volumes/hass_config/_data/restore +tar -xvf homeassistant.tar.gz &>/dev/null +if ! command -v rsync >/dev/null 2>&1; then apt-get install -y rsync &>/dev/null; fi +rsync -a /var/lib/docker/volumes/hass_config/_data/restore/data/ /var/lib/docker/volumes/hass_config/_data +rm -rf /var/lib/docker/volumes/hass_config/_data/restore/* +msg_ok "Restore Complete" +msg_ok "Starting Home Assistant \n" +docker start homeassistant diff --git a/misc/copy-data/README.md b/misc/copy-data/README.md new file mode 100644 index 00000000..e24677c3 --- /dev/null +++ b/misc/copy-data/README.md @@ -0,0 +1,46 @@ +<h2><p align="center">Copy data to another LXC (run in the Proxmox Shell)</p></h2> +<div align="center"> To copy data from Home Assistant Container to Home Assistant Container </div> + +``` +bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/copy-data/home-assistant-container-copy-data-home-assistant-container.sh)" +``` +<div align="center"> To copy data from Home Assistant Container to Home Assistant Core </div> + +``` +bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/copy-data/home-assistant-container-copy-data-home-assistant-core.sh)" +``` +<div align="center"> To copy data from Home Assistant Container to Podman Home Assistant </div> + +``` +bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/copy-data/home-assistant-container-copy-data-podman-home-assistant.sh)" +``` +<div align="center"> To copy data from Podman Home Assistant to Home Assistant Container </div> + +``` +bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/copy-data/podman-home-assistant-copy-data-home-assistant-container.sh)" +``` +<div align="center"> To copy data from Home Assistant Core to Home Assistant Container </div> + +``` +bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/copy-data/home-assistant-core-copy-data-home-assistant-container.sh)" +``` +<div align="center"> To copy data from Home Assistant Core to Home Assistant Core </div> + +``` +bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/copy-data/home-assistant-core-copy-data-home-assistant-core.sh)" +``` +<div align="center"> To copy data from Plex to Plex </div> + +``` +bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/copy-data/plex-copy-data-plex.sh)" +``` +<div align="center"> To copy data from Zigbee2MQTT to Zigbee2MQTT </div> + +``` +bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/copy-data/z2m-copy-data-z2m.sh)" +``` +<div align="center"> To copy data from Zwavejs2MQTT to Zwave JS UI </div> + +``` +bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/copy-data/zwavejs2mqtt-copy-data-zwavejsui.sh)" +``` diff --git a/misc/ha-copy-data.sh b/misc/copy-data/home-assistant-container-copy-data-home-assistant-container.sh similarity index 67% rename from misc/ha-copy-data.sh rename to misc/copy-data/home-assistant-container-copy-data-home-assistant-container.sh index dfc67d12..7b5fe050 100644 --- a/misc/ha-copy-data.sh +++ b/misc/copy-data/home-assistant-container-copy-data-home-assistant-container.sh @@ -1,14 +1,21 @@ #!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + # Use to copy all data from one Home Assistant LXC to another # run from the Proxmox Shell -# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/ha-copy-data.sh)" +clear +if ! command -v pveversion >/dev/null 2>&1; then echo -e "⚠️ Run from the Proxmox Shell"; exit; fi while true; do - read -p "Use to copy all data from one Home Assistant LXC to another. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac + read -p "Use to copy all data from one Home Assistant LXC to another. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac done set -o errexit set -o errtrace @@ -58,28 +65,28 @@ while read -r line; do if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) fi - CTID_MENU+=( "$TAG" "$ITEM " "OFF" ) + CTID_MENU+=("$TAG" "$ITEM " "OFF") done < <(pct list | awk 'NR>1') while [ -z "${CTID_FROM:+x}" ]; do - CTID_FROM=$(whiptail --title "$TITLE" --radiolist \ - "\nWhich HA LXC would you like to copy FROM?\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit + CTID_FROM=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$TITLE" --radiolist \ + "\nWhich HA LXC would you like to copy FROM?\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit done while [ -z "${CTID_TO:+x}" ]; do - CTID_TO=$(whiptail --title "$TITLE" --radiolist \ - "\nWhich HA LXC would you like to copy TO?\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit + CTID_TO=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$TITLE" --radiolist \ + "\nWhich HA LXC would you like to copy TO?\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit done for i in ${!CTID_MENU[@]}; do - [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && \ - CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) - [ "${CTID_MENU[$i]}" == "$CTID_TO" ] && \ - CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) + [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && + CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]}) + [ "${CTID_MENU[$i]}" == "$CTID_TO" ] && + CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]}) done -whiptail --defaultno --title "$TITLE" --yesno \ -"Are you sure you want to copy data between the following LXCs? +whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "$TITLE" --yesno \ + "Are you sure you want to copy data between the following LXCs? $CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME}) Version: 2022.01.23" 13 50 || exit info "Home Assistant Data from '$CTID_FROM' to '$CTID_TO'" @@ -89,13 +96,13 @@ if [ $(pct status $CTID_TO | sed 's/.* //') == 'running' ]; then fi msg "Mounting Container Disks..." DOCKER_PATH=/var/lib/docker/volumes/hass_config/ -CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || \ +CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || die "There was a problem mounting the root disk of LXC '${CTID_FROM}'." -[ -d "${CTID_FROM_PATH}${DOCKER_PATH}" ] || \ +[ -d "${CTID_FROM_PATH}${DOCKER_PATH}" ] || die "Home Assistant directories in '$CTID_FROM' not found." -CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || \ +CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || die "There was a problem mounting the root disk of LXC '${CTID_TO}'." -[ -d "${CTID_TO_PATH}${DOCKER_PATH}" ] || \ +[ -d "${CTID_TO_PATH}${DOCKER_PATH}" ] || die "Home Assistant directories in '$CTID_TO' not found." rm -rf ${CTID_TO_PATH}${DOCKER_PATH} @@ -118,4 +125,4 @@ info "Successfully Transferred Data." # Use to copy all data from one Home Assistant LXC to another # run from the Proxmox Shell -# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/ha-copy-data.sh)" +# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/copy-data/home-assistant-container-copy-data-home-assistant-container.sh)" diff --git a/misc/copy-data/home-assistant-container-copy-data-home-assistant-core.sh b/misc/copy-data/home-assistant-container-copy-data-home-assistant-core.sh new file mode 100644 index 00000000..36af3259 --- /dev/null +++ b/misc/copy-data/home-assistant-container-copy-data-home-assistant-core.sh @@ -0,0 +1,124 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +clear +if ! command -v pveversion >/dev/null 2>&1; then echo -e "⚠️ Run from the Proxmox Shell"; exit; fi +while true; do + read -p "Use to copy all data from a Home Assistant Container LXC to a Home Assistant Core LXC. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac +done +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail +shopt -s expand_aliases +alias die='EXIT=$? LINE=$LINENO error_exit' +trap die ERR +trap cleanup EXIT + +function error_exit() { + trap - ERR + local DEFAULT='Unknown failure occured.' + local REASON="\e[97m${1:-$DEFAULT}\e[39m" + local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" + msg "$FLAG $REASON" + exit $EXIT +} +function warn() { + local REASON="\e[97m$1\e[39m" + local FLAG="\e[93m[WARNING]\e[39m" + msg "$FLAG $REASON" +} +function info() { + local REASON="$1" + local FLAG="\e[36m[INFO]\e[39m" + msg "$FLAG $REASON" +} +function msg() { + local TEXT="$1" + echo -e "$TEXT" +} +function cleanup() { + [ -d "${CTID_FROM_PATH:-}" ] && pct unmount $CTID_FROM + [ -d "${CTID_TO_PATH:-}" ] && pct unmount $CTID_TO + popd >/dev/null + rm -rf $TEMP_DIR +} +TEMP_DIR=$(mktemp -d) +pushd $TEMP_DIR >/dev/null + +TITLE="Home Assistant LXC Data Copy" +while read -r line; do + TAG=$(echo "$line" | awk '{print $1}') + ITEM=$(echo "$line" | awk '{print substr($0,36)}') + OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + CTID_MENU+=("$TAG" "$ITEM " "OFF") +done < <(pct list | awk 'NR>1') +while [ -z "${CTID_FROM:+x}" ]; do + CTID_FROM=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$TITLE" --radiolist \ + "\nWhich HA Container LXC would you like to copy FROM?\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit +done +while [ -z "${CTID_TO:+x}" ]; do + CTID_TO=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$TITLE" --radiolist \ + "\nWhich HA Core LXC would you like to copy TO?\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit +done +for i in ${!CTID_MENU[@]}; do + [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && + CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]}) + [ "${CTID_MENU[$i]}" == "$CTID_TO" ] && + CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]}) +done +whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "$TITLE" --yesno \ + "Are you sure you want to copy data between the following LXCs? +$CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME}) +Version: 2022.10.02" 13 50 || exit +info "Home Assistant Data from '$CTID_FROM' to '$CTID_TO'" +if [ $(pct status $CTID_TO | sed 's/.* //') == 'running' ]; then + msg "Stopping '$CTID_TO'..." + pct stop $CTID_TO +fi +msg "Mounting Container Disks..." +DOCKER_PATH=/var/lib/docker/volumes/hass_config/_data +CORE_PATH=/root/.homeassistant +CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || + die "There was a problem mounting the root disk of LXC '${CTID_FROM}'." +[ -d "${CTID_FROM_PATH}${DOCKER_PATH}" ] || + die "Home Assistant directories in '$CTID_FROM' not found." +CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || + die "There was a problem mounting the root disk of LXC '${CTID_TO}'." +[ -d "${CTID_TO_PATH}${CORE_PATH}" ] || + die "Home Assistant directories in '$CTID_TO' not found." + +msg "Copying Data..." +RSYNC_OPTIONS=( + --archive + --hard-links + --sparse + --xattrs + --no-inc-recursive + --info=progress2 +) +msg "<======== Docker Data ========>" +rsync ${RSYNC_OPTIONS[*]} ${CTID_FROM_PATH}${DOCKER_PATH} ${CTID_TO_PATH}${CORE_PATH} +echo -en "\e[1A\e[0K\e[1A\e[0K" + +info "Successfully Transferred Data." + +# Use to copy all data from a Home Assistant Container LXC to a Home Assistant Core LXC +# run from the Proxmox Shell +# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/copy-data/home-assistant-container-copy-data-home-assistant-core.sh)" diff --git a/misc/ha-copy-data-podman.sh b/misc/copy-data/home-assistant-container-copy-data-podman-home-assistant.sh similarity index 68% rename from misc/ha-copy-data-podman.sh rename to misc/copy-data/home-assistant-container-copy-data-podman-home-assistant.sh index a37c9779..2423f896 100644 --- a/misc/ha-copy-data-podman.sh +++ b/misc/copy-data/home-assistant-container-copy-data-podman-home-assistant.sh @@ -1,14 +1,21 @@ #!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + # Use to copy all data from a Home Assistant LXC to a Podman Home Assistant LXC. # run from the Proxmox Shell -# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/ha-copy-data-podman.sh)" +clear +if ! command -v pveversion >/dev/null 2>&1; then echo -e "⚠️ Run from the Proxmox Shell"; exit; fi while true; do - read -p "Use to copy all data from a Home Assistant LXC to a Podman Home Assistant LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac + read -p "Use to copy all data from a Home Assistant LXC to a Podman Home Assistant LXC. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac done set -o errexit set -o errtrace @@ -58,28 +65,28 @@ while read -r line; do if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) fi - CTID_MENU+=( "$TAG" "$ITEM " "OFF" ) + CTID_MENU+=("$TAG" "$ITEM " "OFF") done < <(pct list | awk 'NR>1') while [ -z "${CTID_FROM:+x}" ]; do - CTID_FROM=$(whiptail --title "$TITLE" --radiolist \ - "\nWhich HA LXC would you like to copy FROM?\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit + CTID_FROM=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$TITLE" --radiolist \ + "\nWhich HA LXC would you like to copy FROM?\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit done while [ -z "${CTID_TO:+x}" ]; do - CTID_TO=$(whiptail --title "$TITLE" --radiolist \ - "\nWhich HA Podman LXC would you like to copy TO?\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit + CTID_TO=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$TITLE" --radiolist \ + "\nWhich HA Podman LXC would you like to copy TO?\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit done for i in ${!CTID_MENU[@]}; do - [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && \ - CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) - [ "${CTID_MENU[$i]}" == "$CTID_TO" ] && \ - CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) + [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && + CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]}) + [ "${CTID_MENU[$i]}" == "$CTID_TO" ] && + CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]}) done -whiptail --defaultno --title "$TITLE" --yesno \ -"Are you sure you want to copy data between the following LXCs? +whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "$TITLE" --yesno \ + "Are you sure you want to copy data between the following LXCs? $CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME}) Version: 2022.02.12" 13 50 || exit info "Home Assistant Data from '$CTID_FROM' to '$CTID_TO'" @@ -90,13 +97,13 @@ fi msg "Mounting Container Disks..." DOCKER_PATH=/var/lib/docker/volumes/hass_config/ PODMAN_PATH=/var/lib/containers/storage/volumes/hass_config/ -CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || \ +CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || die "There was a problem mounting the root disk of LXC '${CTID_FROM}'." -[ -d "${CTID_FROM_PATH}${DOCKER_PATH}" ] || \ +[ -d "${CTID_FROM_PATH}${DOCKER_PATH}" ] || die "Home Assistant directories in '$CTID_FROM' not found." -CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || \ +CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || die "There was a problem mounting the root disk of LXC '${CTID_TO}'." -[ -d "${CTID_TO_PATH}${PODMAN_PATH}" ] || \ +[ -d "${CTID_TO_PATH}${PODMAN_PATH}" ] || die "Home Assistant directories in '$CTID_TO' not found." rm -rf ${CTID_TO_PATH}${PODMAN_PATH} @@ -119,4 +126,4 @@ info "Successfully Transferred Data." # Use to copy all data from a Home Assistant LXC to a Podman Home Assistant LXC # run from the Proxmox Shell -# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/ha-copy-data-podman.sh)" +# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/copy-data/home-assistant-container-copy-data-podman-home-assistant.sh)" diff --git a/misc/copy-data/home-assistant-core-copy-data-home-assistant-container.sh b/misc/copy-data/home-assistant-core-copy-data-home-assistant-container.sh new file mode 100644 index 00000000..387450fc --- /dev/null +++ b/misc/copy-data/home-assistant-core-copy-data-home-assistant-container.sh @@ -0,0 +1,124 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +clear +if ! command -v pveversion >/dev/null 2>&1; then echo -e "⚠️ Run from the Proxmox Shell"; exit; fi +while true; do + read -p "Use to copy all data from a Home Assistant Core LXC to a Home Assistant Container LXC. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac +done +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail +shopt -s expand_aliases +alias die='EXIT=$? LINE=$LINENO error_exit' +trap die ERR +trap cleanup EXIT + +function error_exit() { + trap - ERR + local DEFAULT='Unknown failure occured.' + local REASON="\e[97m${1:-$DEFAULT}\e[39m" + local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" + msg "$FLAG $REASON" + exit $EXIT +} +function warn() { + local REASON="\e[97m$1\e[39m" + local FLAG="\e[93m[WARNING]\e[39m" + msg "$FLAG $REASON" +} +function info() { + local REASON="$1" + local FLAG="\e[36m[INFO]\e[39m" + msg "$FLAG $REASON" +} +function msg() { + local TEXT="$1" + echo -e "$TEXT" +} +function cleanup() { + [ -d "${CTID_FROM_PATH:-}" ] && pct unmount $CTID_FROM + [ -d "${CTID_TO_PATH:-}" ] && pct unmount $CTID_TO + popd >/dev/null + rm -rf $TEMP_DIR +} +TEMP_DIR=$(mktemp -d) +pushd $TEMP_DIR >/dev/null + +TITLE="Home Assistant LXC Data Copy" +while read -r line; do + TAG=$(echo "$line" | awk '{print $1}') + ITEM=$(echo "$line" | awk '{print substr($0,36)}') + OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + CTID_MENU+=("$TAG" "$ITEM " "OFF") +done < <(pct list | awk 'NR>1') +while [ -z "${CTID_FROM:+x}" ]; do + CTID_FROM=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$TITLE" --radiolist \ + "\nWhich HA Core LXC would you like to copy FROM?\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit +done +while [ -z "${CTID_TO:+x}" ]; do + CTID_TO=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$TITLE" --radiolist \ + "\nWhich HA Container LXC would you like to copy TO?\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit +done +for i in ${!CTID_MENU[@]}; do + [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && + CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]}) + [ "${CTID_MENU[$i]}" == "$CTID_TO" ] && + CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]}) +done +whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "$TITLE" --yesno \ + "Are you sure you want to copy data between the following LXCs? +$CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME}) +Version: 2022.10.02" 13 50 || exit +info "Home Assistant Data from '$CTID_FROM' to '$CTID_TO'" +if [ $(pct status $CTID_TO | sed 's/.* //') == 'running' ]; then + msg "Stopping '$CTID_TO'..." + pct stop $CTID_TO +fi +msg "Mounting Container Disks..." +DOCKER_PATH=/var/lib/docker/volumes/hass_config/_data +CORE_PATH=/root/.homeassistant +CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || + die "There was a problem mounting the root disk of LXC '${CTID_FROM}'." +[ -d "${CTID_FROM_PATH}${CORE_PATH}" ] || + die "Home Assistant directories in '$CTID_FROM' not found." +CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || + die "There was a problem mounting the root disk of LXC '${CTID_TO}'." +[ -d "${CTID_TO_PATH}${DOCKER_PATH}" ] || + die "Home Assistant directories in '$CTID_TO' not found." + +msg "Copying Data..." +RSYNC_OPTIONS=( + --archive + --hard-links + --sparse + --xattrs + --no-inc-recursive + --info=progress2 +) +msg "<======== Docker Data ========>" +rsync ${RSYNC_OPTIONS[*]} ${CTID_FROM_PATH}${CORE_PATH} ${CTID_TO_PATH}${DOCKER_PATH} +echo -en "\e[1A\e[0K\e[1A\e[0K" + +info "Successfully Transferred Data." + +# Use to copy all data from a Home Assistant Core LXC to a Home Assistant Container LXC +# run from the Proxmox Shell +# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/copy-data/home-assistant-core-copy-data-home-assistant-container.sh)" diff --git a/misc/copy-data/home-assistant-core-copy-data-home-assistant-core.sh b/misc/copy-data/home-assistant-core-copy-data-home-assistant-core.sh new file mode 100644 index 00000000..68c388ed --- /dev/null +++ b/misc/copy-data/home-assistant-core-copy-data-home-assistant-core.sh @@ -0,0 +1,123 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +clear +if ! command -v pveversion >/dev/null 2>&1; then echo -e "⚠️ Run from the Proxmox Shell"; exit; fi +while true; do + read -p "Use to copy all data from a Home Assistant Core LXC to a Home Assistant Core LXC. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac +done +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail +shopt -s expand_aliases +alias die='EXIT=$? LINE=$LINENO error_exit' +trap die ERR +trap cleanup EXIT + +function error_exit() { + trap - ERR + local DEFAULT='Unknown failure occured.' + local REASON="\e[97m${1:-$DEFAULT}\e[39m" + local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" + msg "$FLAG $REASON" + exit $EXIT +} +function info() { + local REASON="$1" + local FLAG="\e[36m[INFO]\e[39m" + msg "$FLAG $REASON" +} +function msg() { + local TEXT="$1" + echo -e "$TEXT" +} +function cleanup() { + [ -d "${CTID_FROM_PATH:-}" ] && pct unmount $CTID_FROM + [ -d "${CTID_TO_PATH:-}" ] && pct unmount $CTID_TO + popd >/dev/null + rm -rf $TEMP_DIR +} +TEMP_DIR=$(mktemp -d) +pushd $TEMP_DIR >/dev/null + +TITLE="Home Assistant LXC Data Copy" +while read -r line; do + TAG=$(echo "$line" | awk '{print $1}') + ITEM=$(echo "$line" | awk '{print substr($0,36)}') + OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + CTID_MENU+=("$TAG" "$ITEM " "OFF") +done < <(pct list | awk 'NR>1') +while [ -z "${CTID_FROM:+x}" ]; do + CTID_FROM=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$TITLE" --radiolist \ + "\nWhich HA Core LXC would you like to copy FROM?\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit +done +while [ -z "${CTID_TO:+x}" ]; do + CTID_TO=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$TITLE" --radiolist \ + "\nWhich HA Core LXC would you like to copy TO?\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit +done +for i in ${!CTID_MENU[@]}; do + [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && + CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]}) + [ "${CTID_MENU[$i]}" == "$CTID_TO" ] && + CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]}) +done +whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "$TITLE" --yesno \ + "Are you sure you want to copy data between the following LXCs? +$CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME}) +Version: 2022.10.03" 13 50 || exit +info "Home Assistant Data from '$CTID_FROM' to '$CTID_TO'" +if [ $(pct status $CTID_FROM | sed 's/.* //') == 'running' ]; then + msg "Stopping '$CTID_FROM'..." + pct stop $CTID_FROM +fi +if [ $(pct status $CTID_TO | sed 's/.* //') == 'running' ]; then + msg "Stopping '$CTID_TO'..." + pct stop $CTID_TO +fi +msg "Mounting Container Disks..." +CORE_PATH=/root/.homeassistant +CORE_PATH2=/root/ +CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || + die "There was a problem mounting the root disk of LXC '${CTID_FROM}'." +[ -d "${CTID_FROM_PATH}${CORE_PATH}" ] || + die "Home Assistant directories in '$CTID_FROM' not found." +CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || + die "There was a problem mounting the root disk of LXC '${CTID_TO}'." +[ -d "${CTID_TO_PATH}${CORE_PATH2}" ] || + die "Home Assistant directories in '$CTID_TO' not found." + +msg "Copying Data..." +RSYNC_OPTIONS=( + --archive + --hard-links + --sparse + --xattrs + --no-inc-recursive + --info=progress2 +) +msg "<======== Docker Data ========>" +rsync ${RSYNC_OPTIONS[*]} ${CTID_FROM_PATH}${CORE_PATH} ${CTID_TO_PATH}${CORE_PATH2} +echo -en "\e[1A\e[0K\e[1A\e[0K" + +info "Successfully Transferred Data." + +# Use to copy all data from a Home Assistant Core LXC to a Home Assistant Container LXC +# run from the Proxmox Shell +# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/copy-data/home-assistant-core-copy-data-home-assistant-core.sh)" diff --git a/misc/pms-copy-data.sh b/misc/copy-data/plex-copy-data-plex.sh similarity index 68% rename from misc/pms-copy-data.sh rename to misc/copy-data/plex-copy-data-plex.sh index ffa2340f..dbf80f18 100644 --- a/misc/pms-copy-data.sh +++ b/misc/copy-data/plex-copy-data-plex.sh @@ -1,14 +1,21 @@ #!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + # Use to copy all data from one Plex Media Server LXC to another # run from the Proxmox Shell -# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/pms-copy-data.sh)" +clear +if ! command -v pveversion >/dev/null 2>&1; then echo -e "⚠️ Run from the Proxmox Shell"; exit; fi while true; do - read -p "Use to copy all data from one Plex Media Server LXC to another. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac + read -p "Use to copy all data from one Plex Media Server LXC to another. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac done set -o errexit set -o errtrace @@ -58,28 +65,28 @@ while read -r line; do if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) fi - CTID_MENU+=( "$TAG" "$ITEM " "OFF" ) + CTID_MENU+=("$TAG" "$ITEM " "OFF") done < <(pct list | awk 'NR>1') while [ -z "${CTID_FROM:+x}" ]; do - CTID_FROM=$(whiptail --title "$TITLE" --radiolist \ - "\nWhich Plex Media Server LXC would you like to copy FROM?\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit + CTID_FROM=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$TITLE" --radiolist \ + "\nWhich Plex Media Server LXC would you like to copy FROM?\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit done while [ -z "${CTID_TO:+x}" ]; do - CTID_TO=$(whiptail --title "$TITLE" --radiolist \ - "\nWhich Plex Media Server LXC would you like to copy TO?\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit + CTID_TO=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$TITLE" --radiolist \ + "\nWhich Plex Media Server LXC would you like to copy TO?\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit done for i in ${!CTID_MENU[@]}; do - [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && \ - CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) - [ "${CTID_MENU[$i]}" == "$CTID_TO" ] && \ - CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) + [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && + CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]}) + [ "${CTID_MENU[$i]}" == "$CTID_TO" ] && + CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]}) done -whiptail --defaultno --title "$TITLE" --yesno \ -"Are you sure you want to copy data between the following LXCs? +whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "$TITLE" --yesno \ + "Are you sure you want to copy data between the following LXCs? $CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME}) Version: 2022.01.24" 13 50 || exit info "Plex Media Server Data from '$CTID_FROM' to '$CTID_TO'" @@ -89,13 +96,13 @@ if [ $(pct status $CTID_TO | sed 's/.* //') == 'running' ]; then fi msg "Mounting Container Disks..." DATA_PATH=/var/lib/plexmediaserver/Library/ -CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || \ +CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || die "There was a problem mounting the root disk of LXC '${CTID_FROM}'." -[ -d "${CTID_FROM_PATH}${DATA_PATH}" ] || \ +[ -d "${CTID_FROM_PATH}${DATA_PATH}" ] || die "Plex Media Server directories in '$CTID_FROM' not found." -CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || \ +CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || die "There was a problem mounting the root disk of LXC '${CTID_TO}'." -[ -d "${CTID_TO_PATH}${DATA_PATH}" ] || \ +[ -d "${CTID_TO_PATH}${DATA_PATH}" ] || die "Plex Media Server directories in '$CTID_TO' not found." #rm -rf ${CTID_TO_PATH}${DATA_PATH} @@ -118,4 +125,4 @@ info "Successfully Transferred Data." # Use to copy all data from one Plex Media Server LXC to another # run from the Proxmox Shell -# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/pms-copy-data.sh)" +# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/copy-data/plex-copy-data-plex.sh)" diff --git a/misc/podman-copy-data-docker.sh b/misc/copy-data/podman-home-assistant-copy-data-home-assistant-container.sh similarity index 68% rename from misc/podman-copy-data-docker.sh rename to misc/copy-data/podman-home-assistant-copy-data-home-assistant-container.sh index de5e0b1a..ef65e9e6 100644 --- a/misc/podman-copy-data-docker.sh +++ b/misc/copy-data/podman-home-assistant-copy-data-home-assistant-container.sh @@ -1,14 +1,21 @@ #!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + # Use to copy all data from a Podman Home Assistant LXC to a Docker Home Assistant LXC. # run from the Proxmox Shell -# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/podman-copy-data-docker.sh)" +clear +if ! command -v pveversion >/dev/null 2>&1; then echo -e "⚠️ Run from the Proxmox Shell"; exit; fi while true; do - read -p "Use to copy all data from a Podman Home Assistant LXC to a Docker Home Assistant LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac + read -p "Use to copy all data from a Podman Home Assistant LXC to a Docker Home Assistant LXC. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac done set -o errexit set -o errtrace @@ -58,28 +65,28 @@ while read -r line; do if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) fi - CTID_MENU+=( "$TAG" "$ITEM " "OFF" ) + CTID_MENU+=("$TAG" "$ITEM " "OFF") done < <(pct list | awk 'NR>1') while [ -z "${CTID_FROM:+x}" ]; do - CTID_FROM=$(whiptail --title "$TITLE" --radiolist \ - "\nWhich HA Podman LXC would you like to copy FROM?\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit + CTID_FROM=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$TITLE" --radiolist \ + "\nWhich HA Podman LXC would you like to copy FROM?\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit done while [ -z "${CTID_TO:+x}" ]; do - CTID_TO=$(whiptail --title "$TITLE" --radiolist \ - "\nWhich HA LXC would you like to copy TO?\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit + CTID_TO=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$TITLE" --radiolist \ + "\nWhich HA LXC would you like to copy TO?\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit done for i in ${!CTID_MENU[@]}; do - [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && \ - CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) - [ "${CTID_MENU[$i]}" == "$CTID_TO" ] && \ - CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) + [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && + CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]}) + [ "${CTID_MENU[$i]}" == "$CTID_TO" ] && + CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]}) done -whiptail --defaultno --title "$TITLE" --yesno \ -"Are you sure you want to copy data between the following LXCs? +whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "$TITLE" --yesno \ + "Are you sure you want to copy data between the following LXCs? $CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME}) Version: 2022.03.31" 13 50 || exit info "Home Assistant Data from '$CTID_FROM' to '$CTID_TO'" @@ -90,13 +97,13 @@ fi msg "Mounting Container Disks..." DOCKER_PATH=/var/lib/docker/volumes/hass_config/ PODMAN_PATH=/var/lib/containers/storage/volumes/hass_config/ -CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || \ +CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || die "There was a problem mounting the root disk of LXC '${CTID_FROM}'." -[ -d "${CTID_FROM_PATH}${PODMAN_PATH}" ] || \ +[ -d "${CTID_FROM_PATH}${PODMAN_PATH}" ] || die "Home Assistant directories in '$CTID_FROM' not found." -CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || \ +CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || die "There was a problem mounting the root disk of LXC '${CTID_TO}'." -[ -d "${CTID_TO_PATH}${DOCKER_PATH}" ] || \ +[ -d "${CTID_TO_PATH}${DOCKER_PATH}" ] || die "Home Assistant directories in '$CTID_TO' not found." rm -rf ${CTID_TO_PATH}${DOCKER_PATH} @@ -119,4 +126,4 @@ info "Successfully Transferred Data." # Use to copy all data from a Podman Home Assistant LXC to a Docker Home Assistant LXC. # run from the Proxmox Shell -# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/podman-copy-data-docker.sh)" +# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/copy-data/podman-home-assistant-copy-data-home-assistant-container.sh)" diff --git a/misc/z2m-copy-data.sh b/misc/copy-data/z2m-copy-data-z2m.sh similarity index 68% rename from misc/z2m-copy-data.sh rename to misc/copy-data/z2m-copy-data-z2m.sh index a698ef35..6e804de5 100644 --- a/misc/z2m-copy-data.sh +++ b/misc/copy-data/z2m-copy-data-z2m.sh @@ -1,14 +1,21 @@ #!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + # Use to copy all data from one Zigbee2MQTT LXC to another # run from the Proxmox Shell -# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/z2m-copy-data.sh)" +clear +if ! command -v pveversion >/dev/null 2>&1; then echo -e "⚠️ Run from the Proxmox Shell"; exit; fi while true; do - read -p "Use to copy all data from one Zigbee2MQTT LXC to another. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac + read -p "Use to copy all data from one Zigbee2MQTT LXC to another. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac done set -o errexit set -o errtrace @@ -58,28 +65,28 @@ while read -r line; do if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) fi - CTID_MENU+=( "$TAG" "$ITEM " "OFF" ) + CTID_MENU+=("$TAG" "$ITEM " "OFF") done < <(pct list | awk 'NR>1') while [ -z "${CTID_FROM:+x}" ]; do - CTID_FROM=$(whiptail --title "$TITLE" --radiolist \ - "\nWhich Zigbee2MQTT LXC would you like to copy FROM?\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit + CTID_FROM=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$TITLE" --radiolist \ + "\nWhich Zigbee2MQTT LXC would you like to copy FROM?\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit done while [ -z "${CTID_TO:+x}" ]; do - CTID_TO=$(whiptail --title "$TITLE" --radiolist \ - "\nWhich Zigbee2MQTT LXC would you like to copy TO?\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit + CTID_TO=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$TITLE" --radiolist \ + "\nWhich Zigbee2MQTT LXC would you like to copy TO?\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit done for i in ${!CTID_MENU[@]}; do - [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && \ - CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) - [ "${CTID_MENU[$i]}" == "$CTID_TO" ] && \ - CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) + [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && + CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]}) + [ "${CTID_MENU[$i]}" == "$CTID_TO" ] && + CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]}) done -whiptail --defaultno --title "$TITLE" --yesno \ -"Are you sure you want to copy data between the following LXCs? +whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "$TITLE" --yesno \ + "Are you sure you want to copy data between the following LXCs? $CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME}) Version: 2022.01.23" 13 50 || exit info "Zigbee2MQTT Data from '$CTID_FROM' to '$CTID_TO'" @@ -89,13 +96,13 @@ if [ $(pct status $CTID_TO | sed 's/.* //') == 'running' ]; then fi msg "Mounting Container Disks..." DATA_PATH=/opt/zigbee2mqtt/data/ -CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || \ +CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || die "There was a problem mounting the root disk of LXC '${CTID_FROM}'." -[ -d "${CTID_FROM_PATH}${DATA_PATH}" ] || \ +[ -d "${CTID_FROM_PATH}${DATA_PATH}" ] || die "Zigbee2igbee2MQTT directories in '$CTID_FROM' not found." -CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || \ +CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || die "There was a problem mounting the root disk of LXC '${CTID_TO}'." -[ -d "${CTID_TO_PATH}${DATA_PATH}" ] || \ +[ -d "${CTID_TO_PATH}${DATA_PATH}" ] || die "Zigbee2MQTT directories in '$CTID_TO' not found." #rm -rf ${CTID_TO_PATH}${DATA_PATH} @@ -118,4 +125,4 @@ info "Successfully Transferred Data." # Use to copy all data from one Zigbee2MQTT LXC to another # run from the Proxmox Shell -# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/z2m-copy-data.sh)" +# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/copy-data/z2m-copy-data-z2m.sh)" diff --git a/misc/zwave-copy-data.sh b/misc/copy-data/zwavejs2mqtt-copy-data-zwavejsui.sh similarity index 59% rename from misc/zwave-copy-data.sh rename to misc/copy-data/zwavejs2mqtt-copy-data-zwavejsui.sh index 728fbaf7..8d552982 100644 --- a/misc/zwave-copy-data.sh +++ b/misc/copy-data/zwavejs2mqtt-copy-data-zwavejsui.sh @@ -1,14 +1,21 @@ #!/usr/bin/env bash -# Use to copy all data from one Zwavejs2MQTT LXC to another + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +# Use to copy all data from a Zwavejs2MQTT LXC to a Z-wave JS UI LXC # run from the Proxmox Shell -# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/zwave-copy-data.sh)" +clear +if ! command -v pveversion >/dev/null 2>&1; then echo -e "⚠️ Run from the Proxmox Shell"; exit; fi while true; do - read -p "Use to copy all data from one Zwavejs2MQTT LXC to another. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac + read -p "Use to copy all data from a Zwavejs2MQTT LXC to a Z-wave JS UI LXC. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac done clear set -o errexit @@ -51,7 +58,7 @@ function cleanup() { TEMP_DIR=$(mktemp -d) pushd $TEMP_DIR >/dev/null -TITLE="Zigbee2MQTT LXC Data Copy" +TITLE="Zigbee2MQTT to Z-wave JS UI Data Copy" while read -r line; do TAG=$(echo "$line" | awk '{print $1}') ITEM=$(echo "$line" | awk '{print substr($0,36)}') @@ -59,30 +66,30 @@ while read -r line; do if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) fi - CTID_MENU+=( "$TAG" "$ITEM " "OFF" ) + CTID_MENU+=("$TAG" "$ITEM " "OFF") done < <(pct list | awk 'NR>1') while [ -z "${CTID_FROM:+x}" ]; do - CTID_FROM=$(whiptail --title "$TITLE" --radiolist \ - "\nWhich Zwavejs2MQTT LXC would you like to copy FROM?\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit + CTID_FROM=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$TITLE" --radiolist \ + "\nWhich Zwavejs2MQTT LXC would you like to copy FROM?\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit done while [ -z "${CTID_TO:+x}" ]; do - CTID_TO=$(whiptail --title "$TITLE" --radiolist \ - "\nWhich Zwavejs2MQTT LXC would you like to copy TO?\n" \ - 16 $(($MSG_MAX_LENGTH + 23)) 6 \ - "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit + CTID_TO=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$TITLE" --radiolist \ + "\nWhich Z-wave JS UI LXC would you like to copy TO?\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit done for i in ${!CTID_MENU[@]}; do - [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && \ - CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) - [ "${CTID_MENU[$i]}" == "$CTID_TO" ] && \ - CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i+1]}) + [ "${CTID_MENU[$i]}" == "$CTID_FROM" ] && + CTID_FROM_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]}) + [ "${CTID_MENU[$i]}" == "$CTID_TO" ] && + CTID_TO_HOSTNAME=$(sed 's/[[:space:]]*$//' <<<${CTID_MENU[$i + 1]}) done -whiptail --defaultno --title "$TITLE" --yesno \ -"Are you sure you want to copy data between the following LXCs? +whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "$TITLE" --yesno \ + "Are you sure you want to copy data between the following LXCs? $CTID_FROM (${CTID_FROM_HOSTNAME}) -> $CTID_TO (${CTID_TO_HOSTNAME}) -Version: 2022.03.06" 13 50 || exit +Version: 2022.09.21" 13 50 || exit info "Zwavejs2MQTT Data from '$CTID_FROM' to '$CTID_TO'" if [ $(pct status $CTID_TO | sed 's/.* //') == 'running' ]; then msg "Stopping '$CTID_TO'..." @@ -90,13 +97,14 @@ if [ $(pct status $CTID_TO | sed 's/.* //') == 'running' ]; then fi msg "Mounting Container Disks..." DATA_PATH=/opt/zwavejs2mqtt/store/ -CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || \ +DATA_PATH_NEW=/opt/zwave-js-ui/store/ +CTID_FROM_PATH=$(pct mount $CTID_FROM | sed -n "s/.*'\(.*\)'/\1/p") || die "There was a problem mounting the root disk of LXC '${CTID_FROM}'." -[ -d "${CTID_FROM_PATH}${DATA_PATH}" ] || \ +[ -d "${CTID_FROM_PATH}${DATA_PATH}" ] || die "Zwavejs2MQTT directories in '$CTID_FROM' not found." -CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || \ +CTID_TO_PATH=$(pct mount $CTID_TO | sed -n "s/.*'\(.*\)'/\1/p") || die "There was a problem mounting the root disk of LXC '${CTID_TO}'." -[ -d "${CTID_TO_PATH}${DATA_PATH}" ] || \ +[ -d "${CTID_TO_PATH}${DATA_PATH_NEW}" ] || die "Zwavejs2MQTT directories in '$CTID_TO' not found." #rm -rf ${CTID_TO_PATH}${DATA_PATH} @@ -111,9 +119,12 @@ RSYNC_OPTIONS=( --no-inc-recursive --info=progress2 ) -msg "<======== Zwavejs2MQTT Data ========>" -rsync ${RSYNC_OPTIONS[*]} ${CTID_FROM_PATH}${DATA_PATH} ${CTID_TO_PATH}${DATA_PATH} +msg "<======== Zwavejs Data ========>" +rsync ${RSYNC_OPTIONS[*]} ${CTID_FROM_PATH}${DATA_PATH} ${CTID_TO_PATH}${DATA_PATH_NEW} echo -en "\e[1A\e[0K\e[1A\e[0K" info "Successfully Transferred Data." +# Use to copy all data from a Zwavejs2MQTT LXC to a Z-wave JS UI LXC +# run from the Proxmox Shell +# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/copy-data/zwavejs2mqtt-copy-data-zwavejsui.sh)" diff --git a/misc/core-restore-from-backup.sh b/misc/core-restore-from-backup.sh new file mode 100644 index 00000000..885eda9c --- /dev/null +++ b/misc/core-restore-from-backup.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +clear +if command -v pveversion >/dev/null 2>&1; then echo -e "⚠️ Can't Run from the Proxmox Shell"; exit; fi +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}" +APP="Home Assistant Core" +while true; do + read -p "This will restore ${APP} from a backup. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac +done +clear +function header_info { + cat <<"EOF" + __ __ ___ _ __ __ ______ + / / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____ / /_ / ____/___ ________ + / /_/ / __ \/ __ `__ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ `/ __ \/ __/ / / / __ \/ ___/ _ \ + / __ / /_/ / / / / / / __/ / ___ |(__ |__ ) (__ ) /_/ /_/ / / / / /_ / /___/ /_/ / / / __/ +/_/ /_/\____/_/ /_/ /_/\___/ /_/ |_/____/____/_/____/\__/\__,_/_/ /_/\__/ \____/\____/_/ \___/ + RESTORE FROM BACKUP +EOF +} + +header_info + +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}" +} +if [ -z "$(ls -A /root/.homeassistant/backups/)" ]; then + msg_error "No backups found! \n" + exit 1 +fi +DIR=/root/.homeassistant/restore +if [ -d "$DIR" ]; then + msg_ok "Restore Directory Exists." +else + mkdir -p /root/.homeassistant/restore + msg_ok "Created Restore Directory." +fi +cd /root/.homeassistant/backups/ +PS3="Please enter your choice: " +files="$(ls -A .)" +select filename in ${files}; do + msg_ok "You selected ${BL}${filename}${CL}" + break +done +msg_info "Stopping Home Assistant" +sudo service homeassistant stop +msg_ok "Stopped Home Assistant" +msg_info "Restoring Home Assistant using ${filename}" +tar xvf ${filename} -C /root/.homeassistant/restore &>/dev/null +cd /root/.homeassistant/restore +tar -xvf homeassistant.tar.gz &>/dev/null +if ! command -v rsync >/dev/null 2>&1; then apt-get install -y rsync &>/dev/null; fi +rsync -a /root/.homeassistant/restore/data/ /root/.homeassistant +rm -rf /root/.homeassistant/restore/* +msg_ok "Restore Complete" +msg_ok "Starting Home Assistant \n" +sudo service homeassistant start diff --git a/misc/cron-update-lxcs.sh b/misc/cron-update-lxcs.sh new file mode 100644 index 00000000..97fb4e6c --- /dev/null +++ b/misc/cron-update-lxcs.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/cron-update-lxcs.sh)" + +clear +cat <<"EOF" + ______ __ __ __ __ __ _ ________ + / ____/________ ____ / / / /___ ____/ /___ _/ /____ / / | |/ / ____/____ + / / / ___/ __ \/ __ \ / / / / __ \/ __ / __ `/ __/ _ \ / / | / / / ___/ +/ /___/ / / /_/ / / / / / /_/ / /_/ / /_/ / /_/ / /_/ __/ / /___/ / /___(__ ) +\____/_/ \____/_/ /_/ \____/ .___/\__,_/\__,_/\__/\___/ /_____/_/|_\____/____/ + /_/ +EOF + +add() { + while true; do + read -p "This script will add a crontab schedule that updates all LXCs every Sunday at midnight. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac + done + sh -c '(crontab -l -u root 2>/dev/null; echo "0 0 * * 0 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin /bin/bash -c \"\$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/update-lxcs-cron.sh)\" >>/var/log/update-lxcs-cron.log 2>/dev/null") | crontab -u root -' + clear + echo -e "\n To view Cron Update LXCs logs: cat /var/log/update-lxcs-cron.log" +} + +remove() { + (crontab -l | grep -v "github.com/tteck/Proxmox/raw/main/misc/update-lxcs-cron.sh") | crontab - + rm -rf /var/log/update-lxcs-cron.log + echo "Removed Crontab Schedule from Proxmox VE" +} + +OPTIONS=(Add "Add Crontab Schedule" + Remove "Remove Crontab Schedule") + +CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Cron Update LXCs" --menu "Select an option:" 10 58 2 \ + "${OPTIONS[@]}" 3>&1 1>&2 2>&3) + +case $CHOICE in +"Add") + add + ;; +"Remove") + remove + ;; +*) + echo "Exiting..." + exit 0 + ;; +esac diff --git a/misc/crowdsec-v3.sh b/misc/crowdsec.sh similarity index 57% rename from misc/crowdsec-v3.sh rename to misc/crowdsec.sh index 0ab6d5c3..12a20f04 100644 --- a/misc/crowdsec-v3.sh +++ b/misc/crowdsec.sh @@ -1,15 +1,22 @@ #!/usr/bin/env bash -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"` + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +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}" APP="CrowdSec" +hostname="$(hostname)" set -o errexit set -o errtrace set -o nounset @@ -19,29 +26,29 @@ alias die='EXIT=$? LINE=$LINENO error_exit' trap die ERR function error_exit() { - trap - ERR - local reason="Unknown failure occured." - local msg="${1:-$reason}" - local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" - echo -e "$flag $msg" 1>&2 - exit $EXIT + trap - ERR + local reason="Unknown failure occured." + local msg="${1:-$reason}" + local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" + echo -e "$flag $msg" 1>&2 + exit $EXIT } - +if command -v pveversion >/dev/null 2>&1; then echo -e "⚠️ Can't Install on Proxmox "; exit; fi while true; do - read -p "This will Install ${APP}. Proceed(y/n)?" yn + read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; esac done clear function header_info { -echo -e "${BL} + echo -e "${BL} _____ _ _____ / ____| | |/ ____| | | _ __ _____ ____| | (___ ___ ___ - | | v3 | __/ _ \ \ /\ / / _ |\___ \ / _ \/ __| + | | | __/ _ \ \ /\ / / _ |\___ \ / _ \/ __| | |____| | | (_) \ V V / (_| |____) | __/ (__ \_____|_| \___/ \_/\_/ \__ _|_____/ \___|\___| ${CL}" @@ -61,14 +68,15 @@ function msg_ok() { msg_info "Setting up ${APP} Repository" apt-get update &>/dev/null +apt-get install -y curl &>/dev/null apt-get install -y gnupg &>/dev/null -curl -s https://packagecloud.io/install/repositories/crowdsec/crowdsec/script.deb.sh | sudo bash &>/dev/null +curl -s https://packagecloud.io/install/repositories/crowdsec/crowdsec/script.deb.sh | bash &>/dev/null msg_ok "Setup ${APP} Repository" msg_info "Installing ${APP}" apt-get update &>/dev/null apt-get install -y crowdsec &>/dev/null -msg_ok "Installed ${APP}" +msg_ok "Installed ${APP} on $hostname" msg_info "Installing ${APP} Common Bouncer" apt-get install -y crowdsec-firewall-bouncer-iptables &>/dev/null diff --git a/misc/dashy-update.sh b/misc/dashy-update.sh deleted file mode 100644 index 6e7151de..00000000 --- a/misc/dashy-update.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env bash -set -e -clear -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will Update Dashy LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - _____ _ - | __ \ | | - | | | | __ _ ___| |__ _ _ - | | | |/ _ / __| _ \| | | | - | |__| | (_| \__ \ | | | |_| | - |_____/ \__,_|___/_| |_|\__, | - UPDATE __/ | - |___/ -${CL}" -} - -header_info -echo -en "${GN} Stopping Dashy... " -systemctl stop dashy -sleep 1 -echo -e "${CM}${CL} \r" - -echo -en "${GN} Backup conf.yml... " -cd ~ -cp -R /dashy/public/conf.yml conf.yml -sleep 1 -echo -e "${CM}${CL} \r" - -echo -en "${GN} Updating Dashy... " -cd /dashy -git merge &>/dev/null -git pull origin master &>/dev/null -yarn &>/dev/null -yarn build &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Restoring conf.yml... " -cd ~ -cp -R conf.yml /dashy/public -sleep 1 -echo -e "${CM}${CL} \r" - -echo -en "${GN} Cleaning... " -rm -rf conf.yml -sleep 1 -echo -e "${CM}${CL} \r" - -echo -en "${GN} Starting Dashy... " -systemctl start dashy -sleep 1 -echo -e "${CM}${CL} \r" - -echo -e "${GN} Finished ${CL}\n" diff --git a/misc/edge-kernel.sh b/misc/edge-kernel.sh deleted file mode 100644 index e4c37235..00000000 --- a/misc/edge-kernel.sh +++ /dev/null @@ -1,139 +0,0 @@ -#!/usr/bin/env bash -# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/edge-kernel.sh)" -set -e -KERNEL_ON=$(uname -r) -PVE_KERNEL=$(dpkg --list| grep 'kernel-.*-pve' | awk '{print substr($2, 12, length($2)-1) }' | tac | head -n 1) -EDGE_KERNEL=$(dpkg --list| grep 'kernel-.*-edge' | awk '{print substr($2, 12, length($2)-1) }' | tac | head -n 1) -clear -while true; do - read -p "This is a Proxmox Edge Kernel Tool, USE AT YOUR OWN RISK. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear - -show_menu(){ - normal=`echo "\033[m"` - safe=`echo "\033[32m"` - menu=`echo "\033[36m"` - number=`echo "\033[33m"` - bgred=`echo "\033[41m"` - fgred=`echo "\033[31m"` - proxmox-boot-tool kernel list - echo -e "\nCurrent Kernel: ${menu}${KERNEL_ON}${normal}" - printf "\n${menu}*********************************************${normal}\n" - printf "${menu}**${number} 1)${normal} Install Proxmox 5.18 Edge Kernel & Reboot\n" - printf "${menu}**${number} 2)${normal} Switch to Proxmox VE 7 ${menu}${PVE_KERNEL}${normal} Kernel & Reboot\n" - printf "${menu}**${number} 3)${normal} Switch to Proxmox Edge ${menu}${EDGE_KERNEL}${normal} Kernel & Reboot\n" - printf "${menu}**${number} 4)${normal} Unpin Current Kernel\n" - printf "${menu}**${number} 5)${normal} Remove Proxmox Edge Kernel & Reboot\n" - printf "${menu}*********************************************${normal}\n" - printf "Please choose an option from the menu and enter or ${fgred}x${normal} to exit." - read opt -} -option_picked(){ - msgcolor=`echo "\033[01;31m"` - normal=`echo "\033[00;00m"` - message=${@:-"${normal}Error: No message passed"} - printf "${msgcolor}${message}${normal}\n" -} -clear -show_menu -while [ $opt != '' ] - do - if [ $opt = '' ]; then - exit; - else - case $opt in - 1) while true; do - read -p "Are you sure you want to Install Proxmox 5.18 Edge Kernel & Reboot? Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac - done - clear; - option_picked "Installing Proxmox 5.18 Edge Kernel & Rebooting"; - apt-get install -y gnupg - curl -1sLf 'https://dl.cloudsmith.io/public/pve-edge/kernel/gpg.8EC01CCF309B98E7.key' | apt-key add - - echo "deb https://dl.cloudsmith.io/public/pve-edge/kernel/deb/debian bullseye main" > /etc/apt/sources.list.d/pve-edge-kernel.list - apt-get -y update - apt-get -y install pve-kernel-5.18-edge - reboot - break; - ;; - 2) while true; do - read -p "Are you sure you want to Switch to Proxmox VE 7 ${PVE_KERNEL} Kernel & Reboot? Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac - done - clear; - option_picked "Switching to Proxmox VE 7 Kernel & Rebooting"; - proxmox-boot-tool kernel pin ${PVE_KERNEL} - reboot - break; - ;; - 3) while true; do - read -p "Are you sure you want to Switch to Proxmox ${EDGE_KERNEL} Edge Kernel & Reboot? Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac - done - clear; - option_picked "Switching to Proxmox Edge Kernel & Rebooting"; - proxmox-boot-tool kernel pin ${EDGE_KERNEL} - reboot - break; - ;; - 4) while true; do - read -p "Are you sure you want to Unpin the Current Kernel? Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac - done - clear; - option_picked "Unpinning Current Kernel"; - proxmox-boot-tool kernel unpin - clear; - break; - ;; - 5) while true; do - read -p "Are you sure you want to Remove Proxmox Edge Kernel & Reboot? Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac - done - clear; - option_picked "Removing Proxmox Edge Kernel & Rebooting"; - apt-get purge -y ${EDGE_KERNEL} - rm -rf /etc/apt/sources.list.d/pve-edge-kernel.list - proxmox-boot-tool kernel unpin - reboot - break; - ;; - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose an option from the menu"; - show_menu; - ;; - esac - fi - done - -show_menu diff --git a/misc/filebrowser-v3.sh b/misc/filebrowser-v3.sh deleted file mode 100644 index 78cf8ab2..00000000 --- a/misc/filebrowser-v3.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env bash -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}" -APP="FileBrowser" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -function error_exit() { - trap - ERR - local reason="Unknown failure occured." - local msg="${1:-$reason}" - local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" - echo -e "$flag $msg" 1>&2 - exit $EXIT -} - -while true; do - read -p "This will Install ${APP}. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${DGN} - - ______ _ _ ____ - | ____(_) | | _ \ - | |__ _| | ___| |_) |_ __ _____ v3 _____ ___ _ __ - | __| | | |/ _ \ _ <| __/ _ \ \ /\ / / __|/ _ \ __| - | | | | | __/ |_) | | | (_) \ V V /\__ \ __/ | - |_| |_|_|\___|____/|_| \___/ \_/\_/ |___/\___|_| -${CL}" -} - -header_info - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -msg_info "Installing ${APP}" -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 ${APP}" - -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 "${APP} should be reachable by going to the following URL. - ${BL}http://$(hostname -I):8080${CL} \n" diff --git a/misc/filebrowser.sh b/misc/filebrowser.sh new file mode 100644 index 00000000..c4cc0e8d --- /dev/null +++ b/misc/filebrowser.sh @@ -0,0 +1,104 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + _______ __ ____ + / ____(_) /__ / __ )_________ _ __________ _____ + / /_ / / / _ \/ __ / ___/ __ \ | /| / / ___/ _ \/ ___/ + / __/ / / / __/ /_/ / / / /_/ / |/ |/ (__ ) __/ / +/_/ /_/_/\___/_____/_/ \____/|__/|__/____/\___/_/ + +EOF +} +IP=$(hostname -I | awk '{print $1}') +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}" +APP="FileBrowser" +hostname="$(hostname)" +header_info +if [ -f /root/filebrowser.db ]; then + read -r -p "Would you like to uninstall ${APP} on $hostname.? <y/N> " prompt + if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + systemctl disable -q --now filebrowser.service + rm -rf /usr/local/bin/filebrowser /root/filebrowser.db /etc/systemd/system/filebrowser.service + echo "$APP Removed" + sleep 2 + clear + exit + else + clear + exit + fi +fi +while true; do + read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac +done +header_info +function msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." +} + +function msg_ok() { + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" +} + +read -r -p "Would you like to use No Authentication? <y/N> " prompt +msg_info "Installing ${APP}" +apt-get install -y curl &>/dev/null +RELEASE=$(curl -fsSL https://api.github.com/repos/filebrowser/filebrowser/releases/latest | grep -o '"tag_name": ".*"' | sed 's/"//g' | sed 's/tag_name: //g') +curl -fsSL https://github.com/filebrowser/filebrowser/releases/download/$RELEASE/linux-amd64-filebrowser.tar.gz | tar -xzv -C /usr/local/bin &>/dev/null + +if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then + filebrowser config init -a '0.0.0.0' &>/dev/null + filebrowser config set -a '0.0.0.0' &>/dev/null + filebrowser config init --auth.method=noauth &>/dev/null + filebrowser config set --auth.method=noauth &>/dev/null + filebrowser users add ID 1 --perm.admin &>/dev/null +else + 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 +fi +msg_ok "Installed ${APP} on $hostname" + +msg_info "Creating Service" +cat <<EOF >/etc/systemd/system/filebrowser.service +[Unit] +Description=Filebrowser +After=network-online.target + +[Service] +User=root +WorkingDirectory=/root/ +ExecStart=/usr/local/bin/filebrowser -r / + +[Install] +WantedBy=default.target +EOF +systemctl enable -q --now filebrowser.service +msg_ok "Created Service" + +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/misc/frigate-support.sh b/misc/frigate-support.sh index 3a26a3b9..8dbdc563 100644 --- a/misc/frigate-support.sh +++ b/misc/frigate-support.sh @@ -1,54 +1,48 @@ #!/usr/bin/env bash -echo -e "\e[1;33m This script will Prepare a LXC Container for Frigate \e[0m" + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear +cat <<"EOF" + ____ _ __ ____ __ + / __/___(_)__ ____ _/ /____ / __/_ _____ ___ ___ ____/ /_ + / _// __/ / _ `/ _ `/ __/ -_) _\ \/ // / _ \/ _ \/ _ \/ __/ __/ +/_/ /_/ /_/\_, /\_,_/\__/\__/ /___/\_,_/ .__/ .__/\___/_/ \__/ + /___/ /_/ /_/ +EOF +} +header_info while true; do - read -p "Did you replace 106 with your LXC ID? Proceed (y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac + read -p "This will Prepare a LXC Container for Frigate. Proceed (y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac done -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT +header_info -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -CHAR_DEVS+=("1:1") -CHAR_DEVS+=("29:0") -CHAR_DEVS+=("188:.*") -CHAR_DEVS+=("189:.*") -CHAR_DEVS+=("226:0") -CHAR_DEVS+=("226:128") +# The array of device types +# CHAR_DEVS+=(major:minor) +CHAR_DEVS+=("1:1") # mem +CHAR_DEVS+=("29:0") # fb0 +CHAR_DEVS+=("188:.*") # ttyUSB* +CHAR_DEVS+=("189:.*") # bus/usb/* +CHAR_DEVS+=("226:0") # card0 +CHAR_DEVS+=("226:128") # renderD128 +# Proccess char device string for char_dev in ${CHAR_DEVS[@]}; do [ ! -z "${CHAR_DEV_STRING-}" ] && CHAR_DEV_STRING+=" -o" CHAR_DEV_STRING+=" -regex \".*/${char_dev}\"" done -read -r -d '' HOOK_SCRIPT <<- EOF || true +# Store autodev hook script in a variable +read -r -d '' HOOK_SCRIPT <<-EOF || true for char_dev in \$(find /sys/dev/char -regextype sed $CHAR_DEV_STRING); do dev="/dev/\$(sed -n "/DEVNAME/ s/^.*=\(.*\)$/\1/p" \${char_dev}/uevent)"; mkdir -p \$(dirname \${LXC_ROOTFS_MOUNT}\${dev}); @@ -59,19 +53,41 @@ for char_dev in \$(find /sys/dev/char -regextype sed $CHAR_DEV_STRING); do cp -dpR \$dev \${LXC_ROOTFS_MOUNT}\${dev}; done; EOF + +# Remove newline char from the variable HOOK_SCRIPT=${HOOK_SCRIPT//$'\n'/} -CTID=$1 +# Generate menu of LXC containers in current node +NODE=$(hostname) +while read -r line; do + TAG=$(echo "$line" | awk '{print $1}') + ITEM=$(echo "$line" | awk '{print substr($0,36)}') + OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + CTID_MENU+=("$TAG" "$ITEM " "OFF") +done < <(pct list | awk 'NR>1') + +# Selection menu for LXC containers +while [ -z "${CTID:+x}" ]; do + CTID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Containers on $NODE" --radiolist \ + "\nSelect a container to add support:\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || exit +done + +# Add autodev settings CTID_CONFIG_PATH=/etc/pve/lxc/${CTID}.conf sed '/autodev/d' $CTID_CONFIG_PATH >CTID.conf cat CTID.conf >$CTID_CONFIG_PATH -cat <<EOF >> $CTID_CONFIG_PATH +cat <<EOF >>$CTID_CONFIG_PATH lxc.autodev: 1 lxc.hook.autodev: bash -c '$HOOK_SCRIPT' EOF -echo -e "\e[1;33m Finished....Reboot ${CTID} LXC to apply the changes \e[0m" +echo -e "\e[1;33m \nFinished....Reboot ${CTID} LXC to apply the changes.\n \e[0m" -# In the Proxmox web shell run (replace 106 with your LXC ID) -# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/frigate-support.sh)" -s 106 -# Reboot the LXC to apply the changes +# In the Proxmox web shell run +# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/frigate-support.sh)" +# Reboot the LXC to apply the changes \ No newline at end of file diff --git a/misc/fstrim.sh b/misc/fstrim.sh new file mode 100644 index 00000000..5c0e2ae6 --- /dev/null +++ b/misc/fstrim.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info() { + clear + cat <<"EOF" + _______ __ __ ______ _ + / ____(_) /__ _______ _______/ /____ ____ ___ /_ __/____(_)___ ___ + / /_ / / / _ \/ ___/ / / / ___/ __/ _ \/ __ `__ \ / / / ___/ / __ `__ \ + / __/ / / / __(__ ) /_/ (__ ) /_/ __/ / / / / / / / / / / / / / / / / +/_/ /_/_/\___/____/\__, /____/\__/\___/_/ /_/ /_/ /_/ /_/ /_/_/ /_/ /_/ + /____/ +EOF +} +BL=$(echo "\033[36m") +RD=$(echo "\033[01;31m") +CM='\xE2\x9C\x94\033' +GN=$(echo "\033[1;92m") +CL=$(echo "\033[m") +header_info +echo "Loading..." + +ROOT_FS=$(df -Th "/" | awk 'NR==2 {print $2}') +if [ "$ROOT_FS" != "ext4" ]; then + echo "Root filesystem is not ext4. Exiting script." + exit 1 +fi + +whiptail --backtitle "Proxmox VE Helper Scripts" --title "Proxmox VE LXC Filesystem Trim" --yesno "The LXC containers will undergo the fstrim command. Proceed?" 10 58 || exit +NODE=$(hostname) +EXCLUDE_MENU=() +MSG_MAX_LENGTH=0 +while read -r TAG ITEM; do + OFFSET=2 + ((${#ITEM} + OFFSET > MSG_MAX_LENGTH)) && MSG_MAX_LENGTH=${#ITEM}+OFFSET + EXCLUDE_MENU+=("$TAG" "$ITEM " "OFF") +done < <(pct list | awk 'NR>1') +excluded_containers=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Containers on $NODE" --checklist "\nSelect containers to skip from trimming:\n" \ + 16 $((MSG_MAX_LENGTH + 23)) 6 "${EXCLUDE_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"') || exit + +function trim_container() { + local container=$1 + header_info + echo -e "${BL}[Info]${GN} Trimming ${BL}$container${CL} \n" + local before_trim=$(lvs | awk -F '[[:space:]]+' 'NR>1 && (/Data%|'"vm-$container"'/) {gsub(/%/, "", $7); print $7}') + echo -e "${RD}Data before trim $before_trim%${CL}" + pct fstrim $container + local after_trim=$(lvs | awk -F '[[:space:]]+' 'NR>1 && (/Data%|'"vm-$container"'/) {gsub(/%/, "", $7); print $7}') + echo -e "${GN}Data after trim $after_trim%${CL}" + sleep 1.5 +} + + + +for container in $(pct list | awk '{if(NR>1) print $1}'); do + if [[ " ${excluded_containers[@]} " =~ " $container " ]]; then + header_info + echo -e "${BL}[Info]${GN} Skipping ${BL}$container${CL}" + sleep 1 + else + template=$(pct config $container | grep -q "template:" && echo "true" || echo "false") + if [ "$template" == "true" ]; then + header_info + echo -e "${BL}[Info]${GN} Skipping ${container} ${RD}$container is a template ${CL} \n" + sleep 1 + continue + fi + trim_container $container + fi +done + +wait +header_info +echo -e "${GN} Finished, LXC Containers Trimmed. ${CL} \n" diff --git a/misc/glances.sh b/misc/glances.sh new file mode 100644 index 00000000..31840977 --- /dev/null +++ b/misc/glances.sh @@ -0,0 +1,125 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + ________ + / ____/ /___ _____ ________ _____ + / / __/ / __ `/ __ \/ ___/ _ \/ ___/ +/ /_/ / / /_/ / / / / /__/ __(__ ) +\____/_/\__,_/_/ /_/\___/\___/____/ + +EOF +} +IP=$(hostname -I | awk '{print $1}') +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}" +APP="Glances" +hostname="$(hostname)" +silent() { "$@" >/dev/null 2>&1; } +set -e +spinner() { + local chars="/-\|" + local spin_i=0 + printf "\e[?25l" + while true; do + printf "\r \e[36m%s\e[0m" "${chars:spin_i++%${#chars}:1}" + sleep 0.1 + done +} + +msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg} " + spinner & + SPINNER_PID=$! +} + +msg_ok() { + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi + printf "\e[?25h" + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" +} + +install() { + header_info + while true; do + read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac + done + header_info + read -r -p "Verbose mode? <y/N> " prompt + if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then + STD="" + else + STD="silent" + fi + msg_info "Installing $APP" + rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED + $STD bash -c "$(wget -qLO - https://raw.githubusercontent.com/nicolargo/glancesautoinstall/master/install.sh)" + cat <<EOF >/etc/systemd/system/glances.service +[Unit] +Description=Glances - An eye on your system +After=network.target + +[Service] +Type=simple +ExecStart=/usr/local/bin/glances -w +Restart=on-failure + +[Install] +WantedBy=multi-user.target +EOF + systemctl enable -q --now glances.service + msg_ok "Installed $APP on $hostname" + + echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://$IP:61208${CL} \n" +} +uninstall() { + header_info + msg_info "Uninstalling $APP" + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi + systemctl disable -q --now glances + bash -c "$(wget -qLO - https://raw.githubusercontent.com/nicolargo/glancesautoinstall/master/uninstall.sh)" + rm -rf /etc/systemd/system/glances.service + msg_ok "Uninstalled $APP" + msg_ok "Completed Successfully!\n" +} + +OPTIONS=(Install "Install $APP" \ + Uninstall "Uninstall $APP") + +CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "$APP" --menu "Select an option:" 10 58 2 \ + "${OPTIONS[@]}" 3>&1 1>&2 2>&3) + +case $CHOICE in + "Install") + install + ;; + "Uninstall") + uninstall + ;; + *) + echo "Exiting..." + exit 0 + ;; +esac diff --git a/misc/hacs.sh b/misc/hacs.sh deleted file mode 100644 index ed476b0d..00000000 --- a/misc/hacs.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -echo -e "\e[1;33m This script will install Home Assistant Community Store (HACS) \e[0m" - -while true; do - read -p "Start the HACS Install Script (y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done - -apt update &>/dev/null -apt install unzip &>/dev/null -cd /var/lib/docker/volumes/hass_config/_data -wget -O - https://get.hacs.xyz | bash - - -# To install HACS run the following from the container (LXC) console -# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/hacs.sh)" -# Then add the integration in HA diff --git a/misc/heimdalldashboard-all-update.sh b/misc/heimdalldashboard-all-update.sh deleted file mode 100644 index 66539ed6..00000000 --- a/misc/heimdalldashboard-all-update.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env bash -set -e -PP=`echo "\e[1;35m"` -RD=`echo "\033[01;31m"` -BL=`echo "\033[36m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will Update Heimdall Dashboard. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${PP} - _ _ _ _ _ _ _____ _ _ _ - | | | | (_) | | | | | | __ \ | | | | | | - | |__| | ___ _ _ __ ___ __| | __ _| | | | | | | __ _ ___| |__ | |__ ___ __ _ _ __ __| | - | __ |/ _ \ | _ _ \ / _ |/ _ | | | | | | |/ _ / __| _ \| _ \ / _ \ / _ | __/ _ | - | | | | __/ | | | | | | (_| | (_| | | | | |__| | (_| \__ \ | | | |_) | (_) | (_| | | | (_| | - |_| |_|\___|_|_| |_| |_|\__,_|\__,_|_|_| |_____/ \__,_|___/_| |_|_.__/ \___/ \__,_|_| \__,_| - ${RD}UPDATE -${CL}" -} - -header_info - -echo -en "${GN} Stopping Heimdall Dashboard... " -systemctl disable heimdall.service &>/dev/null -systemctl stop heimdall -sleep 1 -echo -e "${CM}${CL} \r" - -echo -en "${GN} 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 -echo -e "${CM}${CL} \r" - -RELEASE=$(curl -sX GET "https://api.github.com/repos/linuxserver/Heimdall/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]') -echo -en "${GN} 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 -echo -e "${CM}${CL} \r" - -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 - -echo -en "${GN} Restoring Data... " -cp -R database-backup/* /opt/Heimdall/database -cp -R public-backup/* /opt/Heimdall/public -sleep 1 -echo -e "${CM}${CL} \r" - -echo -en "${GN} 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 -echo -e "${CM}${CL} \r" - -echo -en "${GN} Starting Heimdall Dashboard... " -systemctl enable --now heimdall.service &>/dev/null -sleep 2 -echo -e "${CM}${CL} \r" - -echo -en "${GN} Finished! ${CL}\n" - diff --git a/misc/host-backup.sh b/misc/host-backup.sh new file mode 100644 index 00000000..31b67bfa --- /dev/null +++ b/misc/host-backup.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + __ __ __ ___ __ + / // /__ ___ / /_ / _ )___ _____/ /____ _____ + / _ / _ \(_-</ __/ / _ / _ `/ __/ '_/ // / _ \ +/_//_/\___/___/\__/ /____/\_,_/\__/_/\_\\_,_/ .__/ + /_/ +EOF +} + +# Function to perform backup +function perform_backup { + local BACKUP_PATH + local DIR + local DIR_DASH + local BACKUP_FILE + local selected_directories=() + + # Get backup path from user + BACKUP_PATH=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "\nDefaults to /root/\ne.g. /mnt/backups/" 11 68 --title "Directory to backup to:" 3>&1 1>&2 2>&3) || return + + # Default to /root/ if no input + BACKUP_PATH="${BACKUP_PATH:-/root/}" + + # Get directory to work in from user + DIR=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "\nDefaults to /etc/\ne.g. /root/, /var/lib/pve-cluster/ etc." 11 68 --title "Directory to work in:" 3>&1 1>&2 2>&3) || return + + # Default to /etc/ if no input + DIR="${DIR:-/etc/}" + + DIR_DASH=$(echo "$DIR" | tr '/' '-') + BACKUP_FILE="$(hostname)${DIR_DASH}backup" + + # Build a list of directories for backup + local CTID_MENU=() + while read -r dir; do + CTID_MENU+=("$(basename "$dir")" "$dir " "OFF") + done < <(ls -d "${DIR}"*) + + # Allow the user to select directories + local HOST_BACKUP + while [ -z "${HOST_BACKUP:+x}" ]; do + HOST_BACKUP=$(whiptail --backtitle "Proxmox VE Host Backup" --title "Working in the ${DIR} directory " --checklist \ + "\nSelect what files/directories to backup:\n" 16 $(((${#DIRNAME} + 2) + 88)) 6 "${CTID_MENU[@]}" 3>&1 1>&2 2>&3) || return + + for selected_dir in ${HOST_BACKUP//\"/}; do + selected_directories+=("${DIR}$selected_dir") + done + done + + # Perform the backup + header_info + echo -e "This will create a backup in\e[1;33m $BACKUP_PATH \e[0mfor these files and directories\e[1;33m ${selected_directories[*]} \e[0m" + read -p "Press ENTER to continue..." + header_info + echo "Working..." + tar -czf "$BACKUP_PATH$BACKUP_FILE-$(date +%Y_%m_%d).tar.gz" --absolute-names "${selected_directories[@]}" + header_info + echo -e "\nFinished" + echo -e "\e[1;33m \nA backup is rendered ineffective when it remains stored on the host.\n \e[0m" + sleep 2 +} + +# Main script execution loop +while true; do + if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "Proxmox VE Host Backup" --yesno "This will create backups for particular files and directories located within a designated directory. Proceed?" 10 88); then + perform_backup + else + break + fi +done diff --git a/misc/hw-acceleration.sh b/misc/hw-acceleration.sh new file mode 100644 index 00000000..19a0b140 --- /dev/null +++ b/misc/hw-acceleration.sh @@ -0,0 +1,116 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +# Execute within the Proxmox shell +# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/hw-acceleration.sh)" + +set -e +function header_info { + clear + cat <<"EOF" + + __ ___ __ ___ __ __ _ + / // / | /| / / / _ |___________ / /__ _______ _/ /_(_)__ ___ + / _ /| |/ |/ / / __ / __/ __/ -_) / -_) __/ _ `/ __/ / _ \/ _ \ +/_//_/ |__/|__/ /_/ |_\__/\__/\__/_/\__/_/ \_,_/\__/_/\___/_//_/ + +EOF +} + +YW=$(echo "\033[33m") +BL=$(echo "\033[36m") +RD=$(echo "\033[01;31m") +GN=$(echo "\033[1;92m") +CL=$(echo "\033[m") +BFR="\\r\\033[K" +HOLD="-" +CM="${GN}✓${CL}" +set -e +header_info +echo "Loading..." +function msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." +} + +function msg_ok() { + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" +} + +if ! pveversion | grep -Eq "pve-manager/(8\.[1-3])"; then + msg_error "This version of Proxmox Virtual Environment is not supported" + echo -e "Requires PVE Version 8.1 or higher" + echo -e "Exiting..." + sleep 2 + exit +fi + +whiptail --backtitle "Proxmox VE Helper Scripts" --title "Add Intel HW Acceleration" --yesno "This Will Add Intel HW Acceleration to an existing LXC Container. Proceed?" 8 72 || exit +NODE=$(hostname) +PREV_MENU=() +MSG_MAX_LENGTH=0 +privileged_containers=$(pct list | awk 'NR>1 && system("grep -q \047unprivileged: 1\047 /etc/pve/lxc/" $1 ".conf")') + +if [ -z "$privileged_containers" ]; then + whiptail --msgbox "No Privileged Containers Found." 10 58 + exit +fi + +while read -r TAG ITEM; do + OFFSET=2 + ((${#ITEM} + OFFSET > MSG_MAX_LENGTH)) && MSG_MAX_LENGTH=${#ITEM}+OFFSET + PREV_MENU+=("$TAG" "$ITEM " "OFF") +done < <(echo "$privileged_containers") + +privileged_container=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Privileged Containers on $NODE" --checklist "\nSelect a Container To Add Intel HW Acceleration:\n" 16 $((MSG_MAX_LENGTH + 23)) 6 "${PREV_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"') || exit +header_info +read -r -p "Verbose mode? <y/N> " prompt + if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then + STD="" + else + STD="silent" + fi +header_info + +cat <<EOF >>/etc/pve/lxc/${privileged_container}.conf +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 + +read -r -p "Do you need the intel-media-va-driver-non-free driver (Debian 12 only)? <y/N> " prompt +if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then + header_info + msg_info "Installing Hardware Acceleration (non-free)" + pct exec ${privileged_container} -- bash -c "cat <<EOF >/etc/apt/sources.list.d/non-free.list + +deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware +deb-src http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware + +deb http://deb.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware +deb-src http://deb.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware + +deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware +deb-src http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware +EOF" + + pct exec ${privileged_container} -- bash -c "silent() { \"\$@\" >/dev/null 2>&1; } && $STD apt-get update && $STD apt-get install -y intel-media-va-driver-non-free ocl-icd-libopencl1 intel-opencl-icd vainfo intel-gpu-tools && $STD adduser \$(id -u -n) video && $STD adduser \$(id -u -n) render" + msg_ok "Installed Hardware Acceleration (non-free)" +else + header_info + msg_info "Installing Hardware Acceleration" + pct exec ${privileged_container} -- bash -c "silent() { \"\$@\" >/dev/null 2>&1; } && $STD apt-get install -y va-driver-all ocl-icd-libopencl1 intel-opencl-icd vainfo intel-gpu-tools && chgrp video /dev/dri && chmod 755 /dev/dri && $STD adduser \$(id -u -n) video && $STD adduser \$(id -u -n) render" + msg_ok "Installed Hardware Acceleration" +fi +sleep 1 +whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "Added tools" "vainfo, execute command 'vainfo'\nintel-gpu-tools, execute command 'intel_gpu_top'" 8 58 + +msg_ok "Completed Successfully!\n" +echo -e "Reboot container ${BL}$privileged_container${CL} to apply the new settings\n" diff --git a/misc/images/adminer.png b/misc/images/adminer.png deleted file mode 100644 index bede2757..00000000 Binary files a/misc/images/adminer.png and /dev/null differ diff --git a/misc/images/adminer_logo-cl.png b/misc/images/adminer_logo-cl.png deleted file mode 100644 index 0d3b6bd4..00000000 Binary files a/misc/images/adminer_logo-cl.png and /dev/null differ diff --git a/misc/images/change.png b/misc/images/change.png deleted file mode 100644 index 5543ec3e..00000000 Binary files a/misc/images/change.png and /dev/null differ diff --git a/misc/images/changelog.png b/misc/images/changelog.png deleted file mode 100644 index f762d00e..00000000 Binary files a/misc/images/changelog.png and /dev/null differ diff --git a/misc/images/discussions.png b/misc/images/discussions.png deleted file mode 100644 index ea667889..00000000 Binary files a/misc/images/discussions.png and /dev/null differ diff --git a/misc/images/docker.png b/misc/images/docker.png deleted file mode 100644 index 210598c2..00000000 Binary files a/misc/images/docker.png and /dev/null differ diff --git a/misc/images/file-manager.png b/misc/images/file-manager.png deleted file mode 100644 index 4acbe6df..00000000 Binary files a/misc/images/file-manager.png and /dev/null differ diff --git a/misc/images/gamuntu.png b/misc/images/gamuntu.png deleted file mode 100644 index b29f2158..00000000 Binary files a/misc/images/gamuntu.png and /dev/null differ diff --git a/misc/images/gamuntu1.png b/misc/images/gamuntu1.png deleted file mode 100644 index 3502838d..00000000 Binary files a/misc/images/gamuntu1.png and /dev/null differ diff --git a/misc/images/logo-81x112.png b/misc/images/logo-81x112.png new file mode 100644 index 00000000..04bcb8d1 Binary files /dev/null and b/misc/images/logo-81x112.png differ diff --git a/misc/images/logo.png b/misc/images/logo.png new file mode 100644 index 00000000..1d2186da Binary files /dev/null and b/misc/images/logo.png differ diff --git a/misc/images/monitor.png b/misc/images/monitor.png new file mode 100644 index 00000000..8b280dfd Binary files /dev/null and b/misc/images/monitor.png differ diff --git a/misc/images/motioneye-256x256.png b/misc/images/motioneye-256x256.png deleted file mode 100644 index 2f0fbaf3..00000000 Binary files a/misc/images/motioneye-256x256.png and /dev/null differ diff --git a/misc/images/node-red-themes.png b/misc/images/node-red-themes.png deleted file mode 100644 index f7a7bdb8..00000000 Binary files a/misc/images/node-red-themes.png and /dev/null differ diff --git a/misc/images/openobsecure.png b/misc/images/openobsecure.png new file mode 100644 index 00000000..52bbc970 Binary files /dev/null and b/misc/images/openobsecure.png differ diff --git a/misc/images/pimox.png b/misc/images/pimox.png new file mode 100644 index 00000000..a6a8baed Binary files /dev/null and b/misc/images/pimox.png differ diff --git a/misc/images/play_prism.png b/misc/images/play_prism.png deleted file mode 100644 index d97c1625..00000000 Binary files a/misc/images/play_prism.png and /dev/null differ diff --git a/misc/images/pms-copy-data.png b/misc/images/pms-copy-data.png deleted file mode 100644 index 073f90d7..00000000 Binary files a/misc/images/pms-copy-data.png and /dev/null differ diff --git a/misc/images/processor.png b/misc/images/processor.png new file mode 100644 index 00000000..75af60a9 Binary files /dev/null and b/misc/images/processor.png differ diff --git a/misc/images/prome.png b/misc/images/prome.png deleted file mode 100644 index 0f6f3de4..00000000 Binary files a/misc/images/prome.png and /dev/null differ diff --git a/misc/images/proxcord.png b/misc/images/proxcord.png deleted file mode 100644 index 619f32bd..00000000 Binary files a/misc/images/proxcord.png and /dev/null differ diff --git a/misc/images/social.png b/misc/images/social.png deleted file mode 100644 index 396c8848..00000000 Binary files a/misc/images/social.png and /dev/null differ diff --git a/misc/images/update-menu.png b/misc/images/update-menu.png deleted file mode 100644 index 42e65b98..00000000 Binary files a/misc/images/update-menu.png and /dev/null differ diff --git a/misc/install.func b/misc/install.func new file mode 100644 index 00000000..4bdc932c --- /dev/null +++ b/misc/install.func @@ -0,0 +1,203 @@ +# This function sets color variables for formatting output in the terminal +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=" " +} + +# This function enables IPv6 if it's not disabled and sets verbose mode if the global variable is set to "yes" +verb_ip6() { + if [ "$VERBOSE" = "yes" ]; then + 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 +} + +# This function sets error handling options and defines the error_handler function to handle errors +catch_errors() { + set -Eeuo pipefail + trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +} + +# This function handles errors +error_handler() { + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi + printf "\e[?25h" + 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" + if [[ "$line_number" -eq 23 ]]; then + echo -e "The silent function has suppressed the error, run the script with verbose mode enabled, which will provide more detailed output.\n" + fi +} + +# This function displays a spinner. +spinner() { + local chars="/-\|" + local spin_i=0 + printf "\e[?25l" + while true; do + printf "\r \e[36m%s\e[0m" "${chars:spin_i++%${#chars}:1}" + sleep 0.1 + done +} + +# This function displays an informational message with a yellow color. +msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg} " + spinner & + SPINNER_PID=$! +} + + +# This function displays a success message with a green color. +msg_ok() { + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi + printf "\e[?25h" + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" +} + +# This function displays a error message with a red color. +msg_error() { + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi + printf "\e[?25h" + local msg="$1" + echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" +} + +# This function sets up the Container OS by generating the locale, setting the timezone, and checking the network connection +setting_up_container() { + msg_info "Setting up Container OS" + sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen + locale_line=$(grep -v '^#' /etc/locale.gen | grep -E '^[a-zA-Z]' | awk '{print $1}' | head -n 1) + echo "LANG=${locale_line}" >/etc/default/locale + locale-gen >/dev/null + export LANG=${locale_line} + 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 + rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED + systemctl disable -q --now systemd-networkd-wait-online.service + msg_ok "Set up Container OS" + msg_ok "Network Connected: ${BL}$(hostname -I)" +} + +# This function checks the network connection by pinging a known IP address and prompts the user to continue if the internet is not connected +network_check() { + set +e + trap - ERR + ipv4_connected=false + ipv6_connected=false + sleep 1 +# Check IPv4 connectivity + if ping -c 1 -W 1 1.1.1.1 &>/dev/null; then + msg_ok "IPv4 Internet Connected"; + ipv4_connected=true + else + msg_error "IPv4 Internet Not Connected"; + fi + +# Check IPv6 connectivity + if ping6 -c 1 -W 1 2606:4700:4700::1111 &>/dev/null; then + msg_ok "IPv6 Internet Connected"; + ipv6_connected=true + else + msg_error "IPv6 Internet Not Connected"; + fi + +# If both IPv4 and IPv6 checks fail, prompt the user + if [[ $ipv4_connected == false && $ipv6_connected == false ]]; then + read -r -p "No Internet detected,would you like to continue anyway? <y/N> " 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 +} + +# This function updates the Container OS by running apt-get update and upgrade +update_os() { + msg_info "Updating Container OS" + if [[ "$CACHER" == "yes" ]]; then + echo "Acquire::http::Proxy-Auto-Detect \"/usr/local/bin/apt-proxy-detect.sh\";" >/etc/apt/apt.conf.d/00aptproxy + cat <<EOF >/usr/local/bin/apt-proxy-detect.sh +#!/bin/bash +if nc -w1 -z "${CACHER_IP}" 3142; then + echo -n "http://${CACHER_IP}:3142" +else + echo -n "DIRECT" +fi +EOF + chmod +x /usr/local/bin/apt-proxy-detect.sh + fi + $STD apt-get update + $STD apt-get -o Dpkg::Options::="--force-confold" -y dist-upgrade + rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED + msg_ok "Updated Container OS" +} + +# This function modifies the message of the day (motd) and SSH settings +motd_ssh() { + echo "export TERM='xterm-256color'" >>/root/.bashrc + echo -e "$APPLICATION LXC provided by https://helper-scripts.com/\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 +} + +# This function customizes the container by modifying the getty service and enabling auto-login for the root user +customize() { + if [[ "$PASSWORD" == "" ]]; then + msg_info "Customizing Container" + GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" + mkdir -p $(dirname $GETTY_OVERRIDE) + cat <<EOF >$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 + echo "bash -c \"\$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/${app}.sh)\"" >/usr/bin/update + chmod +x /usr/bin/update +} diff --git a/misc/kernel-clean-v3.sh b/misc/kernel-clean-v3.sh deleted file mode 100644 index c079d7ea..00000000 --- a/misc/kernel-clean-v3.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env bash -ex -set -euo pipefail -shopt -s inherit_errexit nullglob -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}" -PARTY="🎉" -current_kernel=$(uname -r) -pve=$(pveversion) - -while true; do - read -p "This will Clean Unused Kernel Images, USE AT YOUR OWN RISK. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo -e "${RD}Please answer y/n${CL}";; - esac -done -clear - -function header_info { -echo -e "${RD} - _ __ _ _____ _ - | |/ / | | / ____| | - | / ___ _ __ _ __ ___| | | | | | ___ __ _ _ __ - | < / _ \ __| _ \ / _ \ | | | | |/ _ \/ _ | _ \ - | \ __/ | | | | | __/ | | |____| | __/ (_| | | | | - |_|\_\___|_| |_| |_|\___|_|v3\_____|_|\___|\__,_|_| |_| - -${CL}" -} - -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 check_root() { - if [[ $EUID -ne 0 ]]; then - echo -e "${CROSS}${RD}Error: This script must be ran as the root user.\n${CL}" - exit 1 - else - header_info - edge_kernel - kernel_info - kernel_clean - fi -} - -function edge_kernel() { - if [[ "$current_kernel" == *"edge"* ]]; then - echo -e "\n${CROSS} ${RD}ERROR:${CL} Proxmox ${BL}${current_kernel}${CL} Kernel Active" - echo -e "\nAn Active PVE Kernel is required to use Kernel Clean\n" - exit 1 - fi -} - -function kernel_info() { - latest_kernel=$(dpkg --list| grep 'kernel-.*-pve' | awk '{print $2}' | tac | head -n 1) - echo -e "${YW}PVE Version: ${BL}$pve\n${CL}" - if [[ "$current_kernel" == *"pve"* ]]; then - if [[ "$latest_kernel" != *"$current_kernel"* ]]; then - echo -e "${GN}Latest Kernel: $latest_kernel\n${CL}" - fi - else - echo -e "\n${CROSS} ${RD}ERROR: No PVE Kernel Found\n${CL}" - exit 1 - fi -} - -function kernel_clean() { - kernels=$(dpkg --list| grep 'kernel-.*-pve' | awk '{print $2}' | sort -V) - remove_kernels="" - for kernel in $kernels - do - if [ "$(echo $kernel | grep $current_kernel)" ]; then - break - else - echo -e "${BL}'$kernel' ${CL}${YW}has been added to the remove Kernel list\n${CL}" - remove_kernels+=" $kernel" - fi - done -msg_ok "Kernel Search Completed\n" - if [[ "$remove_kernels" != *"pve"* ]]; then - echo -e "${PARTY} ${GN}It appears there are no old Kernels on your system. \n${CL}" - msg_info "Exiting" - sleep 2 - msg_ok "Done" - else - read -p "Would you like to remove the $(echo $remove_kernels | awk '{print NF}') selected Kernels listed above? [y/n]: " -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - msg_info "Removing ${CL}${RD}$(echo $remove_kernels | awk '{print NF}') ${CL}${YW}old Kernels${CL}" - /usr/bin/apt purge -y $remove_kernels > /dev/null 2>&1 - msg_ok "Successfully Removed Kernels" - msg_info "Updating GRUB" - /usr/sbin/update-grub > /dev/null 2>&1 - msg_ok "Successfully Updated GRUB" - msg_info "Exiting" - sleep 2 - msg_ok "Done" - else - msg_info "Exiting" - sleep 2 - msg_ok "Done" - fi - fi -} - -check_root diff --git a/misc/kernel-clean.sh b/misc/kernel-clean.sh index 9a883003..ca31cc2f 100644 --- a/misc/kernel-clean.sh +++ b/misc/kernel-clean.sh @@ -1,100 +1,75 @@ -#!/bin/bash -RD=$(tput setaf 1) -GN=$(tput setaf 2) -LYW=$(tput setaf 190) -WH=$(tput setaf 7) -BRT=$(tput bold) -CL=$(tput sgr0) -UL=$(tput smul) -current_kernel=$(uname -r) -pve=$(pveversion) +#!/usr/bin/env bash -while true; do - read -p "${WH}This will Clean unused Kernel images. Proceed(y/n)?${CL}" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo -e "${RD}Please answer y/n${CL}";; - esac -done -clear - -function check_root { - if [[ $EUID -ne 0 ]]; then - echo -e "${RD}Error: This script must be ran as the root user.\n${CL}" - exit 1 - fi -} +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE function header_info { -echo -e "${RD} - _ __ _ _____ _ - | |/ / | | / ____| | - | / ___ _ __ _ __ ___| | | | | | ___ __ _ _ __ - | < / _ \ __| _ \ / _ \ | | | | |/ _ \/ _ | _ \ - | \ __/ | | | | | __/ | | |____| | __/ (_| | | | | - |_|\_\___|_| |_| |_|\___|_| \_____|_|\___|\__,_|_| |_| + clear + cat <<"EOF" + __ __ __ ________ + / //_/__ _________ ___ / / / ____/ /__ ____ _____ + / ,< / _ \/ ___/ __ \/ _ \/ / / / / / _ \/ __ `/ __ \ + / /| / __/ / / / / / __/ / / /___/ / __/ /_/ / / / / +/_/ |_\___/_/ /_/ /_/\___/_/ \____/_/\___/\__,_/_/ /_/ -${CL}" +EOF +} +YW=$(echo "\033[33m") +RD=$(echo "\033[01;31m") +GN=$(echo "\033[1;92m") +CL=$(echo "\033[m") +BFR="\\r\\033[K" +HOLD="-" +CM="${GN}✓${CL}" +current_kernel=$(uname -r) +available_kernels=$(dpkg --list | grep 'kernel-.*-pve' | awk '{print $2}' | grep -v "$current_kernel" | sort -V) +header_info + +function msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." } -function kernel_info() { - latest_kernel=$(dpkg --list| grep 'kernel-.*-pve' | awk '{print $2}' | tac | head -n 1) - echo -e "${LYW}PVE Version: ${UL}${WH}$pve\n${CL}" - if [[ "$current_kernel" == *"pve"* ]]; then - if [[ "$latest_kernel" != *"$current_kernel"* ]]; then - echo -e "${GN}Latest Kernel: $latest_kernel\n${CL}" - fi - else - echo -e "\n${RD}ERROR: No PVE Kernel Found\n${CL}" - exit 1 - fi +function msg_ok() { + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" } -function kernel_clean() { - kernels=$(dpkg --list| grep 'kernel-.*-pve' | awk '{print $2}' | sort -V) - remove_kernels="" - for kernel in $kernels - do - if [ "$(echo $kernel | grep $current_kernel)" ]; then - break - else - echo -e "${RD}'$kernel' ${CL}${LYW}has been added to the remove Kernel list\n${CL}" - remove_kernels+=" $kernel" - fi - done -echo -e "${LYW}Kernel Search Complete!\n${CL}" - if [[ "$remove_kernels" != *"pve"* ]]; then - echo -e "${BRT}${GN}It appears there are no old Kernels on your system. \n${CL}" - else - read -p "${LYW}Would you like to remove the${RD} $(echo $remove_kernels | awk '{print NF}') ${CL}${LYW}selected Kernels listed above? [y/n]: ${CL}" -n 1 -r - fi - if [[ $REPLY =~ ^[Yy]$ ]]; then - echo -e "${LYW}\nRemoving ${CL}${RD}$(echo $remove_kernels | awk '{print NF}') ${CL}${LYW}old Kernels...${CL}" - /usr/bin/apt purge -y $remove_kernels > /dev/null 2>&1 - echo -e "${LYW}Finished!\n${CL}" - echo -e "${LYW}Updating GRUB... \n${CL}" - /usr/sbin/update-grub > /dev/null 2>&1 - echo -e "${LYW}Finished!\n${CL}" - else - echo -e "${LYW}Exiting...\n${CL}" - sleep 2 - fi -} +whiptail --backtitle "Proxmox VE Helper Scripts" --title "Proxmox VE Kernel Clean" --yesno "This will Clean Unused Kernel Images, USE AT YOUR OWN RISK. Proceed?" 10 68 || exit +if [ -z "$available_kernels" ]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --title "No Old Kernels" --msgbox "It appears there are no old Kernels on your system. \nCurrent kernel ($current_kernel)." 10 68 + echo "Exiting..." + sleep 2 + clear + exit +fi + KERNEL_MENU=() + MSG_MAX_LENGTH=0 +while read -r TAG ITEM; do + OFFSET=2 + ((${#ITEM} + OFFSET > MSG_MAX_LENGTH)) && MSG_MAX_LENGTH=${#ITEM}+OFFSET + KERNEL_MENU+=("$TAG" "$ITEM " "OFF") +done < <(echo "$available_kernels") -function main() { - check_root - header_info - kernel_info +remove_kernels=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Current Kernel $current_kernel" --checklist "\nSelect Kernels to remove:\n" 16 $((MSG_MAX_LENGTH + 58)) 6 "${KERNEL_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"') || exit +[ -z "$remove_kernels" ] && { + whiptail --backtitle "Proxmox VE Helper Scripts" --title "No Kernel Selected" --msgbox "It appears that no Kernel was selected" 10 68 + echo "Exiting..." + sleep 2 + clear + exit } +whiptail --backtitle "Proxmox VE Helper Scripts" --title "Remove Kernels" --yesno "Would you like to remove the $(echo $remove_kernels | awk '{print NF}') previously selected Kernels?" 10 68 || exit -while true; do - case "$1" in - * ) - main - kernel_clean - exit 1 - ;; - esac - shift -done +msg_info "Removing ${CL}${RD}$(echo $remove_kernels | awk '{print NF}') ${CL}${YW}old Kernels${CL}" +/usr/bin/apt purge -y $remove_kernels >/dev/null 2>&1 +msg_ok "Successfully Removed Kernels" + +msg_info "Updating GRUB" +/usr/sbin/update-grub >/dev/null 2>&1 +msg_ok "Successfully Updated GRUB" +msg_info "Exiting" +sleep 2 +msg_ok "Finished" diff --git a/misc/kernel-pin.sh b/misc/kernel-pin.sh new file mode 100644 index 00000000..a2a15ede --- /dev/null +++ b/misc/kernel-pin.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + __ __ __ ____ _ + / //_/__ _________ ___ / / / __ \(_)___ + / ,< / _ \/ ___/ __ \/ _ \/ / / /_/ / / __ \ + / /| / __/ / / / / / __/ / / ____/ / / / / +/_/ |_\___/_/ /_/ /_/\___/_/ /_/ /_/_/ /_/ + +EOF +} +YW=$(echo "\033[33m") +RD=$(echo "\033[01;31m") +GN=$(echo "\033[1;92m") +CL=$(echo "\033[m") +BFR="\\r\\033[K" +HOLD="-" +CM="${GN}✓${CL}" +current_kernel=$(uname -r) +available_kernels=$(dpkg --list | grep 'kernel-.*-pve' | awk '{print substr($2, 16, length($2)-22)}') +header_info + +function msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." +} + +function msg_ok() { + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" +} + +whiptail --backtitle "Proxmox VE Helper Scripts" --title "Proxmox VE Kernel Pin" --yesno "This will Pin/Unpin Kernel Images, Proceed?" 10 68 || exit + + KERNEL_MENU=() + MSG_MAX_LENGTH=0 +while read -r TAG ITEM; do + OFFSET=2 + ((${#ITEM} + OFFSET > MSG_MAX_LENGTH)) && MSG_MAX_LENGTH=${#ITEM}+OFFSET + KERNEL_MENU+=("$TAG" "$ITEM " "OFF") +done < <(echo "$available_kernels") + +pin_kernel=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Current Kernel $current_kernel" --radiolist "\nSelect Kernel to pin:\nCancel to Unpin any Kernel" 16 $((MSG_MAX_LENGTH + 58)) 6 "${KERNEL_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"') || exit +[ -z "$pin_kernel" ] && { + whiptail --backtitle "Proxmox VE Helper Scripts" --title "No Kernel Selected" --msgbox "It appears that no Kernel was selected\nUnpinning any pinned Kernel" 10 68 + msg_info "Unpinning any Kernel" + proxmox-boot-tool kernel unpin &>/dev/null + msg_ok "Unpinned any Kernel\n" + proxmox-boot-tool kernel list + echo "" + msg_ok "Finished\n" + echo -e "${RD} REBOOT${CL}" + exit +} +whiptail --backtitle "Proxmox VE Helper Scripts" --title "Proxmox VE Kernel Pin" --yesno "Would you like to pin the $pin_kernel Kernel?" 10 68 || exit + +msg_info "Pinning $pin_kernel" +proxmox-boot-tool kernel pin $pin_kernel &>/dev/null +msg_ok "Successfully Pinned $pin_kernel\n" +proxmox-boot-tool kernel list +echo "" +msg_ok "Finished\n" +echo -e "${RD} REBOOT${CL}" diff --git a/misc/latest-update-menu.sh b/misc/latest-update-menu.sh deleted file mode 100644 index 2d23b5f7..00000000 --- a/misc/latest-update-menu.sh +++ /dev/null @@ -1,209 +0,0 @@ -#!/usr/bin/env bash - -while true; do - read -p "This will create a New Update Menu for Home Assistant Container LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -set -o errexit -rm -rf /root/update.sh update update-containers.sh -echo -e "\e[1;92m Creating New Update Menu Script... \e[0m" -if [ -f /usr/local/lib/python3.9/dist-packages/runlike/runlike.py ]; then -echo -e "\e[1;92m pip3/runlike Already Installed! \e[0m" -else -apt-get update &>/dev/null -echo -e "\e[1;92m Installing pip3... \e[0m" -apt-get install -y python3-pip &>/dev/null -echo -e "\e[1;92m Installing runlike... \e[0m" -pip3 install runlike &>/dev/null -fi -echo -e "\e[1;92m Creating Update Script... \e[0m" -if [ -d /root/hass_config ]; then -echo -e "\e[1;92m There's Already (hass_config) Folder! \e[0m" -else -mkdir /root/hass_config -fi -UPDATE_PATH='/root/update' -UPDATE_CONTAINERS_PATH='/root/update-containers.sh' -cat >$UPDATE_PATH <<'EOF' -#!/bin/sh -set -o errexit -show_menu(){ - normal=`echo "\033[m"` - safe=`echo "\033[32m"` - menu=`echo "\033[36m"` - number=`echo "\033[33m"` - bgred=`echo "\033[41m"` - fgred=`echo "\033[31m"` - hostname -I - printf "\n${menu}*********************************************${normal}\n" - printf "${menu}**${number} 1)${safe} Switch to Stable Branch ${normal}\n" - printf "${menu}**${number} 2)${number} Switch to Beta Branch ${normal}\n" - printf "${menu}**${number} 3)${fgred} Switch to Dev Branch ${normal}\n" - printf "${menu}**${number} 4)${safe} Backup Home Assistant Data (to root) ${normal}\n" - printf "${menu}**${number} 5)${number} Restore Home Assistant Data ${normal}\n" - printf "${menu}**${number} 6)${fgred} Edit Home Assistant Configuration ${normal}\n" - printf "${menu}**${number} 7)${safe} Restart Home Assistant ${normal}\n" - printf "${menu}**${number} 8)${safe} Just Update Containers ${normal}\n" - printf "${menu}**${number} 9)${number} Remove Unused Images ${normal}\n" - printf "${menu}**${number} 10)${safe} Update Host OS ${normal}\n" - printf "${menu}**${number} 11)${safe} Reboot Host OS ${normal}\n" - printf "${menu}*********************************************${normal}\n" - printf "Please choose an option from the menu and enter or ${fgred}x to exit. ${normal}" - read opt -} -option_picked(){ - msgcolor=`echo "\033[01;31m"` - normal=`echo "\033[00;00m"` - message=${@:-"${normal}Error: No message passed"} - printf "${msgcolor}${message}${normal}\n" -} -clear -show_menu -while [ $opt != '' ] - do - if [ $opt = '' ]; then - exit; - else - case $opt in - 1) clear; - option_picked "Switching to Stable Branch"; - TAG=stable - break; - ;; - 2) clear; - option_picked "Switching to Beta Branch"; - TAG=beta - break; - ;; - 3) while true; do - read -p "Are you sure you want to Switch to Dev Branch? Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac - done - clear; - option_picked "Switching to Dev Branch"; - TAG=dev - break; - ;; - 4) clear; - option_picked "Backing up Home Assistant Data to root (hass_config)"; - rm -r hass_config; - cp -pR /var/lib/docker/volumes/hass_config/ /root/; - sleep 2; - clear; - show_menu; - ;; - 5) while true; do - read -p "Are you sure you want to Restore Home Assistant Data? Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac - done - clear; - option_picked "Restoring Home Assistant Data from root (hass_config)"; - rm -r /var/lib/docker/volumes/hass_config/_data; - cp -pR /root/hass_config/_data /var/lib/docker/volumes/hass_config/; - sleep 2; - clear; - show_menu; - ;; - 6) while true; do - read -p "Are you sure you want to Edit Home Assistant Configuration? Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac - done - clear; - option_picked "Editing Home Assistant Configuration"; - nano /var/lib/docker/volumes/hass_config/_data/configuration.yaml; - clear; - show_menu; - ;; - 7) clear; - option_picked "Restarting Home Assistant"; - docker restart homeassistant; - exit; - ;; - 8) clear; - option_picked "Just Updating Containers"; - ./update-containers.sh; - sleep 2; - clear; - show_menu; - ;; - 9) clear; - option_picked "Removing Unused Images"; - docker image prune -af; - sleep 2; - clear; - show_menu; - ;; - 10) clear; - option_picked "Updating Host OS"; - apt update && apt upgrade -y; - sleep 2; - clear; - show_menu; - ;; - 11) clear; - option_picked "Reboot Host OS"; - reboot; - exit; - ;; - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose an option from the menu"; - show_menu; - ;; - esac - fi - done -docker pull homeassistant/home-assistant:$TAG -docker rm --force homeassistant -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 \ - -v /etc/timezone:/etc/timezone:ro \ - --net=host \ - homeassistant/home-assistant:$TAG -EOF -sudo chmod +x /root/update -cat >$UPDATE_CONTAINERS_PATH <<'EOF' -#!/bin/bash -set -o errexit -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 -EOF -sudo chmod +x /root/update-containers.sh -echo -e "\e[1;92m Finished. Type ./update in the LXC console\e[0m" diff --git a/misc/microcode.sh b/misc/microcode.sh new file mode 100644 index 00000000..44ad9b54 --- /dev/null +++ b/misc/microcode.sh @@ -0,0 +1,125 @@ +#!/usr/bin/env bash +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + ____ __ ____ __ + / __ \_________ ________ ______________ _____ / |/ (_)_____________ _________ ____/ /__ + / /_/ / ___/ __ \/ ___/ _ \/ ___/ ___/ __ \/ ___/ / /|_/ / / ___/ ___/ __ \/ ___/ __ \/ __ / _ \ + / ____/ / / /_/ / /__/ __(__ |__ ) /_/ / / / / / / / /__/ / / /_/ / /__/ /_/ / /_/ / __/ +/_/ /_/ \____/\___/\___/____/____/\____/_/ /_/ /_/_/\___/_/ \____/\___/\____/\__,_/\___/ + +EOF +} + +RD=$(echo "\033[01;31m") +YW=$(echo "\033[33m") +GN=$(echo "\033[1;92m") +CL=$(echo "\033[m") +BFR="\\r\\033[K" +HOLD="-" +CM="${GN}✓${CL}" +CROSS="${RD}✗${CL}" + +msg_info() { echo -ne " ${HOLD} ${YW}$1..."; } +msg_ok() { echo -e "${BFR} ${CM} ${GN}$1${CL}"; } +msg_error() { echo -e "${BFR} ${CROSS} ${RD}$1${CL}"; } + +header_info +current_microcode=$(journalctl -k | grep -i 'microcode: Current revision:' | grep -oP 'Current revision: \K0x[0-9a-f]+') +[ -z "$current_microcode" ] && current_microcode="Not found." + +intel() { + if ! dpkg -s iucode-tool >/dev/null 2>&1; then + msg_info "Installing iucode-tool (Intel microcode updater)" + apt-get install -y iucode-tool &>/dev/null + msg_ok "Installed iucode-tool" + else + msg_ok "Intel iucode-tool is already installed" + sleep 1 + fi + + intel_microcode=$(curl -fsSL "https://ftp.debian.org/debian/pool/non-free-firmware/i/intel-microcode//" | grep -o 'href="[^"]*amd64.deb"' | sed 's/href="//;s/"//') + [ -z "$intel_microcode" ] && { whiptail --backtitle "Proxmox VE Helper Scripts" --title "No Microcode Found" --msgbox "It appears there were no microcode packages found\n Try again later." 10 68; msg_info "Exiting"; sleep 1; msg_ok "Done"; exit; } + + MICROCODE_MENU=() + MSG_MAX_LENGTH=0 + + while read -r TAG ITEM; do + OFFSET=2 + (( ${#ITEM} + OFFSET > MSG_MAX_LENGTH )) && MSG_MAX_LENGTH=${#ITEM}+OFFSET + MICROCODE_MENU+=("$TAG" "$ITEM " "OFF") + done < <(echo "$intel_microcode") + + microcode=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Current Microcode revision:${current_microcode}" --radiolist "\nSelect a microcode package to install:\n" 16 $((MSG_MAX_LENGTH + 58)) 6 "${MICROCODE_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"') || exit + + [ -z "$microcode" ] && { whiptail --backtitle "Proxmox VE Helper Scripts" --title "No Microcode Selected" --msgbox "It appears that no microcode packages were selected" 10 68; msg_info "Exiting"; sleep 1; msg_ok "Done"; exit; } + + msg_info "Downloading the Intel Processor Microcode Package $microcode" + wget -q http://ftp.debian.org/debian/pool/non-free-firmware/i/intel-microcode/$microcode + msg_ok "Downloaded the Intel Processor Microcode Package $microcode" + + msg_info "Installing $microcode (Patience)" + dpkg -i $microcode &>/dev/null + msg_ok "Installed $microcode" + + msg_info "Cleaning up" + rm $microcode + msg_ok "Cleaned" + echo -e "\nIn order to apply the changes, a system reboot will be necessary.\n" +} + +amd() { + amd_microcode=$(curl -fsSL "https://ftp.debian.org/debian/pool/non-free-firmware/a/amd64-microcode///" | grep -o 'href="[^"]*amd64.deb"' | sed 's/href="//;s/"//') + + [ -z "$amd_microcode" ] && { whiptail --backtitle "Proxmox VE Helper Scripts" --title "No Microcode Found" --msgbox "It appears there were no microcode packages found\n Try again later." 10 68; msg_info "Exiting"; sleep 1; msg_ok "Done"; exit; } + + MICROCODE_MENU=() + MSG_MAX_LENGTH=0 + + while read -r TAG ITEM; do + OFFSET=2 + (( ${#ITEM} + OFFSET > MSG_MAX_LENGTH )) && MSG_MAX_LENGTH=${#ITEM}+OFFSET + MICROCODE_MENU+=("$TAG" "$ITEM " "OFF") + done < <(echo "$amd_microcode") + + microcode=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Current Microcode revision:${current_microcode}" --radiolist "\nSelect a microcode package to install:\n" 16 $((MSG_MAX_LENGTH + 58)) 6 "${MICROCODE_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"') || exit + + [ -z "$microcode" ] && { whiptail --backtitle "Proxmox VE Helper Scripts" --title "No Microcode Selected" --msgbox "It appears that no microcode packages were selected" 10 68; msg_info "Exiting"; sleep 1; msg_ok "Done"; exit; } + + msg_info "Downloading the AMD Processor Microcode Package $microcode" + wget -q https://ftp.debian.org/debian/pool/non-free-firmware/a/amd64-microcode/$microcode + msg_ok "Downloaded the AMD Processor Microcode Package $microcode" + + msg_info "Installing $microcode (Patience)" + dpkg -i $microcode &>/dev/null + msg_ok "Installed $microcode" + + msg_info "Cleaning up" + rm $microcode + msg_ok "Cleaned" + echo -e "\nIn order to apply the changes, a system reboot will be necessary.\n" +} + +if ! command -v pveversion >/dev/null 2>&1; then header_info; msg_error "No PVE Detected!"; exit; fi + +whiptail --backtitle "Proxmox VE Helper Scripts" --title "Proxmox VE Processor Microcode" --yesno "This will check for CPU microcode packages with the option to install. Proceed?" 10 58 || exit + +msg_info "Checking CPU Vendor" +cpu=$(lscpu | grep -oP 'Vendor ID:\s*\K\S+' | head -n 1) +if [ "$cpu" == "GenuineIntel" ]; then + msg_ok "${cpu} was detected" + sleep 1 + intel +elif [ "$cpu" == "AuthenticAMD" ]; then + msg_ok "${cpu} was detected" + sleep 1 + amd +else + msg_error "${cpu} is not supported" + exit +fi diff --git a/misc/monitor-all.sh b/misc/monitor-all.sh new file mode 100644 index 00000000..79bf0df0 --- /dev/null +++ b/misc/monitor-all.sh @@ -0,0 +1,163 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +clear +cat <<"EOF" + __ ___ _ __ ___ ____ + / |/ /___ ____ (_) /_____ _____ / | / / / + / /|_/ / __ \/ __ \/ / __/ __ \/ ___/ / /| | / / / + / / / / /_/ / / / / / /_/ /_/ / / / ___ |/ / / +/_/ /_/\____/_/ /_/_/\__/\____/_/ /_/ |_/_/_/ + +EOF + +add() { +while true; do + read -p "This script will add Monitor All to Proxmox VE. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac +done + +echo '#!/usr/bin/env bash +# Read excluded instances from command line arguments +excluded_instances=("$@") +echo "Excluded instances: ${excluded_instances[@]}" + +while true; do + + for instance in $(pct list | awk '\''{if(NR>1) print $1}'\''; qm list | awk '\''{if(NR>1) print $1}'\''); do + # Skip excluded instances + if [[ " ${excluded_instances[@]} " =~ " ${instance} " ]]; then + echo "Skipping $instance because it is excluded" + continue + fi + + # Determine the type of the instance (container or virtual machine) + if pct status $instance >/dev/null 2>&1; then + # It is a container + config_cmd="pct config" + IP=$(pct exec $instance ip a s dev eth0 | awk '\''/inet / {print $2}'\'' | cut -d/ -f1) + else + # It is a virtual machine + config_cmd="qm config" + IP=$(qm guest cmd $instance network-get-interfaces | egrep -o "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -E "192\.|10\." | head -n 1) + fi + + # Skip instances based on onboot and templates + onboot=$($config_cmd $instance | grep -q "onboot: 0" || ( ! $config_cmd $instance | grep -q "onboot" ) && echo "true" || echo "false") + template=$($config_cmd $instance | grep template | grep -q "template:" && echo "true" || echo "false") + + if [ "$onboot" == "true" ]; then + echo "Skipping $instance because it is set not to boot" + continue + elif [ "$template" == "true" ]; then + echo "Skipping $instance because it is a template" + continue + fi + + # Ping the instance + if ! ping -c 1 $IP >/dev/null 2>&1; then + # If the instance can not be pinged, stop and start it + if pct status $instance >/dev/null 2>&1; then + # It is a container + echo "$(date): CT $instance is not responding, restarting..." + pct stop $instance >/dev/null 2>&1 + sleep 5 + pct start $instance >/dev/null 2>&1 + else + # It is a virtual machine + if qm status $instance | grep -q "status: running"; then + echo "$(date): VM $instance is not responding, restarting..." + qm stop $instance >/dev/null 2>&1 + sleep 5 + else + echo "$(date): VM $instance is not running, starting..." + fi + qm start $instance >/dev/null 2>&1 + fi + fi + done + + # Wait for 5 minutes. (Edit to your needs) + echo "$(date): Pausing for 5 minutes..." + sleep 300 +done >/var/log/ping-instances.log 2>&1' >/usr/local/bin/ping-instances.sh +touch /var/log/ping-instances.log +# Change file permissions to executable +chmod +x /usr/local/bin/ping-instances.sh +cat <<EOF >/etc/systemd/system/ping-instances.timer +[Unit] +Description=Delay ping-instances.service by 5 minutes + +[Timer] +OnBootSec=300 +OnUnitActiveSec=300 + +[Install] +WantedBy=timers.target +EOF + +# Create ping-instances.service +cat <<EOF >/etc/systemd/system/ping-instances.service +[Unit] +Description=Ping instances every 5 minutes and restarts if necessary +After=ping-instances.timer +Requires=ping-instances.timer +[Service] +Type=simple +# To specify which CT/VM should be excluded, add the CT/VM ID at the end of the line where ExecStart=/usr/local/bin/ping-instances.sh is specified. +# For example: ExecStart=/usr/local/bin/ping-instances.sh 100 102 +# Virtual machines without the QEMU guest agent installed must be excluded. + +ExecStart=/usr/local/bin/ping-instances.sh +Restart=always +StandardOutput=file:/var/log/ping-instances.log +StandardError=file:/var/log/ping-instances.log + +[Install] +WantedBy=multi-user.target +EOF + +# Reload daemon, enable and start ping-instances.service +systemctl daemon-reload +systemctl enable -q --now ping-instances.timer +systemctl enable -q --now ping-instances.service +clear +echo -e "\n To view Monitor All logs: cat /var/log/ping-instances.log" +} + +remove() { + systemctl disable -q --now ping-instances.timer + systemctl disable -q --now ping-instances.service + rm /etc/systemd/system/ping-instances.service /etc/systemd/system/ping-instances.timer /usr/local/bin/ping-instances.sh /var/log/ping-instances.log + echo "Removed Monitor All from Proxmox VE" +} + +# Define options for the whiptail menu +OPTIONS=(Add "Add Monitor-All to Proxmox VE" \ + Remove "Remove Monitor-All from Proxmox VE") + +# Show the whiptail menu and save the user's choice +CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Monitor-All for Proxmox VE" --menu "Select an option:" 10 58 2 \ + "${OPTIONS[@]}" 3>&1 1>&2 2>&3) + +# Check the user's choice and perform the corresponding action +case $CHOICE in + "Add") + add + ;; + "Remove") + remove + ;; + *) + echo "Exiting..." + exit 0 + ;; +esac diff --git a/misc/netdata.sh b/misc/netdata.sh new file mode 100644 index 00000000..885cd42d --- /dev/null +++ b/misc/netdata.sh @@ -0,0 +1,122 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + _ __ __ ____ __ + / | / /__ / /_/ __ \____ _/ /_____ _ + / |/ / _ \/ __/ / / / __ `/ __/ __ `/ + / /| / __/ /_/ /_/ / /_/ / /_/ /_/ / +/_/ |_/\___/\__/_____/\__,_/\__/\__,_/ + +EOF +} + +YW=$(echo "\033[33m") +BL=$(echo "\033[36m") +RD=$(echo "\033[01;31m") +GN=$(echo "\033[1;92m") +CL=$(echo "\033[m") +BFR="\\r\\033[K" +HOLD="-" +CM="${GN}✓${CL}" +silent() { "$@" >/dev/null 2>&1; } +set -e +header_info +echo "Loading..." +function msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." +} + +function msg_ok() { + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" +} + +install() { + header_info + while true; do + read -p "Are you sure you want to install NetData on Proxmox VE host. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac + done + header_info + read -r -p "Verbose mode? <y/N> " prompt + if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then + STD="" + else + STD="silent" + fi + header_info + + msg_info "Setting up repository" + wget -q https://repo.netdata.cloud/repos/repoconfig/debian/bookworm/netdata-repo_2-2+debian12_all.deb + $STD dpkg -i netdata-repo_2-2+debian12_all.deb + rm -rf netdata-repo_2-2+debian12_all.deb + msg_ok "Set up repository" + + msg_info "Installing Netdata" + $STD apt-get update + $STD apt-get install -y netdata + msg_ok "Installed Netdata" + msg_ok "Completed Successfully!\n" + echo -e "\n Netdata should be reachable at${BL} http://$(hostname -I | awk '{print $1}'):19999 ${CL}\n" +} + +uninstall() { + header_info + read -r -p "Verbose mode? <y/N> " prompt + if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then + STD="" + else + STD="silent" + fi + header_info + + msg_info "Uninstalling Netdata" + systemctl stop netdata + rm -rf /var/log/netdata /var/lib/netdata /var/cache/netdata /etc/netdata/go.d + rm -rf /etc/apt/trusted.gpg.d/netdata-archive-keyring.gpg /etc/apt/sources.list.d/netdata.list + $STD apt-get remove --purge -y netdata netdata-repo + systemctl daemon-reload + $STD apt autoremove -y + $STD userdel netdata + msg_ok "Uninstalled Netdata" + msg_ok "Completed Successfully!\n" +} + +if ! pveversion | grep -Eq "pve-manager/(8\.[0-9])"; then + echo -e "This version of Proxmox Virtual Environment is not supported" + echo -e "Requires PVE Version 8.0 or higher" + echo -e "Exiting..." + sleep 2 + exit +fi + +OPTIONS=(Install "Install NetData on Proxmox VE" \ + Uninstall "Uninstall NetData from Proxmox VE") + +CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "NetData" --menu "Select an option:" 10 58 2 \ + "${OPTIONS[@]}" 3>&1 1>&2 2>&3) + +case $CHOICE in + "Install") + install + ;; + "Uninstall") + uninstall + ;; + *) + echo "Exiting..." + exit 0 + ;; +esac diff --git a/misc/nocodb-update.sh b/misc/nocodb-update.sh deleted file mode 100644 index 9a4e0399..00000000 --- a/misc/nocodb-update.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env bash -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}" -APP="NocoDB" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -function error_exit() { - trap - ERR - local reason="Unknown failure occured." - local msg="${1:-$reason}" - local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" - echo -e "$flag $msg" 1>&2 - exit $EXIT -} - -while true; do - read -p "This will Update ${APP}. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${YW} - _ _ _____ ____ - | \ | | | __ \| _ \ - | \| | ___ v3___ ___ | | | | |_) | - | |/ _ \ / __/ _ \| | | | _ < - | |\ | (_) | (_| (_) | |__| | |_) | - |_| \_|\___/ \___\___/|_____/|____/ - UPDATE -${CL}" -} - -header_info - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -msg_info "Updating ${APP}" -cd /opt/nocodb -npm uninstall -s --save nocodb &>/dev/null -npm install -s --save nocodb &>/dev/null -msg_ok "Updated ${APP}" - -read -p "${APP} LXC needs to reboot to apply the update. Reboot now? " -n 1 -r -echo -if [[ $REPLY =~ ^[Yy]$ ]] -then - reboot=yes -else - reboot=no -fi - -if [ "$reboot" == "yes" ]; then -msg_info "Rebooting ${APP} LXC" -reboot -fi - -if [ "$reboot" == "no" ]; then -msg_ok "Finished Updating ${APP}. Reboot to apply the update." -fi diff --git a/misc/node-red-themes.sh b/misc/node-red-themes.sh deleted file mode 100644 index 5f8738b1..00000000 --- a/misc/node-red-themes.sh +++ /dev/null @@ -1,137 +0,0 @@ -#!/usr/bin/env bash -# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/node-red-themes.sh)" -set -o errexit -show_menu(){ - YW=`echo "\033[33m"` - RD=`echo "\033[01;31m"` - BL=`echo "\033[36m"` - CM='\xE2\x9C\x94\033' - GN=`echo "\033[1;92m"` - CL=`echo "\033[m"` -echo -e "${RD} Backup your Node-Red flows before running this script!!${CL} \n " -while true; do - read -p "This will Install Node-Red Themes. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -echo -e "${RD} Backup your Node-Red flows before installing any theme!!${CL} \n " - printf "\n${BL}*********************************************${CL}\n" - printf "${BL}**${YW} 1)${GN} Default Theme ${CL}\n" - printf "${BL}**${YW} 2)${GN} Dark Theme ${CL}\n" - printf "${BL}**${YW} 3)${GN} Dracula Theme ${CL}\n" - printf "${BL}**${YW} 4)${GN} Midnight-Red Theme ${CL}\n" - printf "${BL}**${YW} 5)${GN} Oled Theme ${CL}\n" - printf "${BL}**${YW} 6)${GN} Solarized-Dark Theme ${CL}\n" - printf "${BL}**${YW} 7)${GN} Solarized-Light Theme ${CL}\n" - printf "${BL}*********************************************${CL}\n" - printf "Please choose a theme from the menu and enter or ${RD}x to exit. ${CL}" - read opt -} - -option_picked(){ - msgcolor=`echo "\033[01;31m"` - normal=`echo "\033[00;00m"` - message=${@:-"${CL}Error: No message passed"} - printf "${RD}${message}${CL}\n" -} - -clear -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - option_picked "Installing Default Theme"; - THEME= - JS=// - break; - ;; - 2) clear; - option_picked "Installing Dark Theme"; - THEME=dark - break; - ;; - 3) clear; - option_picked "Installing Dracula Theme"; - THEME=dracula - break; - ;; - 4) clear; - option_picked "Installing Midnight-Red Theme"; - THEME=midnight-red - break; - ;; - 5) clear; - option_picked "Installing Oled Theme"; - THEME=oled - break; - ;; - 6) clear; - option_picked "Installing Solarized-Dark Theme"; - THEME=solarized-dark - break; - ;; - 7) clear; - option_picked "Installing Solarized-Light Theme"; - THEME=solarized-light - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a theme from the menu"; - show_menu; - ;; - esac - done -echo -en "${GN} Installing ${THEME} Theme... " -cd /root/.node-red -if [ "${THEME}" = "" ]; then - echo -e "${CM}${CL} \r" - else -npm install @node-red-contrib-themes/${THEME} &>/dev/null -echo -e "${CM}${CL} \r" -fi -echo -en "${GN} Writing Settings... " -cat <<EOF > /root/.node-red/settings.js -module.exports = { uiPort: process.env.PORT || 1880, - mqttReconnectTime: 15000, - serialReconnectTime: 15000, - debugMaxLength: 1000, - functionGlobalContext: { - }, - exportGlobalContextKeys: false, - - // Configure the logging output - logging: { - console: { - level: "info", - metrics: false, - audit: false - } - }, - - // Customising the editor - editorTheme: { - ${JS}theme: "${THEME}" - }, - projects: { - // To enable the Projects feature, set this value to true - enabled: false - } -} -EOF -echo -e "${CM}${CL} \r" - -echo -en "${GN} Restarting Node-Red... " -echo -e "${CM}${CL} \r" -node-red-restart -echo -en "${GN} Finished... ${CL} \n" -exit diff --git a/misc/npm_update.sh b/misc/npm_update.sh deleted file mode 100644 index 4289e892..00000000 --- a/misc/npm_update.sh +++ /dev/null @@ -1,177 +0,0 @@ -#!/usr/bin/env bash -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) }') \ - -RD=`echo "\033[01;31m"` -BL=`echo "\033[36m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` - -function update_info { -echo -e "${RD} - _ _ _____ __ __ - | \ | | | __ \ | \/ | - | \| | | |__) | | \ / | - | | | ___/ | |\/| | - | |\ | | | | | | | - |_| \_| |_| |_| |_| - UPDATE v${RELEASE} -${CL}" -} - -update_info - -while true; do - read -p "This will update Nginx Proxy Manager to v${RELEASE}. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -update_info -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap 'die "Script interrupted."' INT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -T="$(date +%M)" - -if [ -f /lib/systemd/system/npm.service ]; then -echo -en "${GN} Prep For Update... " -sleep 2 -echo -e "${CM}${CL} \r" -echo -en "${GN} Stopping Services... " - systemctl stop openresty - systemctl stop npm -echo -e "${CM}${CL} \r" - -echo -en "${GN} Cleaning Old Files... " - rm -rf /app \ - /var/www/html \ - /etc/nginx \ - /var/log/nginx \ - /var/lib/nginx \ - /var/cache/nginx &>/dev/null - echo -e "${CM}${CL} \r" - else - echo -en "${RD} No NPM to Update! ${CL}" - exit -fi - -echo -en "${GN} 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} -echo -e "${CM}${CL} \r" - -echo -en "${GN} 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 -echo -e "${CM}${CL} \r" - -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 - -echo -en "${GN} 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 -echo -e "${CM}${CL} \r" - -echo -en "${GN} 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 -echo -e "${CM}${CL} \r" - -echo -en "${GN} Starting Services... " -systemctl enable npm &>/dev/null -systemctl start openresty -systemctl start npm -echo -e "${CM}${CL} \r" -TS="$(($(date +%M)-T))" - -IP=$(hostname -I | cut -f1 -d ' ') -echo -e "${GN}Successfully Updated Nginx Proxy Manager to ${RD}${RELEASE}${CL} and it took ${RD}${TS} minutes.${CL} - NPM should be reachable at ${BL}http://${IP}:81 ${CL} - - " diff --git a/misc/olivetin.sh b/misc/olivetin.sh new file mode 100644 index 00000000..f3909ad9 --- /dev/null +++ b/misc/olivetin.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +cat <<"EOF" + ____ ___ _______ + / __ \/ (_) _____/_ __(_)___ + / / / / / / | / / _ \/ / / / __ \ +/ /_/ / / /| |/ / __/ / / / / / / +\____/_/_/ |___/\___/_/ /_/_/ /_/ + +EOF +} + +IP=$(hostname -I | awk '{print $1}') +YW=$(echo "\033[33m") +BL=$(echo "\033[36m") +GN=$(echo "\033[1;92m") +CL=$(echo "\033[m") +BFR="\\r\\033[K" +HOLD="-" +CM="${GN}✓${CL}" +APP="OliveTin" +hostname="$(hostname)" +set-e +header_info + +while true; do + read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac +done +header_info + +function msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." +} + +function msg_ok() { + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" +} + +msg_info "Installing ${APP}" +wget -q https://github.com/OliveTin/OliveTin/releases/latest/download/OliveTin_linux_amd64.deb +dpkg -i OliveTin_linux_amd64.deb &>/dev/null +systemctl enable --now OliveTin &>/dev/null +rm OliveTin_linux_amd64.deb +msg_ok "Installed ${APP} on $hostname" + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://$IP:1337${CL} \n" diff --git a/misc/pbs3-upgrade.sh b/misc/pbs3-upgrade.sh new file mode 100644 index 00000000..4565811e --- /dev/null +++ b/misc/pbs3-upgrade.sh @@ -0,0 +1,172 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +header_info() { + clear + cat <<"EOF" + ____ ____ __________ __ ______ __________ ___ ____ ______ + / __ \/ __ ) ___/__ / / / / / __ \/ ____/ __ \/ | / __ \/ ____/ + / /_/ / __ \__ \ /_ < / / / / /_/ / / __/ /_/ / /| | / / / / __/ + / ____/ /_/ /__/ /__/ / / /_/ / ____/ /_/ / _, _/ ___ |/ /_/ / /___ +/_/ /_____/____/____/ \____/_/ \____/_/ |_/_/ |_/_____/_____/ + +EOF +} + +RD=$(echo "\033[01;31m") +YW=$(echo "\033[33m") +GN=$(echo "\033[1;92m") +CL=$(echo "\033[m") +BFR="\\r\\033[K" +HOLD="-" +CM="${GN}✓${CL}" +CROSS="${RD}✗${CL}" + +set -euo pipefail +shopt -s inherit_errexit nullglob + +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}" +} + + +start_routines() { + header_info + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS 2 BACKUP" --menu "\nMake a backup of /etc/proxmox-backup to ensure that in the worst case, any relevant configuration can be recovered?" 14 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Backing up Proxmox Backup Server 2" + tar czf "pbs2-etc-backup-$(date -I).tar.gz" -C "/etc" "proxmox-backup" + msg_ok "Backed up Proxmox Backup Server 2" + ;; + no) + msg_error "Selected no to Backing up Proxmox Backup Server 2" + ;; + esac + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS 3 SOURCES" --menu "This will set the correct sources to update and install Proxmox Backup Server 3.\n \nChange to Proxmox Backup Server 3 sources?" 14 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Changing to Proxmox Backup Server 3 Sources" + cat <<EOF >/etc/apt/sources.list +deb http://deb.debian.org/debian bookworm main contrib +deb http://deb.debian.org/debian bookworm-updates main contrib +deb http://security.debian.org/debian-security bookworm-security main contrib +EOF + msg_ok "Changed to Proxmox Backup Server 3 Sources" + ;; + no) + msg_error "Selected no to Correcting Proxmox Backup Server 3 Sources" + ;; + esac + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS3-ENTERPRISE" --menu "The 'pbs-enterprise' repository is only available to users who have purchased a Proxmox VE subscription.\n \nDisable 'pbs-enterprise' repository?" 14 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Disabling 'pbs-enterprise' repository" + cat <<EOF >/etc/apt/sources.list.d/pbs-enterprise.list +# deb https://enterprise.proxmox.com/debian/pbs bookworm pbs-enterprise +EOF + msg_ok "Disabled 'pbs-enterprise' repository" + ;; + no) + msg_error "Selected no to Disabling 'pbs-enterprise' repository" + ;; + esac + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS3-NO-SUBSCRIPTION" --menu "The 'pbs-no-subscription' repository provides access to all of the open-source components of Proxmox Backup Server.\n \nEnable 'pbs-no-subscription' repository?" 14 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Enabling 'pbs-no-subscription' repository" + cat <<EOF >/etc/apt/sources.list.d/pbs-install-repo.list +deb http://download.proxmox.com/debian/pbs bookworm pbs-no-subscription +EOF + msg_ok "Enabled 'pbs-no-subscription' repository" + ;; + no) + msg_error "Selected no to Enabling 'pbs-no-subscription' repository" + ;; + esac + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS3 TEST" --menu "The 'pbstest' repository can give advanced users access to new features and updates before they are officially released.\n \nAdd (Disabled) 'pbstest' repository?" 14 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Adding 'pbstest' repository and set disabled" + cat <<EOF >/etc/apt/sources.list.d/pbstest-for-beta.list +# deb http://download.proxmox.com/debian/pbs bookworm pbstest +EOF + msg_ok "Added 'pbstest' repository" + ;; + no) + msg_error "Selected no to Adding 'pbstest' repository" + ;; + esac + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS 3 UPDATE" --menu "\nUpdate to Proxmox Backup Server 3 now?" 11 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Updating to Proxmox Backup Server 3 (Patience)" + apt-get update + DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" dist-upgrade -y + msg_ok "Updated to Proxmox Backup Server 3" + ;; + no) + msg_error "Selected no to Updating to Proxmox Backup Server 3" + ;; + esac + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "REBOOT" --menu "\nReboot Proxmox Backup Server 3 now? (recommended)" 11 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Rebooting Proxmox Backup Server 3" + sleep 2 + msg_ok "Completed Install Routines" + reboot + ;; + no) + msg_error "Selected no to Rebooting Proxmox Backup Server 3 (Reboot recommended)" + msg_ok "Completed Install Routines" + ;; + esac +} + +header_info +while true; do + read -p "Start the Update to Proxmox Backup Server 3 Script (y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) clear; exit ;; + *) echo "Please answer yes or no." ;; + esac +done + +start_routines diff --git a/misc/photoprism-update.sh b/misc/photoprism-update.sh deleted file mode 100644 index 7ab7f8f6..00000000 --- a/misc/photoprism-update.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env bash -set -e -RELEASE=$(curl -s https://api.github.com/repos/photoprism/photoprism/releases/latest \ -| grep "tag_name" \ -| awk '{print substr($2, 2, length($2)-4) }') \ - -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -PP=`echo "\e[1;35m"` - -while true; do - read -p "Update PhotoPrism LXC. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${PP} - _____ _ _ _____ _ - | __ \| | | | | __ \ (_) - | |__) | |__ ___ | |_ ___ | |__) | __ _ ___ _ __ ___ - | ___/| _ \ / _ \| __/ _ \| ___/ __| / __| _ _ \ - | | | | | | (_) | || (_) | | | | | \__ \ | | | | | - |_| |_| |_|\___/ \__\___/|_| |_| |_|___/_| |_| |_| - ${RD} UPDATE -${CL}" -} - -header_info -show_menu(){ - printf " ${YW} 1)${GN} Release Branch ${CL}\n" - printf " ${YW} 2)${YW} Develop Branch ${CL}\n" - - printf "Please choose a Install Branch and hit enter or ${RD}x${CL} to exit." - read opt -} - -option_picked(){ - message1=${@:-"${CL}Error: No message passed"} - printf " ${YW}${message1}${CL}\n" -} -show_menu -while [ "$opt" != " " ] - do - case $opt in - 1) clear; - header_info; - option_picked "Using Release Branch"; - BR="release" - break; - ;; - 2) clear; - header_info; - option_picked "Using Develop Branch"; - BR="develop" - break; - ;; - - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose a Install Branch from the menu"; - show_menu; - ;; - esac - done - -echo -en "${GN} Stopping PhotoPrism... " -sudo systemctl stop photoprism -echo -e "${CM}${CL} \r" - -echo -en "${GN} Cloning PhotoPrism ${BR} branch... " -git clone https://github.com/photoprism/photoprism.git &>/dev/null -cd photoprism -git checkout ${BR} &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Building PhotoPrism ${BR} branch... " -sudo make all &>/dev/null -sudo ./scripts/build.sh prod /opt/photoprism/bin/photoprism &>/dev/null -sudo cp -a assets/ /opt/photoprism/assets/ &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Cleaning... " -cd ~ -rm -rf photoprism -echo -e "${CM}${CL} \r" - -echo -en "${GN} Starting PhotoPrism... " -sudo systemctl start photoprism -echo -e "${CM}${CL} \n" - -echo -e "${GN} Finished ${CL} \n " - - diff --git a/misc/podman.md b/misc/podman.md deleted file mode 100644 index 34b45371..00000000 --- a/misc/podman.md +++ /dev/null @@ -1,11 +0,0 @@ -<p align="center"><img src="https://podman.io/images/podman.svg" /></p> - -Podman is a daemonless container engine for developing, managing, and running OCI Containers on your Linux System. Similar to Docker, Podman is an open source project. Anybody can check out the source code for the program. Contrary to Docker, Podman does not require a daemon process to launch and manage containers. This is an important difference between the two projects. - -Podman seeks to improve on some of Docker’s drawbacks. For one, Podman does not require a daemon running as root. In fact, Podman containers run with the same permissions as the user who launched them. This addresses a significant security concern, although you can still run containers with root permissions if you really want to. - -Podman seeks to be a drop-in replacement for Docker as far as the CLI is concerned. The developers boast that most users can simply use alias docker=podman and continue running the same familiar commands. The container image format is also fully compatible between Docker and Podman, so existing containers built on Dockerfiles will work with Podman. - -Another key difference is that, it handles running containers, but not building them (non-monolithic). The goal here is to have a set of container standards that any application can be developed to support, rather than relying on a single monolithic application such as Docker to perform all duties. - -https://www.liquidweb.com/kb/podman-vs-docker/ ___ https://github.com/containers/podman-compose ___ https://podman.io/ diff --git a/misc/podman_hacs.sh b/misc/podman_hacs.sh deleted file mode 100644 index d85ad7da..00000000 --- a/misc/podman_hacs.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -echo -e "\e[1;33m This script will install Home Assistant Community Store (HACS) \e[0m" - -while true; do - read -p "Start the HACS Install Script (y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done - -apt update &>/dev/null -apt install unzip &>/dev/null -cd /var/lib/containers/storage/volumes/hass_config/_data -wget -O - https://get.hacs.xyz | bash - - -# To install HACS run the following from the container (LXC) console -# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/podman_hacs.sh)" -# Then add the integration in HA diff --git a/misc/post-install-v3.sh b/misc/post-install-v3.sh deleted file mode 100644 index effa399d..00000000 --- a/misc/post-install-v3.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env bash -ex -set -euo pipefail -shopt -s inherit_errexit nullglob -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}" - -echo -e "\e[1;33m This script will Perform Post Install Routines. PVE7 ONLY \e[0m" -while true; do - read -p "Start the PVE7 Post Install Script (y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -if [ `pveversion | grep "pve-manager/7" | wc -l` -ne 1 ]; then - echo -e "This script requires Proxmox Virtual Environment 7.0 or greater" - echo -e "Exiting..." - sleep 2 - exit -fi -function header_info { -echo -e "${RD} - _______ ________ ______ _____ _ _____ _ _ _ - | __ \ \ / / ____|____ | | __ \ | | |_ _| | | | | | - | |__) \ \ / /| |__ / / | |__) |__ ___| |_ | | _ __ ___| |_ __ _| | | - | ___/ \ \/ / | __| v3 / / | ___/ _ \/ __| __| | | | _ \/ __| __/ _ | | | - | | \ / | |____ / / | | | (_) \__ \ |_ _| |_| | | \__ \ || (_| | | | - |_| \/ |______|/_/ |_| \___/|___/\__| |_____|_| |_|___/\__\__,_|_|_| -${CL}" -} - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - -clear -header_info -read -r -p "Disable Enterprise Repository? <y/n> " prompt -if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] -then -msg_info "Disabling Enterprise Repository" -sleep 2 -sed -i "s/^deb/#deb/g" /etc/apt/sources.list.d/pve-enterprise.list -msg_ok "Disabled Enterprise Repository" -fi - -read -r -p "Add/Correct PVE7 Sources (sources.list)? <y/n> " prompt -if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] -then -msg_info "Adding or Correcting PVE7 Sources" -cat <<EOF > /etc/apt/sources.list -deb http://ftp.debian.org/debian bullseye main contrib -deb http://ftp.debian.org/debian bullseye-updates main contrib -deb http://security.debian.org/debian-security bullseye-security main contrib -EOF -sleep 2 -msg_ok "Added or Corrected PVE7 Sources" -fi - -read -r -p "Enable No-Subscription Repository? <y/n> " prompt -if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] -then -msg_info "Enabling No-Subscription Repository" -cat <<EOF >> /etc/apt/sources.list -deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription -EOF -sleep 2 -msg_ok "Enabled No-Subscription Repository" -fi - -read -r -p "Add (Disabled) Beta/Test Repository? <y/n> " prompt -if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] -then -msg_info "Adding Beta/Test Repository and set disabled" -cat <<EOF >> /etc/apt/sources.list -# deb http://download.proxmox.com/debian/pve bullseye pvetest -EOF -sleep 2 -msg_ok "Added Beta/Test Repository" -fi - -read -r -p "Disable Subscription Nag? <y/n> " prompt -if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] -then -msg_info "Disabling Subscription Nag" -echo "DPkg::Post-Invoke { \"dpkg -V proxmox-widget-toolkit | grep -q '/proxmoxlib\.js$'; if [ \$? -eq 1 ]; then { echo 'Removing subscription nag from UI...'; sed -i '/data.status/{s/\!//;s/Active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; }; fi\"; };" > /etc/apt/apt.conf.d/no-nag-script -apt --reinstall install proxmox-widget-toolkit &>/dev/null -msg_ok "Disabled Subscription Nag" -fi - -read -r -p "Update Proxmox VE 7 now? <y/n> " prompt -if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] -then -msg_info "Updating Proxmox VE 7" -apt-get update &>/dev/null -apt-get -y dist-upgrade &>/dev/null -msg_ok "Updated Proxmox VE 7" -fi - -sleep 2 -msg_ok "Finished Post Install Routines" diff --git a/misc/post-pbs-install.sh b/misc/post-pbs-install.sh new file mode 100644 index 00000000..550626be --- /dev/null +++ b/misc/post-pbs-install.sh @@ -0,0 +1,184 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +header_info() { + clear + cat <<"EOF" + ____ ____ _____ ____ __ ____ __ ____ + / __ \/ __ ) ___/ / __ \____ _____/ /_ / _/___ _____/ /_____ _/ / / + / /_/ / __ \__ \ / /_/ / __ \/ ___/ __/ / // __ \/ ___/ __/ __ `/ / / + / ____/ /_/ /__/ / / ____/ /_/ (__ ) /_ _/ // / / (__ ) /_/ /_/ / / / +/_/ /_____/____/ /_/ \____/____/\__/ /___/_/ /_/____/\__/\__,_/_/_/ + +EOF +} + +RD=$(echo "\033[01;31m") +YW=$(echo "\033[33m") +GN=$(echo "\033[1;92m") +CL=$(echo "\033[m") +BFR="\\r\\033[K" +HOLD="-" +CM="${GN}✓${CL}" +CROSS="${RD}✗${CL}" + +set -euo pipefail +shopt -s inherit_errexit nullglob + +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}" +} + + +start_routines() { + header_info + VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)" + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS SOURCES" --menu "This will set the correct sources to update and install Proxmox Backup Server.\n \nChange to Proxmox Backup Server sources?" 14 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Changing to Proxmox Backup Server Sources" + cat <<EOF >/etc/apt/sources.list +deb http://deb.debian.org/debian ${VERSION} main contrib +deb http://deb.debian.org/debian ${VERSION}-updates main contrib +deb http://security.debian.org/debian-security ${VERSION}-security main contrib +EOF + msg_ok "Changed to Proxmox Backup Server Sources" + ;; + no) + msg_error "Selected no to Correcting Proxmox Backup Server Sources" + ;; + esac + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS-ENTERPRISE" --menu "The 'pbs-enterprise' repository is only available to users who have purchased a Proxmox VE subscription.\n \nDisable 'pbs-enterprise' repository?" 14 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Disabling 'pbs-enterprise' repository" + cat <<EOF >/etc/apt/sources.list.d/pbs-enterprise.list +# deb https://enterprise.proxmox.com/debian/pbs ${VERSION} pbs-enterprise +EOF + msg_ok "Disabled 'pbs-enterprise' repository" + ;; + no) + msg_error "Selected no to Disabling 'pbs-enterprise' repository" + ;; + esac + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS-NO-SUBSCRIPTION" --menu "The 'pbs-no-subscription' repository provides access to all of the open-source components of Proxmox Backup Server.\n \nEnable 'pbs-no-subscription' repository?" 14 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Enabling 'pbs-no-subscription' repository" + cat <<EOF >/etc/apt/sources.list.d/pbs-install-repo.list +deb http://download.proxmox.com/debian/pbs ${VERSION} pbs-no-subscription +EOF + msg_ok "Enabled 'pbs-no-subscription' repository" + ;; + no) + msg_error "Selected no to Enabling 'pbs-no-subscription' repository" + ;; + esac + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS TEST" --menu "The 'pbstest' repository can give advanced users access to new features and updates before they are officially released.\n \nAdd (Disabled) 'pbstest' repository?" 14 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Adding 'pbstest' repository and set disabled" + cat <<EOF >/etc/apt/sources.list.d/pbstest-for-beta.list +# deb http://download.proxmox.com/debian/pbs ${VERSION} pbstest +EOF + msg_ok "Added 'pbstest' repository" + ;; + no) + msg_error "Selected no to Adding 'pbstest' repository" + ;; + esac + + if [[ ! -f /etc/apt/apt.conf.d/no-nag-script ]]; then + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUBSCRIPTION NAG" --menu "This will disable the nag message reminding you to purchase a subscription every time you log in to the web interface.\n \nDisable subscription nag?" 14 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "Support Subscriptions" "Supporting the software's development team is essential. Check their official website's Support Subscriptions for pricing. Without their dedicated work, we wouldn't have this exceptional software." 10 58 + msg_info "Disabling subscription nag" + echo "DPkg::Post-Invoke { \"dpkg -V proxmox-widget-toolkit | grep -q '/proxmoxlib\.js$'; if [ \$? -eq 1 ]; then { echo 'Removing subscription nag from UI...'; sed -i '/data\.status.*{/{s/\!//;s/active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; }; fi\"; };" >/etc/apt/apt.conf.d/no-nag-script + apt --reinstall install proxmox-widget-toolkit &>/dev/null + msg_ok "Disabled subscription nag (Delete browser cache)" + ;; + no) + whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "Support Subscriptions" "Supporting the software's development team is essential. Check their official website's Support Subscriptions for pricing. Without their dedicated work, we wouldn't have this exceptional software." 10 58 + msg_error "Selected no to Disabling subscription nag" + ;; + esac + fi + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UPDATE" --menu "\nUpdate Proxmox Backup Server now?" 11 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Updating Proxmox Backup Server (Patience)" + apt-get update &>/dev/null + apt-get -y dist-upgrade &>/dev/null + msg_ok "Updated Proxmox Backup Server" + ;; + no) + msg_error "Selected no to Updating Proxmox Backup Server" + ;; + esac + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "REBOOT" --menu "\nReboot Proxmox Backup Server now? (recommended)" 11 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Rebooting Proxmox Backup Server" + sleep 2 + msg_ok "Completed Post Install Routines" + reboot + ;; + no) + msg_error "Selected no to Rebooting Proxmox Backup Server (Reboot recommended)" + msg_ok "Completed Post Install Routines" + ;; + esac +} + +header_info +echo -e "\nThis script will Perform Post Install Routines.\n" +while true; do + read -p "Start the Proxmox Backup Server Post Install Script (y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) clear; exit ;; + *) echo "Please answer yes or no." ;; + esac +done + +if command -v pveversion >/dev/null 2>&1; then + echo -e "\n🛑 PVE Detected, Wrong Script!\n" + exit 1 +fi + +start_routines diff --git a/misc/post-pve-install.sh b/misc/post-pve-install.sh new file mode 100644 index 00000000..f142b850 --- /dev/null +++ b/misc/post-pve-install.sh @@ -0,0 +1,242 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +header_info() { + clear + cat <<"EOF" + ____ _ ________ ____ __ ____ __ ____ + / __ \ | / / ____/ / __ \____ _____/ /_ / _/___ _____/ /_____ _/ / / + / /_/ / | / / __/ / /_/ / __ \/ ___/ __/ / // __ \/ ___/ __/ __ `/ / / + / ____/| |/ / /___ / ____/ /_/ (__ ) /_ _/ // / / (__ ) /_/ /_/ / / / +/_/ |___/_____/ /_/ \____/____/\__/ /___/_/ /_/____/\__/\__,_/_/_/ + +EOF +} + +RD=$(echo "\033[01;31m") +YW=$(echo "\033[33m") +GN=$(echo "\033[1;92m") +CL=$(echo "\033[m") +BFR="\\r\\033[K" +HOLD="-" +CM="${GN}✓${CL}" +CROSS="${RD}✗${CL}" + +set -euo pipefail +shopt -s inherit_errexit nullglob + +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}" +} + +start_routines() { + header_info + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SOURCES" --menu "The package manager will use the correct sources to update and install packages on your Proxmox VE server.\n \nCorrect Proxmox VE sources?" 14 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Correcting Proxmox VE Sources" + cat <<EOF >/etc/apt/sources.list +deb http://deb.debian.org/debian bookworm main contrib +deb http://deb.debian.org/debian bookworm-updates main contrib +deb http://security.debian.org/debian-security bookworm-security main contrib +EOF +echo 'APT::Get::Update::SourceListWarnings::NonFreeFirmware "false";' >/etc/apt/apt.conf.d/no-bookworm-firmware.conf + msg_ok "Corrected Proxmox VE Sources" + ;; + no) + msg_error "Selected no to Correcting Proxmox VE Sources" + ;; + esac + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PVE-ENTERPRISE" --menu "The 'pve-enterprise' repository is only available to users who have purchased a Proxmox VE subscription.\n \nDisable 'pve-enterprise' repository?" 14 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Disabling 'pve-enterprise' repository" + cat <<EOF >/etc/apt/sources.list.d/pve-enterprise.list +# deb https://enterprise.proxmox.com/debian/pve bookworm pve-enterprise +EOF + msg_ok "Disabled 'pve-enterprise' repository" + ;; + no) + msg_error "Selected no to Disabling 'pve-enterprise' repository" + ;; + esac + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PVE-NO-SUBSCRIPTION" --menu "The 'pve-no-subscription' repository provides access to all of the open-source components of Proxmox VE.\n \nEnable 'pve-no-subscription' repository?" 14 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Enabling 'pve-no-subscription' repository" + cat <<EOF >/etc/apt/sources.list.d/pve-install-repo.list +deb http://download.proxmox.com/debian/pve bookworm pve-no-subscription +EOF + msg_ok "Enabled 'pve-no-subscription' repository" + ;; + no) + msg_error "Selected no to Enabling 'pve-no-subscription' repository" + ;; + esac + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "CEPH PACKAGE REPOSITORIES" --menu "The 'Ceph Package Repositories' provides access to both the 'no-subscription' and 'enterprise' repositories (initially disabled).\n \nCorrect 'ceph package sources?" 14 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Correcting 'ceph package repositories'" + cat <<EOF >/etc/apt/sources.list.d/ceph.list +# deb https://enterprise.proxmox.com/debian/ceph-quincy bookworm enterprise +# deb http://download.proxmox.com/debian/ceph-quincy bookworm no-subscription +# deb https://enterprise.proxmox.com/debian/ceph-reef bookworm enterprise +# deb http://download.proxmox.com/debian/ceph-reef bookworm no-subscription +EOF + msg_ok "Corrected 'ceph package repositories'" + ;; + no) + msg_error "Selected no to Correcting 'ceph package repositories'" + ;; + esac + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PVETEST" --menu "The 'pvetest' repository can give advanced users access to new features and updates before they are officially released.\n \nAdd (Disabled) 'pvetest' repository?" 14 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Adding 'pvetest' repository and set disabled" + cat <<EOF >/etc/apt/sources.list.d/pvetest-for-beta.list +# deb http://download.proxmox.com/debian/pve bookworm pvetest +EOF + msg_ok "Added 'pvetest' repository" + ;; + no) + msg_error "Selected no to Adding 'pvetest' repository" + ;; + esac + + if [[ ! -f /etc/apt/apt.conf.d/no-nag-script ]]; then + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUBSCRIPTION NAG" --menu "This will disable the nag message reminding you to purchase a subscription every time you log in to the web interface.\n \nDisable subscription nag?" 14 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "Support Subscriptions" "Supporting the software's development team is essential. Check their official website's Support Subscriptions for pricing. Without their dedicated work, we wouldn't have this exceptional software." 10 58 + msg_info "Disabling subscription nag" + echo "DPkg::Post-Invoke { \"dpkg -V proxmox-widget-toolkit | grep -q '/proxmoxlib\.js$'; if [ \$? -eq 1 ]; then { echo 'Removing subscription nag from UI...'; sed -i '/.*data\.status.*{/{s/\!//;s/active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; }; fi\"; };" >/etc/apt/apt.conf.d/no-nag-script + apt --reinstall install proxmox-widget-toolkit &>/dev/null + msg_ok "Disabled subscription nag (Delete browser cache)" + ;; + no) + whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "Support Subscriptions" "Supporting the software's development team is essential. Check their official website's Support Subscriptions for pricing. Without their dedicated work, we wouldn't have this exceptional software." 10 58 + msg_error "Selected no to Disabling subscription nag" + ;; + esac + fi + + if ! systemctl is-active --quiet pve-ha-lrm; then + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "HIGH AVAILABILITY" --menu "Enable high availability?" 10 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Enabling high availability" + systemctl enable -q --now pve-ha-lrm + systemctl enable -q --now pve-ha-crm + systemctl enable -q --now corosync + msg_ok "Enabled high availability" + ;; + no) + msg_error "Selected no to Enabling high availability" + ;; + esac + fi + + if systemctl is-active --quiet pve-ha-lrm; then + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "HIGH AVAILABILITY" --menu "If you plan to utilize a single node instead of a clustered environment, you can disable unnecessary high availability (HA) services, thus reclaiming system resources.\n\nIf HA becomes necessary at a later stage, the services can be re-enabled.\n\nDisable high availability?" 18 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Disabling high availability" + systemctl disable -q --now pve-ha-lrm + systemctl disable -q --now pve-ha-crm + systemctl disable -q --now corosync + msg_ok "Disabled high availability" + ;; + no) + msg_error "Selected no to Disabling high availability" + ;; + esac + fi + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UPDATE" --menu "\nUpdate Proxmox VE now?" 11 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Updating Proxmox VE (Patience)" + apt-get update &>/dev/null + apt-get -y dist-upgrade &>/dev/null + msg_ok "Updated Proxmox VE" + ;; + no) + msg_error "Selected no to Updating Proxmox VE" + ;; + esac + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "REBOOT" --menu "\nReboot Proxmox VE now? (recommended)" 11 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Rebooting Proxmox VE" + sleep 2 + msg_ok "Completed Post Install Routines" + reboot + ;; + no) + msg_error "Selected no to Rebooting Proxmox VE (Reboot recommended)" + msg_ok "Completed Post Install Routines" + ;; + esac +} + +header_info +echo -e "\nThis script will Perform Post Install Routines.\n" +while true; do + read -p "Start the Proxmox VE Post Install Script (y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) clear; exit ;; + *) echo "Please answer yes or no." ;; + esac +done + +if ! pveversion | grep -Eq "pve-manager/8.[0-2]"; then + msg_error "This version of Proxmox Virtual Environment is not supported" + echo -e "Requires Proxmox Virtual Environment Version 8.0 or later." + echo -e "Exiting..." + sleep 2 + exit +fi + +start_routines diff --git a/misc/post_install.sh b/misc/post_install.sh deleted file mode 100644 index d529fb3c..00000000 --- a/misc/post_install.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash - -echo -e "\e[1;33m This script will Setup Repositories and attempt the No-Nag fix. PVE7 ONLY \e[0m" -while true; do - read -p "Start the PVE7 Post Install Script (y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -if [ `pveversion | grep "pve-manager/7" | wc -l` -ne 1 ]; then - echo -e "This script requires Proxmox Virtual Environment 7.0 or greater" - echo -e "Exiting..." - sleep 2 - exit -fi -clear -echo -e "\e[1;33m Disable Enterprise Repository... \e[0m" -sleep 1 -sed -i "s/^deb/#deb/g" /etc/apt/sources.list.d/pve-enterprise.list -echo -e "\e[1;33m Setup Repositories... \e[0m" -sleep 1 -cat <<EOF > /etc/apt/sources.list -deb http://ftp.debian.org/debian bullseye main contrib -deb http://ftp.debian.org/debian bullseye-updates main contrib -deb http://security.debian.org/debian-security bullseye-security main contrib -deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription -# deb http://download.proxmox.com/debian/pve bullseye pvetest -EOF -echo -e "\e[1;33m Disable Subscription Nag... \e[0m" -echo "DPkg::Post-Invoke { \"dpkg -V proxmox-widget-toolkit | grep -q '/proxmoxlib\.js$'; if [ \$? -eq 1 ]; then { echo 'Removing subscription nag from UI...'; sed -i '/data.status/{s/\!//;s/Active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; }; fi\"; };" > /etc/apt/apt.conf.d/no-nag-script -apt --reinstall install proxmox-widget-toolkit &>/dev/null -echo -e "\e[1;33m Finished....Please Update Proxmox \e[0m" - -# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/post_install.sh)" diff --git a/misc/pve8-upgrade.sh b/misc/pve8-upgrade.sh new file mode 100644 index 00000000..360b339b --- /dev/null +++ b/misc/pve8-upgrade.sh @@ -0,0 +1,136 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +header_info() { + clear + cat <<"EOF" + ____ _ ____________ __ ______ __________ ___ ____ ______ + / __ \ | / / ____( __ ) / / / / __ \/ ____/ __ \/ | / __ \/ ____/ + / /_/ / | / / __/ / __ | / / / / /_/ / / __/ /_/ / /| | / / / / __/ + / ____/| |/ / /___/ /_/ / / /_/ / ____/ /_/ / _, _/ ___ |/ /_/ / /___ +/_/ |___/_____/\____/ \____/_/ \____/_/ |_/_/ |_/_____/_____/ + +EOF +} + +RD=$(echo "\033[01;31m") +YW=$(echo "\033[33m") +GN=$(echo "\033[1;92m") +CL=$(echo "\033[m") +BFR="\\r\\033[K" +HOLD="-" +CM="${GN}✓${CL}" +CROSS="${RD}✗${CL}" + +set -euo pipefail +shopt -s inherit_errexit nullglob + +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}" +} + +start_routines() { + header_info + + whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "PVE8 SOURCES" "This will set the correct sources to update and install Proxmox VE 8." 10 58 + msg_info "Changing to Proxmox VE 8 Sources" + cat <<EOF >/etc/apt/sources.list +deb http://ftp.debian.org/debian bookworm main contrib +deb http://ftp.debian.org/debian bookworm-updates main contrib +deb http://security.debian.org/debian-security bookworm-security main contrib +EOF + msg_ok "Changed to Proxmox VE 8 Sources" + + whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "PVE8-ENTERPRISE" "The 'pve-enterprise' repository is only available to users who have purchased a Proxmox VE subscription." 10 58 + msg_info "Disabling 'pve-enterprise' repository" + cat <<EOF >/etc/apt/sources.list.d/pve-enterprise.list +# deb https://enterprise.proxmox.com/debian/pve bookworm pve-enterprise +EOF + msg_ok "Disabled 'pve-enterprise' repository" + + whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "PVE8-NO-SUBSCRIPTION" "The 'pve-no-subscription' repository provides access to all of the open-source components of Proxmox VE." 10 58 + msg_info "Enabling 'pve-no-subscription' repository" + cat <<EOF >/etc/apt/sources.list.d/pve-install-repo.list +deb http://download.proxmox.com/debian/pve bookworm pve-no-subscription +EOF + msg_ok "Enabled 'pve-no-subscription' repository" + + whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "PVE8 CEPH PACKAGE REPOSITORIES" "The 'Ceph Package Repositories' provides access to both the 'no-subscription' and 'enterprise' repositories." 10 58 + msg_info "Enabling 'ceph package repositories'" + cat <<EOF >/etc/apt/sources.list.d/ceph.list +# deb https://enterprise.proxmox.com/debian/ceph-quincy bookworm enterprise +deb http://download.proxmox.com/debian/ceph-quincy bookworm no-subscription +EOF + msg_ok "Enabled 'ceph package repositories'" + + whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "PVE8 TEST" "The 'pvetest' repository can give advanced users access to new features and updates before they are officially released (Disabled)." 10 58 + msg_info "Adding 'pvetest' repository and set disabled" + cat <<EOF >/etc/apt/sources.list.d/pvetest-for-beta.list +# deb http://download.proxmox.com/debian/pve bookworm pvetest +EOF + msg_ok "Added 'pvetest' repository" + + whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "PVE8 UPDATE" "Updating to Proxmox VE 8" 10 58 + msg_info "Updating to Proxmox VE 8 (Patience)" + apt-get update + DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" dist-upgrade -y + msg_ok "Updated to Proxmox VE 8" + + CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "REBOOT" --menu "\nReboot Proxmox VE 8 now? (recommended)" 11 58 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + case $CHOICE in + yes) + msg_info "Rebooting Proxmox VE 8" + sleep 2 + msg_ok "Completed Install Routines" + reboot + ;; + no) + msg_error "Selected no to Rebooting Proxmox VE 8 (Reboot recommended)" + msg_ok "Completed Install Routines" + ;; + esac +} + +header_info +while true; do + read -p "Start the Update to Proxmox VE 8 Script (y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) clear; exit ;; + *) echo "Please answer yes or no." ;; + esac +done + +if ! command -v pveversion >/dev/null 2>&1; then + header_info + msg_error "\n No PVE Detected!\n" + exit +fi + +if ! pveversion | grep -Eq "pve-manager/(7\.4-(16|17|18|19))"; then + header_info + msg_error "This version of Proxmox Virtual Environment is not supported" + echo -e " PVE Version 7.4-16 or higher is required." + echo -e "\nExiting..." + sleep 3 + exit +fi + +start_routines diff --git a/misc/pyenv.sh b/misc/pyenv.sh new file mode 100644 index 00000000..0a548e78 --- /dev/null +++ b/misc/pyenv.sh @@ -0,0 +1,159 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +set -e +YW=$(echo "\033[33m") +RD=$(echo "\033[01;31m") +BL=$(echo "\033[36m") +GN=$(echo "\033[1;92m") +CL=$(echo "\033[m") +CM="${GN}✓${CL}" +CROSS="${RD}✗${CL}" +BFR="\\r\\033[K" +HOLD="-" +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}" +} +if command -v pveversion >/dev/null 2>&1; then msg_error "Can't Install on Proxmox "; exit; fi +msg_info "Installing pyenv" +apt-get install -y \ + make \ + build-essential \ + libjpeg-dev \ + libpcap-dev \ + libssl-dev \ + zlib1g-dev \ + libbz2-dev \ + libreadline-dev \ + libsqlite3-dev \ + autoconf \ + git \ + curl \ + sudo \ + llvm \ + libncursesw5-dev \ + xz-utils \ + tk-dev \ + libxml2-dev \ + libxmlsec1-dev \ + libffi-dev \ + libopenjp2-7 \ + libtiff5 \ + libturbojpeg0-dev \ + liblzma-dev &>/dev/null + +git clone https://github.com/pyenv/pyenv.git ~/.pyenv &>/dev/null +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" +pyenv install 3.11.1 &>/dev/null +pyenv global 3.11.1 +msg_ok "Installed Python 3.11.1" +read -r -p "Would you like to install Home Assistant Beta? <y/N> " prompt +if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then +msg_info "Installing Home Assistant Beta" +cat <<EOF >/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 +mkdir /srv/homeassistant +cd /srv/homeassistant +python3 -m venv . +source bin/activate +python3 -m pip install wheel &>/dev/null +pip3 install --upgrade pip &>/dev/null +pip3 install psycopg2-binary &>/dev/null +pip3 install --pre homeassistant &>/dev/null +systemctl enable homeassistant &>/dev/null +msg_ok "Installed Home Assistant Beta" +echo -e " Go to $(hostname -I | awk '{print $1}'):8123" +hass +fi + +read -r -p "Would you like to install ESPHome Beta? <y/N> " prompt +if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then +msg_info "Installing ESPHome Beta" +mkdir /srv/esphome +cd /srv/esphome +python3 -m venv . +source bin/activate +python3 -m pip install wheel &>/dev/null +pip3 install --upgrade pip &>/dev/null +pip3 install --pre esphome &>/dev/null +cat <<EOF >/srv/esphome/start.sh +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /srv/esphome/bin/activate +esphome dashboard /srv/esphome/ +EOF +chmod +x start.sh +cat <<EOF >/etc/systemd/system/esphomedashboard.service +[Unit] +Description=ESPHome Dashboard Service +After=network.target +[Service] +Type=simple +User=root +WorkingDirectory=/srv/esphome +ExecStart=/srv/esphome/start.sh +RestartSec=30 +Restart=on-failure +[Install] +WantedBy=multi-user.target +EOF +systemctl enable --now esphomedashboard &>/dev/null +msg_ok "Installed ESPHome Beta" +echo -e " Go to $(hostname -I | awk '{print $1}'):6052" +exec $SHELL +fi + +read -r -p "Would you like to install Matter-Server (Beta)? <y/N> " prompt +if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then +msg_info "Installing Matter Server" +apt-get install -y \ +libcairo2-dev \ +libjpeg62-turbo-dev \ +libgirepository1.0-dev \ +libpango1.0-dev \ +libgif-dev \ +g++ &>/dev/null +python3 -m pip install wheel +pip3 install --upgrade pip +pip install python-matter-server[server] +msg_ok "Installed Matter Server" +echo -e "Start server > python -m matter_server.server" +fi +msg_ok "\nFinished\n" +exec $SHELL diff --git a/misc/scaling-governor.sh b/misc/scaling-governor.sh index 8eace5bd..3523ab2c 100644 --- a/misc/scaling-governor.sh +++ b/misc/scaling-governor.sh @@ -1,99 +1,58 @@ #!/usr/bin/env bash -clear + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE set -e -while true; do - read -p "View CPU Scaling Governors. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done +header_info() { clear -function header_info { -echo -e " - _____ _____ _ _ - / ____| __ \| | | | - | | | |__) | | | | - | | | ___/| | | | - | |____| | | |__| | - \_____|_| \____/ - Scaling Governors -" +cat <<EOF + ________ __ __ _____ + / ___/ _ \/ / / / / ___/__ _ _____ _______ ___ _______ +/ /__/ ___/ /_/ / / (_ / _ \ |/ / -_) __/ _ \/ _ \/ __(_-< +\___/_/ \____/ \___/\___/___/\__/_/ /_//_/\___/_/ /___/ +EOF } -show_menu(){ - CL=`echo "\033[m"` - GN=`echo "\033[32m"` - BL=`echo "\033[36m"` - YW=`echo "\033[33m"` - fgred=`echo "\033[31m"` header_info - CK=$(uname -r) - IP=$(hostname -I) -# MAC=$(cat /sys/class/net/eno1/address) - ACSG=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors) - CCSG=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor) - echo -e "${YW}Proxmox IP ${BL}${IP}${CL}" - - echo -e "${YW}MAC Address ${BL}${MAC}${CL}" - - echo -e "${YW}Current Kernel ${BL}${CK}${CL}" - - echo -e "\n${YW}Available CPU Scaling Governors - ${BL}${ACSG}${CL}" - - echo -e "\n${YW}Current CPU Scaling Governor - ${BL}${CCSG}${CL}" - printf "\n ${fgred}Only Select Available CPU Scaling Governors From Above${CL}\n \n" - printf "${BL}**${YW} 1)${GN} Switch to ${BL}conservative${CL}${GN} CPU Scaling Governor ${CL}\n" - printf "${BL}**${YW} 2)${GN} Switch to ${BL}ondemand${CL}${GN} CPU Scaling Governor ${CL}\n" - printf "${BL}**${YW} 3)${GN} Switch to ${BL}userspace${CL}${GN} CPU Scaling Governor ${CL}\n" - printf "${BL}**${YW} 4)${GN} Switch to ${BL}powersave${CL}${GN} CPU Scaling Governor ${CL}\n" - printf "${BL}**${YW} 5)${GN} Switch to ${BL}performance${CL}${GN} CPU Scaling Governor ${CL}\n" - printf "${BL}**${YW} 6)${GN} Switch to ${BL}schedutil${CL}${GN} CPU Scaling Governor ${CL}\n" - printf "\n ${fgred}NOTE: Settings return to default after reboot${CL}\n" - printf "\n Please choose an option from the menu and press [ENTER] or ${fgred}x${CL} to exit." - read opt +whiptail --backtitle "Proxmox VE Helper Scripts" --title "CPU Scaling Governors" --yesno "View/Change CPU Scaling Governors. Proceed?" 10 58 || exit +current_governor=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor) +GOVERNORS_MENU=() +MSG_MAX_LENGTH=0 +while read -r TAG ITEM; do + OFFSET=2 + ((${#ITEM} + OFFSET > MSG_MAX_LENGTH)) && MSG_MAX_LENGTH=${#ITEM}+OFFSET + GOVERNORS_MENU+=("$TAG" "$ITEM " "OFF") +done < <(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors | tr ' ' '\n' | grep -v "$current_governor") +scaling_governor=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Current CPU Scaling Governor is set to $current_governor" --checklist "\nSelect the Scaling Governor to use:\n" 16 $((MSG_MAX_LENGTH + 58)) 6 "${GOVERNORS_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"') || exit +[ -z "$scaling_governor" ] && { + whiptail --backtitle "Proxmox VE Helper Scripts" --title "No CPU Scaling Governor Selected" --msgbox "It appears that no CPU Scaling Governor was selected" 10 68 + clear + exit } -clear -show_menu -while [ $opt != '' ] - do - if [ $opt = '' ]; then - exit; - else - case $opt in - 1) echo "conservative" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor - clear - show_menu - ;; - 2) echo "ondemand" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor - clear - show_menu - ;; - 3) echo "userspace" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor - clear - show_menu - ;; - 4) echo "powersave" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor - clear - show_menu - ;; - 5) echo "performance" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor - clear - show_menu - ;; - 6) echo "schedutil" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor - clear - show_menu - ;; - x)exit; - ;; - \n)exit; - ;; - *)clear; - show_menu; - ;; - esac +echo "${scaling_governor}" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor >/dev/null +current_governor=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor) +whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "Current CPU Scaling Governor" "\nCurrent CPU Scaling Governor has been set to $current_governor\n" 10 60 +CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "CPU Scaling Governor" --menu "This will establish a crontab to maintain the CPU Scaling Governor configuration across reboots.\n \nSetup a crontab?" 14 68 2 \ + "yes" " " \ + "no" " " 3>&2 2>&1 1>&3) + +case $CHOICE in + yes) + set +e + NEW_CRONTAB_COMMAND="(sleep 60 && echo \"$current_governor\" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor)" + EXISTING_CRONTAB=$(crontab -l 2>/dev/null) + if [[ -n "$EXISTING_CRONTAB" ]]; then + TEMP_CRONTAB_FILE=$(mktemp) + echo "$EXISTING_CRONTAB" | grep -v "@reboot (sleep 60 && echo*" > "$TEMP_CRONTAB_FILE" + crontab "$TEMP_CRONTAB_FILE" + rm "$TEMP_CRONTAB_FILE" fi - done + (crontab -l 2>/dev/null; echo "@reboot $NEW_CRONTAB_COMMAND") | crontab - + echo -e "\nCrontab Set (use 'crontab -e' to check)" + ;; + no) + echo -e "\n\033[31mNOTE: Settings return to default after reboot\033[m\n" + ;; +esac +echo -e "Current CPU Scaling Governor is set to \033[36m$current_governor\033[m\n" diff --git a/misc/technitiumdns-update.sh b/misc/technitiumdns-update.sh deleted file mode 100644 index 3cb30e42..00000000 --- a/misc/technitiumdns-update.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/sh -set -e -dotnetDir="/opt/dotnet" -dnsDir="/etc/dns" -dnsTar="/etc/dns/DnsServerPortable.tar.gz" -dnsUrl="https://download.technitium.com/dns/DnsServerPortable.tar.gz" - -mkdir -p $dnsDir -installLog="$dnsDir/install.log" -echo "" > $installLog - -echo "" -echo "===============================" -echo "Technitium DNS Server Update" -echo "===============================" - -if dotnet --list-runtimes 2> /dev/null | grep -q "Microsoft.NETCore.App 6.0."; -then - dotnetFound="yes" -else - dotnetFound="no" -fi - - if [ -d $dotnetDir ] - then - dotnetUpdate="yes" - echo "Updating .NET 6 Runtime..." - fi - - curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -c 6.0 --runtime dotnet --no-path --install-dir $dotnetDir --verbose >> $installLog 2>&1 - - if [ ! -f "/usr/bin/dotnet" ] - then - ln -s $dotnetDir/dotnet /usr/bin >> $installLog 2>&1 - fi - - if dotnet --list-runtimes 2> /dev/null | grep -q "Microsoft.NETCore.App 6.0."; - then - if [ "$dotnetUpdate" = "yes" ] - then - echo ".NET 6 Runtime was updated successfully!" - fi - else - echo "Failed to update .NET 6 Runtime. Please try again." - exit 1 - fi - -if curl -o $dnsTar --fail $dnsUrl >> $installLog 2>&1 -then - if [ -d $dnsDir ] - then - echo "Updating Technitium DNS Server..." - fi - - tar -zxf $dnsTar -C $dnsDir >> $installLog 2>&1 - - if [ "$(ps --no-headers -o comm 1 | tr -d '\n')" = "systemd" ] - then - if [ -f "/etc/systemd/system/dns.service" ] - then - echo "Restarting systemd service..." - systemctl restart dns.service >> $installLog 2>&1 - fi - - echo "" - echo "Technitium DNS Server was updated successfully!" - else - echo "" - echo "Failed to update Technitium DNS Server: systemd was not detected." - exit 1 - fi -else - echo "" - echo "Failed to download Technitium DNS Server from: $dnsUrl" - exit 1 -fi diff --git a/misc/unifi-update.sh b/misc/unifi-update.sh deleted file mode 100644 index a7a19aae..00000000 --- a/misc/unifi-update.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -APP="UniFi Update" -while true; do - read -p "This will run ${APP}. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${RD} - _ _ _ ______ _ - | | | | (_) ____(_) - | | | |_ __ _| |__ _ - | | | | _ \| | __| | | - | |__| | | | | | | | | - \____/|_| |_|_|_| |_| - UPDATE -${CL}" -} - -header_info -sleep 3 -wget -qL https://get.glennr.nl/unifi/update/unifi-update.sh && bash unifi-update.sh - diff --git a/misc/update-lxcs-cron.sh b/misc/update-lxcs-cron.sh new file mode 100644 index 00000000..04827734 --- /dev/null +++ b/misc/update-lxcs-cron.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +echo "$(date)" +excluded_containers=("$@") +function update_container() { + container=$1 + name=$(pct exec "$container" hostname) + os=$(pct config "$container" | awk '/^ostype/ {print $2}') + if [[ "$os" == "ubuntu" || "$os" == "debian" ]]; then + disk_info=$(pct exec "$container" df /boot | awk 'NR==2{gsub("%","",$5); printf "%s %.1fG %.1fG %.1fG", $5, $3/1024/1024, $2/1024/1024, $4/1024/1024 }') + read -ra disk_info_array <<<"$disk_info" + echo -e "\n[Info] Updating $container : $name - Boot Disk: ${disk_info_array[0]}% full [${disk_info_array[1]}/${disk_info_array[2]} used, ${disk_info_array[3]} free]" + else + echo -e "\n[Info] Updating $container : $name - [No disk info for ${os}]" + fi + case "$os" in + alpine) pct exec "$container" -- ash -c "apk update && apk upgrade" ;; + archlinux) pct exec "$container" -- bash -c "pacman -Syyu --noconfirm" ;; + fedora | rocky | centos | alma) pct exec "$container" -- bash -c "dnf -y update && dnf -y upgrade" ;; + ubuntu | debian | devuan) pct exec "$container" -- bash -c "apt-get update 2>/dev/null | grep 'packages.*upgraded'; apt-get upgrade --dry-run && DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" dist-upgrade -y; rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED" ;; + esac +} + +for container in $(pct list | awk '{if(NR>1) print $1}'); do + excluded=false + for excluded_container in "${excluded_containers[@]}"; do + if [ "$container" == "$excluded_container" ]; then + excluded=true + break + fi + done + if [ "$excluded" == true ]; then + echo -e "[Info] Skipping $container" + sleep 1 + else + status=$(pct status $container) + template=$(pct config $container | grep -q "template:" && echo "true" || echo "false") + if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then + echo -e "[Info] Starting $container" + pct start $container + echo -e "[Info] Waiting For $container To Start" + sleep 5 + update_container $container + echo -e "[Info] Shutting down $container" + pct shutdown $container & + elif [ "$status" == "status: running" ]; then + update_container $container + fi + fi +done +wait + +echo -e "Finished, All Containers Updated. \n" diff --git a/misc/update-lxcs.sh b/misc/update-lxcs.sh index d179b866..1ad3b5cd 100644 --- a/misc/update-lxcs.sh +++ b/misc/update-lxcs.sh @@ -1,80 +1,111 @@ -#!/bin/bash -set -e -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This Will Update All LXC Containers. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + function header_info { -echo -e "${BL} - _ _ _____ _____ _______ ______ - | | | | __ \| __ \ /\|__ __| ____| - | | | | |__) | | | | / \ | | | |__ - | | | | ___/| | | |/ /\ \ | | | __| - | |__| | | | |__| / ____ \| | | |____ - \____/|_| |_____/_/ \_\_| |______| + clear + cat <<"EOF" + __ __ __ __ __ _ ________ + / / / /___ ____/ /___ _/ /____ / / | |/ / ____/ + / / / / __ \/ __ / __ `/ __/ _ \ / / | / / +/ /_/ / /_/ / /_/ / /_/ / /_/ __/ / /___/ / /___ +\____/ .___/\__,_/\__,_/\__/\___/ /_____/_/|_\____/ + /_/ -${CL}" +EOF } +set -eEuo pipefail +YW=$(echo "\033[33m") +BL=$(echo "\033[36m") +RD=$(echo "\033[01;31m") +CM='\xE2\x9C\x94\033' +GN=$(echo "\033[1;92m") +CL=$(echo "\033[m") header_info +echo "Loading..." +whiptail --backtitle "Proxmox VE Helper Scripts" --title "Proxmox VE LXC Updater" --yesno "This Will Update LXC Containers. Proceed?" 10 58 || exit +NODE=$(hostname) +EXCLUDE_MENU=() +MSG_MAX_LENGTH=0 +while read -r TAG ITEM; do + OFFSET=2 + ((${#ITEM} + OFFSET > MSG_MAX_LENGTH)) && MSG_MAX_LENGTH=${#ITEM}+OFFSET + EXCLUDE_MENU+=("$TAG" "$ITEM " "OFF") +done < <(pct list | awk 'NR>1') +excluded_containers=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Containers on $NODE" --checklist "\nSelect containers to skip from updates:\n" 16 $((MSG_MAX_LENGTH + 23)) 6 "${EXCLUDE_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"') || exit -containers=$(pct list | tail -n +2 | cut -f1 -d' ') +function needs_reboot() { + local container=$1 + local os=$(pct config "$container" | awk '/^ostype/ {print $2}') + local reboot_required_file="/var/run/reboot-required.pkgs" + if [ -f "$reboot_required_file" ]; then + if [[ "$os" == "ubuntu" || "$os" == "debian" ]]; then + if pct exec "$container" -- [ -s "$reboot_required_file" ]; then + return 0 + fi + fi + fi + return 1 +} function update_container() { container=$1 - clear header_info - echo -e "${BL}[Info]${GN} Updating${BL} $container ${CL} \n" - pct config $container > temp - os=`awk '/^ostype/' temp | cut -d' ' -f2` - if [ "$os" == "alpine" ] - then - pct exec $container -- ash -c "apk update && apk upgrade" + name=$(pct exec "$container" hostname) + os=$(pct config "$container" | awk '/^ostype/ {print $2}') + if [[ "$os" == "ubuntu" || "$os" == "debian" || "$os" == "fedora" ]]; then + disk_info=$(pct exec "$container" df /boot | awk 'NR==2{gsub("%","",$5); printf "%s %.1fG %.1fG %.1fG", $5, $3/1024/1024, $2/1024/1024, $4/1024/1024 }') + read -ra disk_info_array <<<"$disk_info" + echo -e "${BL}[Info]${GN} Updating ${BL}$container${CL} : ${GN}$name${CL} - ${YW}Boot Disk: ${disk_info_array[0]}% full [${disk_info_array[1]}/${disk_info_array[2]} used, ${disk_info_array[3]} free]${CL}\n" else - pct exec $container -- bash -c "apt update && apt upgrade -y && apt autoremove -y" + echo -e "${BL}[Info]${GN} Updating ${BL}$container${CL} : ${GN}$name${CL} - ${YW}[No disk info for ${os}]${CL}\n" fi + case "$os" in + alpine) pct exec "$container" -- ash -c "apk update && apk upgrade" ;; + archlinux) pct exec "$container" -- bash -c "pacman -Syyu --noconfirm" ;; + fedora | rocky | centos | alma) pct exec "$container" -- bash -c "dnf -y update && dnf -y upgrade" ;; + ubuntu | debian | devuan) pct exec "$container" -- bash -c "apt-get update 2>/dev/null | grep 'packages.*upgraded'; apt list --upgradable && apt-get -yq dist-upgrade 2>&1; rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED" ;; + esac } -read -p "Skip stopped containers? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - skip=no -else - skip=yes + +containers_needing_reboot=() +header_info +for container in $(pct list | awk '{if(NR>1) print $1}'); do + if [[ " ${excluded_containers[@]} " =~ " $container " ]]; then + header_info + echo -e "${BL}[Info]${GN} Skipping ${BL}$container${CL}" + sleep 1 + else + status=$(pct status $container) + template=$(pct config $container | grep -q "template:" && echo "true" || echo "false") + if [ "$template" == "false" ] && [ "$status" == "status: stopped" ]; then + echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n" + pct start $container + echo -e "${BL}[Info]${GN} Waiting For${BL} $container${CL}${GN} To Start ${CL} \n" + sleep 5 + update_container $container + echo -e "${BL}[Info]${GN} Shutting down${BL} $container ${CL} \n" + pct shutdown $container & + elif [ "$status" == "status: running" ]; then + update_container $container + fi + if pct exec "$container" -- [ -e "/var/run/reboot-required" ]; then + # Get the container's hostname and add it to the list + container_hostname=$(pct exec "$container" hostname) + containers_needing_reboot+=("$container ($container_hostname)") + fi + fi +done +wait +header_info +echo -e "${GN}The process is complete, and the containers have been successfully updated.${CL}\n" +if [ "${#containers_needing_reboot[@]}" -gt 0 ]; then + echo -e "${RD}The following containers require a reboot:${CL}" + for container_name in "${containers_needing_reboot[@]}"; do + echo "$container_name" + done fi - -for container in $containers -do - status=`pct status $container` - if [ "$skip" == "no" ]; then - if [ "$status" == "status: stopped" ]; then - echo -e "${BL}[Info]${GN} Starting${BL} $container ${CL} \n" - pct start $container - echo -e "${BL}[Info]${GN} Waiting For${BL} $container${CL}${GN} To Start ${CL} \n" - sleep 5 - update_container $container - echo -e "${BL}[Info]${GN} Shutting down${BL} $container ${CL} \n" - pct shutdown $container & - elif [ "$status" == "status: running" ]; then - update_container $container - fi - fi - if [ "$skip" == "yes" ]; then - if [ "$status" == "status: running" ]; then - update_container $container - fi - fi -done; wait - -rm temp -echo -e "${GN} Finished, All Containers Updated. ${CL} \n" +echo "" diff --git a/misc/uptimekuma-update.sh b/misc/uptimekuma-update.sh deleted file mode 100644 index 70e77dcb..00000000 --- a/misc/uptimekuma-update.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env bash -ex -LATEST=$(curl -sL https://api.github.com/repos/louislam/uptime-kuma/releases/latest | grep '"tag_name":' | cut -d'"' -f4) -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}" -APP="Uptime Kuma" -while true; do - read -p "This will Update ${APP} to ${LATEST}. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear -function header_info { -echo -e "${DGN} - _ _ _ _ _ __ - | | | | | | (_) | |/ / - | | | |_v3_ | |_ _ _ __ ___ ___ | ' /_ _ _ __ ___ __ _ - | | | | _ \| __| | _ _ \ / _ \ | <| | | | _ _ \ / _ | - | |__| | |_) | |_| | | | | | | __/ | . \ |_| | | | | | | (_| | - \____/| .__/ \__|_|_| |_| |_|\___| |_|\_\__,_|_| |_| |_|\__,_| - | | - |_| UPDATE -${CL}" -} - -header_info - -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - - -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 &>/dev/null -git checkout $LATEST &>/dev/null -git pull &>/dev/null -msg_ok "Pulled ${APP} ${LATEST}" - -msg_info "Updating ${APP} to ${LATEST} (Patience)" -npm ci &>/dev/null -msg_ok "Updated ${APP}" - -msg_info "Starting ${APP}" -sudo systemctl start uptime-kuma &>/dev/null -msg_ok "Started ${APP}" - -msg_ok "Done!" diff --git a/misc/usb-passthrough.sh b/misc/usb-passthrough.sh index 8b75c792..25ceb3e6 100644 --- a/misc/usb-passthrough.sh +++ b/misc/usb-passthrough.sh @@ -1,39 +1,20 @@ #!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + echo -e "\e[1;33m This script will allow USB passthrough to a PRIVILEGED LXC Container ONLY\e[0m" while true; do - read -p "Did you replace 106 with your LXC ID? Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac + read -p "Did you replace 106 with your LXC ID? Proceed(y/n)?" yn + case $yn in + [Yy]*) break ;; + [Nn]*) exit ;; + *) echo "Please answer yes or no." ;; + esac done -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} TEMP_DIR=$(mktemp -d) pushd $TEMP_DIR >/dev/null CHAR_DEVS+=("166:.*") @@ -45,7 +26,7 @@ for char_dev in ${CHAR_DEVS[@]}; do CHAR_DEV_STRING+=" -regex \".*/${char_dev}\"" done -read -r -d '' HOOK_SCRIPT <<- EOF || true +read -r -d '' HOOK_SCRIPT <<-EOF || true for char_dev in \$(find /sys/dev/char -regextype sed $CHAR_DEV_STRING); do dev="/dev/\$(sed -n "/DEVNAME/ s/^.*=\(.*\)$/\1/p" \${char_dev}/uevent)"; mkdir -p \$(dirname \${LXC_ROOTFS_MOUNT}\${dev}); @@ -63,7 +44,7 @@ CTID_CONFIG_PATH=/etc/pve/lxc/${CTID}.conf sed '/autodev/d' $CTID_CONFIG_PATH >CTID.conf cat CTID.conf >$CTID_CONFIG_PATH -cat <<EOF >> $CTID_CONFIG_PATH +cat <<EOF >>$CTID_CONFIG_PATH lxc.autodev: 1 lxc.hook.autodev: bash -c '$HOOK_SCRIPT' EOF diff --git a/misc/vaultwarden-update.sh b/misc/vaultwarden-update.sh deleted file mode 100644 index b645e810..00000000 --- a/misc/vaultwarden-update.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash -VAULT=$(curl -s https://api.github.com/repos/dani-garcia/vaultwarden/releases/latest \ -| grep "tag_name" \ -| awk '{print substr($2, 2, length($2)-3) }') \ - -RD=`echo "\033[01;31m"` -BL=`echo "\033[36m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -function update_info { -echo -e "${BL} - __ __ _ _ _ - \ \ / / | | | | | - \ \ / /_ _ _ _| | |___ ____ _ _ __ __| | ___ _ __ - \ \/ / _ | | | | | __\ \ /\ / / _ | __/ _ |/ _ \ _ \ - \ / (_| | |_| | | |_ \ V V / (_| | | | (_| | __/ | | | - \/ \__,_|\__,_|_|\__| \_/\_/ \__,_|_| \__,_|\___|_| |_| - ${VAULT} UPDATE -${CL}" -} - -update_info -while true; do - read -p "This will Update Vaultwarden to $VAULT (set 2vCPU 2048MiB RAM Min.). Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -sleep 2 -echo -e "${GN} Stopping Vaultwarden... ${CL}" -systemctl stop vaultwarden.service -sleep 1 - -echo -e "${GN} Updating (Building) to ${VAULT} (Patience)... ${CL}" -git clone https://github.com/dani-garcia/vaultwarden &>/dev/null -cd vaultwarden -cargo build --features "sqlite,mysql,postgresql" --release &>/dev/null -cp target/release/vaultwarden /opt/vaultwarden/bin/ - -echo -e "${GN} Starting Vaultwarden ${VAULT}... ${CL}" -systemctl start vaultwarden.service -sleep 1 - -echo -e "${GN} Cleaning up... ${CL}" -cd ~ && rm -rf vaultwarden - -echo -e "${GN} Finished Update (set resources back to normal settings)${CL}" diff --git a/misc/web-vault-update.sh b/misc/web-vault-update.sh deleted file mode 100644 index d55b0aeb..00000000 --- a/misc/web-vault-update.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash -VWRELEASE=$(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) }') \ - -RD=`echo "\033[01;31m"` -BL=`echo "\033[36m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -function update_info { -echo -e "${BL} - __ __ _ _ _ - \ \ / / | | | | | - \ \ /\ / /__| |__ ________ ____ _ _ _| | |_ - \ \/ \/ / _ \ _ \______\ \ / / _ | | | | | __| - \ /\ / __/ |_) | \ V / (_| | |_| | | |_ - \/ \/ \___|_.__/ \_/ \__,_|\__,_|_|\__| - ${VWRELEASE} UPDATE -${CL}" -} -update_info -while true; do - read -p "This will Update Web-Vault to $VWRELEASE. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -sleep 2 -echo -e "${GN} Stopping Vaultwarden... ${CL}" -systemctl stop vaultwarden.service -sleep 1 - -echo -e "${GN} Updating to ${VWRELEASE}... ${CL}" -curl -fsSLO https://github.com/dani-garcia/bw_web_builds/releases/download/$VWRELEASE/bw_web_$VWRELEASE.tar.gz &>/dev/null -if [ -d "/var/lib/vaultwarden" ]; then -tar -xzf bw_web_$VWRELEASE.tar.gz -C /var/lib/vaultwarden/ &>/dev/null -else -tar -zxf bw_web_$VWRELEASE.tar.gz -C /opt/vaultwarden/ &>/dev/null -fi - -echo -e "${GN} Cleaning up... ${CL}" -rm bw_web_$VWRELEASE.tar.gz - -echo -e "${GN} Starting Vaultwarden... ${CL}" -systemctl start vaultwarden.service -sleep 1 -echo -e "${GN} Finished Update ${CL}" diff --git a/misc/webmin.sh b/misc/webmin.sh index 080b5611..a7188b01 100644 --- a/misc/webmin.sh +++ b/misc/webmin.sh @@ -1,40 +1,61 @@ #!/usr/bin/env bash -YW=`echo "\033[33m"` -RD=`echo "\033[01;31m"` -BL=`echo "\033[36m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -while true; do - read -p "This will Install Webmin, Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE -echo -en "${GN} Installing Prerequisites... " +function header_info { + clear + cat <<"EOF" + _ __ __ _ + | | /| / /__ / / __ _ (_)__ + | |/ |/ / -_) _ \/ ' \/ / _ \ + |__/|__/\__/_.__/_/_/_/_/_//_/ + +EOF +} +set -eEuo pipefail +YW=$(echo "\033[33m") +BL=$(echo "\033[36m") +BGN=$(echo "\033[4;92m") +GN=$(echo "\033[1;92m") +DGN=$(echo "\033[32m") +CL=$(echo "\033[m") +CM="${GN}✓${CL}" +BFR="\\r\\033[K" +HOLD="-" + +msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." +} + +msg_ok() { + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" +} + +header_info + +whiptail --backtitle "Proxmox VE Helper Scripts" --title "Webmin Installer" --yesno "This Will Install Webmin on this LXC Container. Proceed?" 10 58 || exit + +msg_info "Installing Prerequisites" apt update &>/dev/null apt-get -y install libnet-ssleay-perl libauthen-pam-perl libio-pty-perl unzip shared-mime-info &>/dev/null -echo -e "${CM}${CL} \r" +msg_ok "Installed Prerequisites" -echo -en "${GN} Downloading Webmin... " -wget http://prdownloads.sourceforge.net/webadmin/webmin_1.996_all.deb &>/dev/null -echo -e "${CM}${CL} \r" +LATEST=$(curl -sL https://api.github.com/repos/webmin/webmin/releases/latest | grep '"tag_name":' | cut -d'"' -f4) -echo -en "${GN} Installing Webmin... " -dpkg --install webmin_1.996_all.deb &>/dev/null -echo -e "${CM}${CL} \r" +msg_info "Downloading Webmin" +wget -q https://github.com/webmin/webmin/releases/download/$LATEST/webmin_${LATEST}_all.deb +msg_ok "Downloaded Webmin" -echo -en "${GN} Setting Default Webmin usermame & password to root... " +msg_info "Installing Webmin" +dpkg -i webmin_${LATEST}_all.deb &>/dev/null /usr/share/webmin/changepass.pl /etc/webmin root root &>/dev/null -rm -rf /root/webmin_1.996_all.deb -echo -e "${CM}${CL} \r" +rm -rf /root/webmin_${LATEST}_all.deb +msg_ok "Installed Webmin" + IP=$(hostname -I | cut -f1 -d ' ') -echo -e "${BL} Successfully Installed Webmin, Now Go To https://${IP}:10000 ${CL}" - - -# bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/webmin.sh)" +echo -e "Successfully Installed!! Webmin should be reachable by going to ${BL}https://${IP}:10000${CL}" diff --git a/misc/zwavejs2mqtt-update.sh b/misc/zwavejs2mqtt-update.sh deleted file mode 100644 index cf02af01..00000000 --- a/misc/zwavejs2mqtt-update.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bash -set -e -RD=`echo "\033[01;31m"` -BL=`echo "\033[36m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -function error_exit() { - trap - ERR - local reason="Unknown failure occured." - local msg="${1:-$reason}" - local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" - echo -e "$flag $msg" 1>&2 - exit $EXIT -} - -echo -en "${GN} Updating Zwavejs2MQTT... " -systemctl stop zwavejs2mqtt.service -cd /opt/zwavejs2mqtt -curl -s https://api.github.com/repos/zwave-js/zwavejs2mqtt/releases/latest | grep "browser_download_url.*zip" | cut -d : -f 2,3 | tr -d \" | wget -i - &>/dev/null -unzip -o zwavejs2mqtt-v*.zip zwavejs2mqtt &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Checking Service... " -SERVICE=/etc/systemd/system/zwavejs2mqtt.service -cat <<EOF > $SERVICE -[Unit] -Description=ZWavejs2MQTT -Wants=network-online.target -After=network-online.target -[Service] -User=root -WorkingDirectory=/opt/zwavejs2mqtt -ExecStart=/opt/zwavejs2mqtt/zwavejs2mqtt -[Install] -WantedBy=multi-user.target -EOF -echo -e "${CM}${CL} \r" - -echo -en "${GN} Cleanup... " -rm zwavejs2mqtt-v*.zip -systemctl --system daemon-reload -systemctl start zwavejs2mqtt.service -systemctl enable zwavejs2mqtt.service &>/dev/null -echo -e "${CM}${CL} \n" - -echo -e "${GN} Finished ${CL}" - diff --git a/setup/adguard-install.sh b/setup/adguard-install.sh deleted file mode 100644 index fd8ff882..00000000 --- a/setup/adguard-install.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing AdGuard Home" -curl -sSL https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh &>/dev/null -msg_ok "Installed AdGuard Home" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/adguard_setup.sh b/setup/adguard_setup.sh deleted file mode 100644 index bd48318d..00000000 --- a/setup/adguard_setup.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -RETRY_NUM=5 -RETRY_EVERY=3 -NUM=$RETRY_NUM -trap die ERR -trap 'die "Script interrupted."' INT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} - -echo -e "${CHECKMARK} \e[1;92m Setting up Container OS... \e[0m" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -e "${CROSS} \e[1;31m No Network \e[0m $(date)" - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS} \e[1;31m No Network After $RETRY_NUM Tries \e[0m" - exit 1 - fi -done - echo -e "${CHECKMARK} \e[1;92m Network Connected \e[0m $(hostname -I)" - -echo -e "${CHECKMARK} \e[1;92m Updating Container OS... \e[0m" -apt-get update &>/dev/null -apt-get -qqy upgrade &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Dependencies... \e[0m" -apt-get update &>/dev/null -apt-get -y install \ - curl \ - sudo &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing AdGuard Home... \e[0m" -curl -sSL https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Customizing LXC... \e[0m" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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//') - -echo -e "${CHECKMARK} \e[1;92m Cleanup... \e[0m" -rm -rf /adguard_setup.sh /var/{cache,log}/* /var/lib/apt/lists/* diff --git a/setup/daemonsync-install.sh b/setup/daemonsync-install.sh deleted file mode 100644 index 2af9de0a..00000000 --- a/setup/daemonsync-install.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y g++-multilib &>/dev/null -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 &>/dev/null -sudo dpkg -i daemonsync_2.2.0.0059_amd64.deb &>/dev/null -msg_ok "Installed Daemon Sync Server" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/dashy-install.sh b/setup/dashy-install.sh deleted file mode 100644 index 02039294..00000000 --- a/setup/dashy-install.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y git &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -sudo curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - &>/dev/null -msg_ok "Set up Node.js Repository" - -msg_info "Installing Node.js" -sudo apt-get install -y nodejs git make g++ gcc &>/dev/null -msg_ok "Installed Node.js" - -msg_info "Installing Yarn" -npm install --global yarn &>/dev/null -msg_ok "Installed Yarn" - -msg_info "Installing Dashy (Patience)" -git clone https://github.com/Lissy93/dashy.git &>/dev/null -cd /dashy -yarn &>/dev/null -export NODE_OPTIONS=--max-old-space-size=1000 &>/dev/null -yarn build &>/dev/null -msg_ok "Installed Dashy" - -msg_info "Creating Service" -cat <<EOF > /etc/systemd/system/dashy.service -[Unit] -Description=dashy - -[Service] -Type=simple -WorkingDirectory=/dashy -ExecStart=/usr/bin/yarn start -[Install] -WantedBy=multi-user.target -EOF -sudo systemctl start dashy &>/dev/null -sudo systemctl enable dashy &>/dev/null -msg_ok "Created Service" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/debian-install.sh b/setup/debian-install.sh deleted file mode 100644 index 48e7eb1f..00000000 --- a/setup/debian-install.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -msg_ok "Installed Dependencies" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -chmod -x /etc/update-motd.d/* -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/debian11_setup.sh b/setup/debian11_setup.sh deleted file mode 100644 index e1cbf177..00000000 --- a/setup/debian11_setup.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -RETRY_NUM=5 -RETRY_EVERY=3 -NUM=$RETRY_NUM -trap die ERR -trap 'die "Script interrupted."' INT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} - -echo -e "${CHECKMARK} \e[1;92m Setting up Container OS... \e[0m" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -e "${CROSS} \e[1;31m No Network: \e[0m $(date)" - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS} \e[1;31m No Network After $RETRY_NUM Tries \e[0m" - exit 1 - fi -done - echo -e "${CHECKMARK} \e[1;92m Network Connected: \e[0m $(hostname -I)" - -echo -e "${CHECKMARK} \e[1;92m Updating Container OS... \e[0m" -apt-get update &>/dev/null -apt-get -qqy upgrade &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Dependencies... \e[0m" -apt-get update &>/dev/null -apt-get -qqy install \ - curl \ - sudo &>/dev/null - -DOCKER_CONFIG_PATH='/etc/docker/daemon.json' -mkdir -p $(dirname $DOCKER_CONFIG_PATH) -cat >$DOCKER_CONFIG_PATH <<'EOF' -{ - "log-driver": "journald" -} -EOF - -echo -e "${CHECKMARK} \e[1;92m Customizing Container... \e[0m" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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//') - -echo -e "${CHECKMARK} \e[1;92m Cleanup... \e[0m" -rm -rf /debian11_setup.sh /var/{cache,log}/* /var/lib/apt/lists/* diff --git a/setup/deconz-install.sh b/setup/deconz-install.sh deleted file mode 100644 index d38b416a..00000000 --- a/setup/deconz-install.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y gnupg &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Setting Phoscon Repository" -wget -q http://phoscon.de/apt/deconz.pub.key -O - | sudo apt-key add - &>/dev/null -sh -c "echo 'deb [arch=amd64] http://phoscon.de/apt/deconz $(lsb_release -cs) main' > /etc/apt/sources.list.d/deconz.list" &>/dev/null -msg_ok "Setup Phoscon Repository" - -msg_info "Installing deConz" -apt-get update &>/dev/null -apt-get install -y deconz &>/dev/null -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 -systemctl start deconz -systemctl enable deconz &>/dev/null -msg_ok "Created Service" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -chmod -x /etc/update-motd.d/* -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/docker-install.sh b/setup/docker-install.sh deleted file mode 100644 index aec07703..00000000 --- a/setup/docker-install.sh +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -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) -cat >$DOCKER_CONFIG_PATH <<'EOF' -{ - "log-driver": "journald" -} -EOF -sh <(curl -sSL https://get.docker.com) &>/dev/null -msg_ok "Installed Docker $DOCKER_LATEST_VERSION" - -read -r -p "Would you like to add Portainer? <Y/n> " prompt -if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] -then -PORTAINER="Y" -else -PORTAINER="N" -fi - -if [[ $PORTAINER == "Y" ]]; then -msg_info "Installing Portainer $PORTAINER_LATEST_VERSION" -docker volume create portainer_data >/dev/null -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 &>/dev/null -msg_ok "Installed Portainer $PORTAINER_LATEST_VERSION" -fi - -read -r -p "Would you like to add Docker Compose? <Y/n> " prompt -if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] -then -DOCKER_COMPOSE="Y" -else -DOCKER_COMPOSE="N" -fi - -if [[ $DOCKER_COMPOSE == "Y" ]]; 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 - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/esphome-install.sh b/setup/esphome-install.sh deleted file mode 100644 index e8c0c05a..00000000 --- a/setup/esphome-install.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y git &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing pip3" -apt-get install -y python3-pip &>/dev/null -msg_ok "Installed pip3" - -msg_info "Installing ESPHome" -pip3 install esphome &>/dev/null -msg_ok "Installed ESPHome" - -msg_info "Installing ESPHome Dashboard" -pip3 install tornado esptool &>/dev/null - -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 -systemctl enable esphomeDashboard.service &>/dev/null -systemctl start esphomeDashboard -msg_ok "Installed ESPHome Dashboard" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/esphome_setup.sh b/setup/esphome_setup.sh deleted file mode 100644 index 001730f0..00000000 --- a/setup/esphome_setup.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' -YW=`echo "\033[33m"` -BL=`echo "\033[36m"` -RD=`echo "\033[01;31m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -RETRY_NUM=5 -RETRY_EVERY=3 -NUM=$RETRY_NUM -trap die ERR -trap 'die "Script interrupted."' INT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} - -echo -en "${GN} Setting up Container OS... " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -echo -e "${CM}${CL} \r" - -echo -en "${GN} Updating Container OS... " -apt-get update &>/dev/null -apt-get -qqy upgrade &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Installing Dependencies... " -apt-get update &>/dev/null -apt-get -qqy install \ - curl \ - sudo &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Installing pip3... " -apt-get install python3-pip -y &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Installing ESPHome... " -pip3 install esphome &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Installing ESPHome Dashboard... " -pip3 install tornado esptool &>/dev/null - -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 -systemctl enable esphomeDashboard.service &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Customizing Container... " -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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//') -systemctl start esphomeDashboard -echo -e "${CM}${CL} \r" - -echo -en "${GN} Cleanup... " -rm -rf /esphome_setup.sh /var/{cache,log}/* /var/lib/apt/lists/* -echo -e "${CM}${CL} \r" diff --git a/setup/grafana-install.sh b/setup/grafana-install.sh deleted file mode 100644 index 9eff5400..00000000 --- a/setup/grafana-install.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y gnupg &>/dev/null -apt-get install -y apt-transport-https &>/dev/null -apt-get install -y software-properties-common &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Setting up Grafana Repository" -wget -qO- https://packages.grafana.com/gpg.key | sudo apt-key add - &>/dev/null -echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list &>/dev/null -msg_ok "Set up Grafana Repository" - -msg_info "Installing Grafana" -apt-get update &>/dev/null -apt-get install -y grafana &>/dev/null -msg_ok "Installed Grafana" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 -systemctl start grafana-server -systemctl enable grafana-server.service &>/dev/null - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/grocy-install.sh b/setup/grocy-install.sh deleted file mode 100644 index de7bc523..00000000 --- a/setup/grocy-install.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y apache2 &>/dev/null -apt-get install -y unzip &>/dev/null -apt-get install -y php &>/dev/null -apt-get install -y libapache2-mod-php &>/dev/null -apt-get install -y php-sqlite3 &>/dev/null -apt-get install -y php-gd &>/dev/null -apt-get install -y php-intl &>/dev/null -apt-get install -y php-mbstring &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing grocy" -wget https://releases.grocy.info/latest &>/dev/null -unzip latest -d /var/www/html &>/dev/null -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 <<EOF > /etc/apache2/sites-available/grocy.conf -<VirtualHost *:80> - ServerAdmin webmaster@localhost - DocumentRoot /var/www/html/public - ErrorLog /var/log/apache2/error.log -<Directory /var/www/html/public> - Options Indexes FollowSymLinks MultiViews - AllowOverride All - Order allow,deny - allow from all -</Directory> -</VirtualHost> -EOF - -a2dissite 000-default.conf &>/dev/null -a2ensite grocy.conf &>/dev/null -a2enmod rewrite &>/dev/null -systemctl reload apache2 -msg_ok "Installed grocy" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -chmod -x /etc/update-motd.d/* -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/cache/* /root/latest -msg_ok "Cleaned" diff --git a/setup/ha_setup.sh b/setup/ha_setup.sh deleted file mode 100644 index a97b62e8..00000000 --- a/setup/ha_setup.sh +++ /dev/null @@ -1,296 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -RETRY_NUM=5 -RETRY_EVERY=3 -NUM=$RETRY_NUM -trap die ERR -trap 'die "Script interrupted."' INT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} - -echo -e "${CHECKMARK} \e[1;92m Setting up Container OS... \e[0m" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -e "${CROSS} \e[1;31m No Network: \e[0m $(date)" - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS} \e[1;31m No Network After $RETRY_NUM Tries \e[0m" - exit 1 - fi -done - echo -e "${CHECKMARK} \e[1;92m Network Connected: \e[0m $(hostname -I)" - -echo -e "${CHECKMARK} \e[1;92m Updating Container OS... \e[0m" -apt-get update &>/dev/null -apt-get -qqy upgrade &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Dependencies... \e[0m" -apt-get update &>/dev/null -apt-get -qqy install \ - curl \ - sudo &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing pip3... \e[0m" -apt-get install -y python3-pip &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Docker... \e[0m" -DOCKER_CONFIG_PATH='/etc/docker/daemon.json' -mkdir -p $(dirname $DOCKER_CONFIG_PATH) -cat >$DOCKER_CONFIG_PATH <<'EOF' -{ - "log-driver": "journald" -} -EOF -sh <(curl -sSL https://get.docker.com) &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Pulling Portainer Image...\e[0m" -docker pull portainer/portainer-ce:latest &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Portainer... \e[0m" -docker volume create portainer_data >/dev/null -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 &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Pulling Home Assistant Image...\e[0m" -docker pull homeassistant/home-assistant:stable &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Home Assistant... \e[0m" -docker volume create hass_config >/dev/null -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 \ - -v /etc/timezone:/etc/timezone:ro \ - --net=host \ - homeassistant/home-assistant:stable &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Creating Update Menu Script... \e[0m" -pip3 install runlike &>/dev/null -UPDATE_PATH='/root/update' -UPDATE_CONTAINERS_PATH='/root/update-containers.sh' -cat >$UPDATE_PATH <<'EOF' -#!/bin/sh -set -o errexit -show_menu(){ - normal=`echo "\033[m"` - safe=`echo "\033[32m"` - menu=`echo "\033[36m"` - number=`echo "\033[33m"` - bgred=`echo "\033[41m"` - fgred=`echo "\033[31m"` - hostname -I - printf "\n${menu}*********************************************${normal}\n" - printf "${menu}**${number} 1)${safe} Switch to Stable Branch ${normal}\n" - printf "${menu}**${number} 2)${number} Switch to Beta Branch ${normal}\n" - printf "${menu}**${number} 3)${fgred} Switch to Dev Branch ${normal}\n" - printf "${menu}**${number} 4)${safe} Backup Home Assistant Data (to root) ${normal}\n" - printf "${menu}**${number} 5)${number} Restore Home Assistant Data ${normal}\n" - printf "${menu}**${number} 6)${fgred} Edit Home Assistant Configuration ${normal}\n" - printf "${menu}**${number} 7)${safe} Restart Home Assistant ${normal}\n" - printf "${menu}**${number} 8)${safe} Just Update Containers ${normal}\n" - printf "${menu}**${number} 9)${number} Remove Unused Images ${normal}\n" - printf "${menu}**${number} 10)${safe} Update Host OS ${normal}\n" - printf "${menu}**${number} 11)${safe} Reboot Host OS ${normal}\n" - printf "${menu}*********************************************${normal}\n" - printf "Please choose an option from the menu and enter or ${fgred}x to exit. ${normal}" - read opt -} -option_picked(){ - msgcolor=`echo "\033[01;31m"` - normal=`echo "\033[00;00m"` - message=${@:-"${normal}Error: No message passed"} - printf "${msgcolor}${message}${normal}\n" -} -clear -show_menu -while [ $opt != '' ] - do - if [ $opt = '' ]; then - exit; - else - case $opt in - 1) clear; - option_picked "Switching to Stable Branch"; - TAG=stable - break; - ;; - 2) clear; - option_picked "Switching to Beta Branch"; - TAG=beta - break; - ;; - 3) while true; do - read -p "Are you sure you want to Switch to Dev Branch? Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac - done - clear; - option_picked "Switching to Dev Branch"; - TAG=dev - break; - ;; - 4) clear; - option_picked "Backing up Home Assistant Data to root (hass_config)"; - rm -r hass_config; - cp -pR /var/lib/docker/volumes/hass_config/ /root/; - sleep 2; - clear; - show_menu; - ;; - 5) while true; do - read -p "Are you sure you want to Restore Home Assistant Data? Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac - done - clear; - option_picked "Restoring Home Assistant Data from root (hass_config)"; - rm -r /var/lib/docker/volumes/hass_config/_data; - cp -pR /root/hass_config/_data /var/lib/docker/volumes/hass_config/; - sleep 2; - clear; - show_menu; - ;; - 6) while true; do - read -p "Are you sure you want to Edit Home Assistant Configuration? Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac - done - clear; - option_picked "Editing Home Assistant Configuration"; - nano /var/lib/docker/volumes/hass_config/_data/configuration.yaml; - clear; - show_menu; - ;; - 7) clear; - option_picked "Restarting Home Assistant"; - docker restart homeassistant; - exit; - ;; - 8) clear; - option_picked "Just Updating Containers"; - ./update-containers.sh; - sleep 2; - clear; - show_menu; - ;; - 9) clear; - option_picked "Removing Unused Images"; - docker image prune -af; - sleep 2; - clear; - show_menu; - ;; - 10) clear; - option_picked "Updating Host OS"; - apt update && apt upgrade -y; - sleep 2; - clear; - show_menu; - ;; - 11) clear; - option_picked "Reboot Host OS"; - reboot; - exit; - ;; - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose an option from the menu"; - show_menu; - ;; - esac - fi - done -docker pull homeassistant/home-assistant:$TAG -docker rm --force homeassistant -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 \ - -v /etc/timezone:/etc/timezone:ro \ - --net=host \ - homeassistant/home-assistant:$TAG -EOF -sudo chmod +x /root/update -cat >$UPDATE_CONTAINERS_PATH <<'EOF' -#!/bin/bash -set -o errexit -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 -EOF -sudo chmod +x /root/update-containers.sh - -echo -e "${CHECKMARK} \e[1;92m Customizing LXC... \e[0m" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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//') -mkdir /root/hass_config -echo -e "${CHECKMARK} \e[1;92m Cleanup... \e[0m" -rm -rf /ha_setup.sh /var/{cache,log}/* /var/lib/apt/lists/* diff --git a/setup/heimdalldashboard-install.sh b/setup/heimdalldashboard-install.sh deleted file mode 100644 index 852068d8..00000000 --- a/setup/heimdalldashboard-install.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing PHP" -apt-get install -y php &>/dev/null -apt-get install -y php-sqlite3 &>/dev/null -apt-get install -y php-zip &>/dev/null -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}" -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) }') -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 -sudo systemctl enable --now heimdall.service &>/dev/null -msg_ok "Created Service" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/homeassistant-install.sh b/setup/homeassistant-install.sh deleted file mode 100644 index 8ee274bb..00000000 --- a/setup/homeassistant-install.sh +++ /dev/null @@ -1,329 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing pip3" -apt-get install -y python3-pip &>/dev/null -msg_ok "Installed pip3" - -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) -cat >$DOCKER_CONFIG_PATH <<'EOF' -{ - "log-driver": "journald" -} -EOF -sh <(curl -sSL https://get.docker.com) &>/dev/null -msg_ok "Installed Docker $DOCKER_LATEST_VERSION" - -msg_info "Pulling Portainer $PORTAINER_LATEST_VERSION Image" -docker pull portainer/portainer-ce:latest &>/dev/null -msg_ok "Pulled Portainer $PORTAINER_LATEST_VERSION Image" - -msg_info "Installing Portainer $PORTAINER_LATEST_VERSION" -docker volume create portainer_data >/dev/null -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 &>/dev/null -msg_ok "Installed Portainer $PORTAINER_LATEST_VERSION" - -msg_info "Pulling Home Assistant $CORE_LATEST_VERSION Image" -docker pull homeassistant/home-assistant:stable &>/dev/null -msg_ok "Pulled Home Assistant $CORE_LATEST_VERSION Image" - -msg_info "Installing Home Assistant $CORE_LATEST_VERSION" -docker volume create hass_config >/dev/null -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 &>/dev/null -msg_ok "Installed Home Assistant $CORE_LATEST_VERSION" - -msg_info "Creating Update Menu Script" -pip3 install runlike &>/dev/null -UPDATE_PATH='/root/update' -UPDATE_CONTAINERS_PATH='/root/update-containers.sh' -cat >$UPDATE_PATH <<'EOF' -#!/bin/sh -set -o errexit -show_menu(){ - normal=`echo "\033[m"` - safe=`echo "\033[32m"` - menu=`echo "\033[36m"` - number=`echo "\033[33m"` - bgred=`echo "\033[41m"` - fgred=`echo "\033[31m"` - hostname -I - printf "\n${menu}*********************************************${normal}\n" - printf "${menu}**${number} 1)${safe} Switch to Stable Branch ${normal}\n" - printf "${menu}**${number} 2)${number} Switch to Beta Branch ${normal}\n" - printf "${menu}**${number} 3)${fgred} Switch to Dev Branch ${normal}\n" - printf "${menu}**${number} 4)${safe} Backup Home Assistant Data (to root) ${normal}\n" - printf "${menu}**${number} 5)${number} Restore Home Assistant Data ${normal}\n" - printf "${menu}**${number} 6)${fgred} Edit Home Assistant Configuration ${normal}\n" - printf "${menu}**${number} 7)${safe} Restart Home Assistant ${normal}\n" - printf "${menu}**${number} 8)${safe} Just Update Containers ${normal}\n" - printf "${menu}**${number} 9)${number} Remove Unused Images ${normal}\n" - printf "${menu}**${number} 10)${safe} Update Host OS ${normal}\n" - printf "${menu}**${number} 11)${safe} Reboot Host OS ${normal}\n" - printf "${menu}*********************************************${normal}\n" - printf "Please choose an option from the menu and enter or ${fgred}x to exit. ${normal}" - read opt -} -option_picked(){ - msgcolor=`echo "\033[01;31m"` - normal=`echo "\033[00;00m"` - message=${@:-"${normal}Error: No message passed"} - printf "${msgcolor}${message}${normal}\n" -} -clear -show_menu -while [ $opt != '' ] - do - if [ $opt = '' ]; then - exit; - else - case $opt in - 1) clear; - option_picked "Switching to Stable Branch"; - TAG=stable - break; - ;; - 2) clear; - option_picked "Switching to Beta Branch"; - TAG=beta - break; - ;; - 3) while true; do - read -p "Are you sure you want to Switch to Dev Branch? Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac - done - clear; - option_picked "Switching to Dev Branch"; - TAG=dev - break; - ;; - 4) clear; - option_picked "Backing up Home Assistant Data to root (hass_config)"; - rm -r hass_config; - cp -pR /var/lib/docker/volumes/hass_config/ /root/; - sleep 2; - clear; - show_menu; - ;; - 5) while true; do - read -p "Are you sure you want to Restore Home Assistant Data? Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac - done - clear; - option_picked "Restoring Home Assistant Data from root (hass_config)"; - rm -r /var/lib/docker/volumes/hass_config/_data; - cp -pR /root/hass_config/_data /var/lib/docker/volumes/hass_config/; - sleep 2; - clear; - show_menu; - ;; - 6) while true; do - read -p "Are you sure you want to Edit Home Assistant Configuration? Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac - done - clear; - option_picked "Editing Home Assistant Configuration"; - nano /var/lib/docker/volumes/hass_config/_data/configuration.yaml; - clear; - show_menu; - ;; - 7) clear; - option_picked "Restarting Home Assistant"; - docker restart homeassistant; - exit; - ;; - 8) clear; - option_picked "Just Updating Containers"; - ./update-containers.sh; - sleep 2; - clear; - show_menu; - ;; - 9) clear; - option_picked "Removing Unused Images"; - docker image prune -af; - sleep 2; - clear; - show_menu; - ;; - 10) clear; - option_picked "Updating Host OS"; - apt update && apt upgrade -y; - sleep 2; - clear; - show_menu; - ;; - 11) clear; - option_picked "Reboot Host OS"; - reboot; - exit; - ;; - x)exit; - ;; - \n)exit; - ;; - *)clear; - option_picked "Please choose an option from the menu"; - show_menu; - ;; - esac - fi - done -docker pull homeassistant/home-assistant:$TAG -docker rm --force homeassistant -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 \ - -v /etc/timezone:/etc/timezone:ro \ - --net=host \ - homeassistant/home-assistant:$TAG -EOF -sudo chmod +x /root/update -cat >$UPDATE_CONTAINERS_PATH <<'EOF' -#!/bin/bash -set -o errexit -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 -EOF -sudo chmod +x /root/update-containers.sh -msg_ok "Created Update Menu Script" -mkdir /root/hass_config -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/homebridge-install.sh b/setup/homebridge-install.sh deleted file mode 100644 index 8ba3327f..00000000 --- a/setup/homebridge-install.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - &>/dev/null -msg_ok "Set up Node.js Repository" - -msg_info "Installing Node.js" -sudo apt-get install -y nodejs gcc g++ make python net-tools &>/dev/null -msg_ok "Installed Node.js" - -msg_info "nstalling Homebridge" -sudo npm install -g --unsafe-perm homebridge homebridge-config-ui-x &>/dev/null -msg_info "nstalled Homebridge" - -msg_info "Creating Service" -sudo hb-service install --user homebridge &>/dev/null -msg_ok "Created Service" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/influxdb-install.sh b/setup/influxdb-install.sh deleted file mode 100644 index 216949e7..00000000 --- a/setup/influxdb-install.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y lsb-base &>/dev/null -apt-get install -y lsb-release &>/dev/null -apt-get install -y gnupg2 &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Setting up InfluxDB Repository" -wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add - &>/dev/null -echo "deb https://repos.influxdata.com/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/influxdb.list &>/dev/null -msg_ok "Set up InfluxDB Repository" - -msg_info "Installing InfluxDB" -apt-get update &>/dev/null -apt-get install -y influxdb &>/dev/null -msg_ok "Installed InfluxDB" - -msg_info "Installing Telegraf" -apt-get install -y telegraf &>/dev/null -msg_ok "Installed Telegraf" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/iobroker-install.sh b/setup/iobroker-install.sh deleted file mode 100644 index 9db4f6d3..00000000 --- a/setup/iobroker-install.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing ioBroker (10 min)" -curl -sLf https://iobroker.net/install.sh | bash - &>/dev/null -msg_ok "Installed ioBroker" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/jellyfin-install.sh b/setup/jellyfin-install.sh deleted file mode 100644 index dccddafe..00000000 --- a/setup/jellyfin-install.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y apt-transport-https &>/dev/null -apt-get install -y software-properties-common &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Setting Up Hardware Acceleration" -apt-get -y install \ - va-driver-all \ - ocl-icd-libopencl1 \ - beignet-opencl-icd &>/dev/null - -/bin/chgrp video /dev/dri -/bin/chmod 755 /dev/dri -/bin/chmod 660 /dev/dri/* -msg_ok "Set Up Hardware Acceleration" - -msg_info "Setting Up Jellyfin Repository" -sudo add-apt-repository universe -y &>/dev/null -wget -q -O - https://repo.jellyfin.org/ubuntu/jellyfin_team.gpg.key | sudo apt-key add - &>/dev/null -echo "deb [arch=$( dpkg --print-architecture )] https://repo.jellyfin.org/ubuntu $( lsb_release -c -s ) main" | sudo tee /etc/apt/sources.list.d/jellyfin.list &>/dev/null -msg_ok "Set Up Jellyfin Repository" - -msg_info "Installing Jellyfin" -apt-get update &>/dev/null -sudo apt install jellyfin-server -y &>/dev/null -apt install jellyfin-ffmpeg -y &>/dev/null -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" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -chmod -x /etc/update-motd.d/* -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/jellyfin_setup.sh b/setup/jellyfin_setup.sh deleted file mode 100644 index 0f7a2549..00000000 --- a/setup/jellyfin_setup.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -RETRY_NUM=10 -RETRY_EVERY=3 -NUM=$RETRY_NUM -trap 'die "Script interrupted."' INT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} - -echo -e "${CHECKMARK} \e[1;92m Setting up Container OS... \e[0m" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -e "${CROSS} \e[1;31m No Network: \e[0m $(date)" - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS} \e[1;31m No Network After $RETRY_NUM Tries \e[0m" - exit 1 - fi -done - echo -e "${CHECKMARK} \e[1;92m Network Connected: \e[0m $(hostname -I)" - -echo -e "${CHECKMARK} \e[1;92m Updating Container OS... \e[0m" -apt-get update &>/dev/null -apt-get -qqy upgrade &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Dependencies... \e[0m" - apt-get update &>/dev/null - apt-get -qqy install \ - curl \ - sudo &>/dev/null - sudo apt install apt-transport-https -y &>/dev/null - sudo apt-get install software-properties-common -y &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Setting Up Jellyfin Repository... \e[0m" -sudo add-apt-repository universe -y &>/dev/null -wget -q -O - https://repo.jellyfin.org/ubuntu/jellyfin_team.gpg.key | sudo apt-key add - &>/dev/null -echo "deb [arch=$( dpkg --print-architecture )] https://repo.jellyfin.org/ubuntu $( lsb_release -c -s ) main" | sudo tee /etc/apt/sources.list.d/jellyfin.list &>/dev/null -echo -e "${CHECKMARK} \e[1;92m Installing Jellyfin... \e[0m" -apt-get update &>/dev/null -sudo apt install jellyfin-server -y &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Creating Jellyfin Service... \e[0m" -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 ${JELLYFIN_WEB_OPT} ${JELLYFIN_RESTART_OPT} ${JELLYFIN_FFMPEG_OPT} ${JELL> -Restart = on-failure -TimeoutSec = 15 - -[Install] -WantedBy = multi-user.target -EOF - -ln -s /usr/share/jellyfin/web/ /usr/lib/jellyfin/bin/jellyfin-web - -echo -e "${CHECKMARK} \e[1;92m Customizing Container... \e[0m" -chmod -x /etc/update-motd.d/* -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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//') -echo -e "${CHECKMARK} \e[1;92m Cleanup... \e[0m" -rm -rf /jellyfin_setup.sh /var/{cache,log}/* /var/lib/apt/lists/* diff --git a/setup/keycloak-install.sh b/setup/keycloak-install.sh deleted file mode 100644 index b593459c..00000000 --- a/setup/keycloak-install.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y openjdk-11-jdk &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing Keycloak" -cd /opt -wget https://github.com/keycloak/keycloak/releases/download/18.0.0/keycloak-18.0.0.tar.gz &>/dev/null -tar -xvf keycloak-18.0.0.tar.gz &>/dev/null -mv keycloak-18.0.0 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 -systemctl enable --now keycloak.service &>/dev/null -msg_ok "Created Service" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -chmod -x /etc/update-motd.d/* -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/mariadb-install.sh b/setup/mariadb-install.sh deleted file mode 100644 index 18db68da..00000000 --- a/setup/mariadb-install.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing MariaDB" -curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | sudo bash &>/dev/null -apt-get update >/dev/null -apt-get install -y mariadb-server &>/dev/null -msg_ok "Installed MariaDB" - -msg_info "Installing Adminer" -sudo apt install adminer -y &>/dev/null -sudo a2enconf adminer &>/dev/null -sudo systemctl reload apache2 &>/dev/null -msg_ok "Installed Adminer" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -mkdir /var/log/apache2 -chmod 750 /var/log/apache2 -msg_ok "Cleaned" diff --git a/setup/mariadb_setup.sh b/setup/mariadb_setup.sh deleted file mode 100644 index b3d8b445..00000000 --- a/setup/mariadb_setup.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' -RD=`echo "\033[01;31m"` -BL=`echo "\033[36m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -RETRY_NUM=5 -RETRY_EVERY=3 -NUM=$RETRY_NUM -trap die ERR -trap 'die "Script interrupted."' INT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} - -echo -en "${GN} Setting up Container OS... " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -e "${CROSS}${RD} No Network! \r" - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -echo -e "${CM}${CL} \r" -echo -en "${GN} Network Connected: ${BL}$(hostname -I)${CL} " -echo -e "${CM}${CL} \r" - -echo -en "${GN} Updating Container OS... " -apt-get update &>/dev/null -apt-get -qqy upgrade &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Installing Dependencies... " -apt-get update &>/dev/null -apt-get -qqy install \ - curl \ - sudo &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Installing MariaDB... " -curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | sudo bash &>/dev/null -apt-get update >/dev/null -apt-get install -y mariadb-server &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Installing Adminer... " -sudo apt install adminer -y &>/dev/null -sudo a2enconf adminer &>/dev/null -sudo systemctl reload apache2 &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Customizing Container... " -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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//') -echo -e "${CM}${CL} \r" - -echo -en "${GN} Cleanup... " -rm -rf /mariadb_setup.sh /var/{cache,log}/* /var/lib/apt/lists/* -mkdir /var/log/apache2 -echo -e "${CM}${CL} \r" diff --git a/setup/meshcentral-install.sh b/setup/meshcentral-install.sh deleted file mode 100644 index 485b352f..00000000 --- a/setup/meshcentral-install.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -sudo curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - &>/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 MeshCentral" -mkdir /opt/meshcentral -cd /opt/meshcentral -npm install meshcentral &>/dev/null -node node_modules/meshcentral --install &>/dev/null -msg_ok "Installed MeshCentral" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/motioneye-install.sh b/setup/motioneye-install.sh deleted file mode 100644 index 4b96cc31..00000000 --- a/setup/motioneye-install.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y cifs-utils &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing Motion" - apt-get install motion -y &>/dev/null - systemctl stop motion &>/dev/null - systemctl disable motion &>/dev/null -msg_ok "Installed Motion" - -msg_info "Installing FFmpeg" - apt-get install ffmpeg v4l-utils -y &>/dev/null -msg_ok "Installed FFmpeg" - -msg_info "Installing Python" - apt-get update &>/dev/null - apt-get install python2 -y &>/dev/null - curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py &>/dev/null - python2 get-pip.py &>/dev/null - apt-get install libffi-dev libzbar-dev libzbar0 -y &>/dev/null - apt-get install python2-dev libssl-dev libcurl4-openssl-dev libjpeg-dev -y &>/dev/null - msg_ok "Installed Python" - -msg_info "Installing MotionEye" - apt-get update &>/dev/null - sudo pip install motioneye &>/dev/null - 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 &>/dev/null - systemctl enable motioneye &>/dev/null - systemctl start motioneye -msg_ok "Created Service" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/motioneye_setup.sh b/setup/motioneye_setup.sh deleted file mode 100644 index ee7a6301..00000000 --- a/setup/motioneye_setup.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -RETRY_NUM=5 -RETRY_EVERY=3 -NUM=$RETRY_NUM -trap die ERR -trap 'die "Script interrupted."' INT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} - -echo -e "${CHECKMARK} \e[1;92m Setting up Container OS... \e[0m" - sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen - locale-gen >/dev/null - while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -e "${CROSS} \e[1;31m No Network: \e[0m $(date)" - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS} \e[1;31m No Network After $RETRY_NUM Tries \e[0m" - exit 1 - fi - done -echo -e "${CHECKMARK} \e[1;92m Network Connected: \e[0m $(hostname -I)" - -echo -e "${CHECKMARK} \e[1;92m Updating Container OS... \e[0m" - apt-get update &>/dev/null - apt-get -qqy upgrade &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Dependencies... \e[0m" - apt-get update &>/dev/null - apt-get -qqy install \ - curl \ - sudo &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Motion... \e[0m" - apt-get install motion -y &>/dev/null - systemctl stop motion &>/dev/null - systemctl disable motion &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing FFmpeg... \e[0m" - apt-get install ffmpeg v4l-utils -y &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Python... \e[0m" - apt-get update &>/dev/null - apt-get install python2 -y &>/dev/null - curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py &>/dev/null - python2 get-pip.py &>/dev/null - apt-get install libffi-dev libzbar-dev libzbar0 -y &>/dev/null - apt-get install python2-dev libssl-dev libcurl4-openssl-dev libjpeg-dev -y &>/dev/null -echo -e "${CHECKMARK} \e[1;92m Installing MotionEye... \e[0m" - apt-get update &>/dev/null - sudo pip install motioneye &>/dev/null - mkdir -p /etc/motioneye - cp /usr/local/share/motioneye/extra/motioneye.conf.sample /etc/motioneye/motioneye.conf - mkdir -p /var/lib/motioneye - -echo -e "${CHECKMARK} \e[1;92m Creating Service file motioneye.service... \e[0m" - cp /usr/local/share/motioneye/extra/motioneye.systemd-unit-local /etc/systemd/system/motioneye.service &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Customizing Container... \e[0m" - rm /etc/motd - rm /etc/update-motd.d/10-uname - touch ~/.hushlogin - GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" - mkdir -p $(dirname $GETTY_OVERRIDE) - cat << EOF > $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//') - systemctl enable motioneye &>/dev/null - systemctl start motioneye - -echo -e "${CHECKMARK} \e[1;92m Cleanup... \e[0m" - rm -rf /motioneye_setup.sh /var/{cache,log}/* /var/lib/apt/lists/* diff --git a/setup/mqtt-install.sh b/setup/mqtt-install.sh deleted file mode 100644 index fd52f630..00000000 --- a/setup/mqtt-install.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y gnupg &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing Mosquitto MQTT Broker" -wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key &>/dev/null -apt-key add mosquitto-repo.gpg.key &>/dev/null -cd /etc/apt/sources.list.d/ -wget http://repo.mosquitto.org/debian/mosquitto-bullseye.list &>/dev/null -apt-get update >/dev/null -apt-get -y install mosquitto &>/dev/null -apt-get -y install mosquitto-clients &>/dev/null -msg_ok "Installed Mosquitto MQTT Broker" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/mqtt_setup.sh b/setup/mqtt_setup.sh deleted file mode 100644 index 13d42531..00000000 --- a/setup/mqtt_setup.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -RETRY_NUM=5 -RETRY_EVERY=3 -NUM=$RETRY_NUM -trap die ERR -trap 'die "Script interrupted."' INT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} - -echo -e "${CHECKMARK} \e[1;92m Setting up Container OS... \e[0m" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -e "${CROSS} \e[1;31m No Network: \e[0m $(date)" - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS} \e[1;31m No Network After $RETRY_NUM Tries \e[0m" - exit 1 - fi -done - echo -e "${CHECKMARK} \e[1;92m Network Connected: \e[0m $(hostname -I)" - -echo -e "${CHECKMARK} \e[1;92m Updating Container OS... \e[0m" -apt-get update &>/dev/null -apt-get -qqy upgrade &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Dependencies... \e[0m" -apt-get update &>/dev/null -apt-get -qqy install \ - curl \ - gnupg \ - sudo &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Mosquitto MQTT Broker.. \e[0m" -wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key &>/dev/null -apt-key add mosquitto-repo.gpg.key &>/dev/null -cd /etc/apt/sources.list.d/ -wget http://repo.mosquitto.org/debian/mosquitto-bullseye.list &>/dev/null -apt-get update >/dev/null -apt-get -y install mosquitto &>/dev/null -apt-get -y install mosquitto-clients &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Customizing LXC... \e[0m" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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//') - -echo -e "${CHECKMARK} \e[1;92m Cleanup... \e[0m" -rm -rf /mqtt_setup.sh /var/{cache,log}/* /var/lib/apt/lists/* diff --git a/setup/n8n-install.sh b/setup/n8n-install.sh deleted file mode 100644 index 09670422..00000000 --- a/setup/n8n-install.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -curl -sL https://deb.nodesource.com/setup_16.x | bash - &>/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 n8n (Patience)" -npm install --global n8n &>/dev/null -msg_ok "Installed n8n" - -msg_info "Creating Service" -cat <<EOF > /etc/systemd/system/n8n.service -[Unit] -Description=n8n - -[Service] -Type=simple -ExecStart=n8n start -[Install] -WantedBy=multi-user.target -EOF -sudo systemctl start n8n &>/dev/null -sudo systemctl enable n8n &>/dev/null -msg_ok "Created Service" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/nginx-proxy-manager-install.sh b/setup/nginx-proxy-manager-install.sh deleted file mode 100644 index afa87e32..00000000 --- a/setup/nginx-proxy-manager-install.sh +++ /dev/null @@ -1,254 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get update &>/dev/null -apt-get -y install \ - sudo \ - curl \ - gnupg \ - make \ - g++ \ - gcc \ - ca-certificates \ - apache2-utils \ - logrotate \ - build-essential \ - python3-dev \ - git \ - lsb-release &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing Python" - apt-get install -y -q --no-install-recommends python3 python3-pip python3-venv &>/dev/null - pip3 install --upgrade setuptools &>/dev/null - pip3 install --upgrade pip &>/dev/null - python3 -m venv /opt/certbot/ &>/dev/null - if [ "$(getconf LONG_BIT)" = "32" ]; then - python3 -m pip install --no-cache-dir -U cryptography==3.3.2 &>/dev/null - fi - python3 -m pip install --no-cache-dir cffi certbot &>/dev/null -msg_ok "Installed Python" - -msg_info "Installing Openresty" -wget -q -O - https://openresty.org/package/pubkey.gpg | apt-key add - &>/dev/null -codename=`grep -Po 'VERSION="[0-9]+ \(\K[^)]+' /etc/os-release` &>/dev/null -echo "deb http://openresty.org/package/debian $codename openresty" | tee /etc/apt/sources.list.d/openresty.list &>/dev/null -apt-get -y update &>/dev/null -apt-get -y install --no-install-recommends openresty &>/dev/null -msg_ok "Installed Openresty" - -msg_info "Setting up Node.js Repository" -curl -fsSL https://deb.nodesource.com/setup_16.x | bash - &>/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 Yarn" -npm install --global yarn &>/dev/null -msg_ok "Installed Yarn" - -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 "Downloading Nginx Proxy Manager 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 Nginx Proxy Manager 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 -en "${GN} Generating dummy SSL Certificate... " - 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 "Set up 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 "Creating Service" -cat << 'EOF' > /lib/systemd/system/npm.service -[Unit] -Description=Nginx Proxy Manager -After=network.target -Wants=openresty.service - -[Service] -Type=simple -Environment=NODE_ENV=production -ExecStartPre=-mkdir -p /tmp/nginx/body /data/letsencrypt-acme-challenge -ExecStart=/usr/bin/node index.js --abort_on_uncaught_exception --max_old_space_size=250 -WorkingDirectory=/app -Restart=on-failure - -[Install] -WantedBy=multi-user.target -EOF -msg_ok "Created Service" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Starting Services" -systemctl enable npm &>/dev/null -systemctl start openresty -systemctl start npm -msg_ok "Started Services" - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/nocodb-install.sh b/setup/nocodb-install.sh deleted file mode 100644 index 9e51d2e1..00000000 --- a/setup/nocodb-install.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y git &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -sudo curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - &>/dev/null -msg_ok "Set up Node.js Repository" - -msg_info "Installing Node.js" -sudo apt-get install -y nodejs git make g++ gcc &>/dev/null -msg_ok "Installed Node.js" - -msg_info "Installing NocoDB" -git clone https://github.com/nocodb/nocodb-seed &>/dev/null -mv nocodb-seed /opt/nocodb -cd /opt/nocodb -npm install &>/dev/null -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" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/node-red-install.sh b/setup/node-red-install.sh deleted file mode 100644 index 058fb297..00000000 --- a/setup/node-red-install.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing Node-Red" -bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --confirm-root --confirm-install --skip-pi &>/dev/nul -sudo systemctl enable nodered.service &>/dev/null -sudo systemctl start nodered.service &>/dev/null -msg_ok "Installed Node-Red" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/node-red_setup.sh b/setup/node-red_setup.sh deleted file mode 100644 index def5d877..00000000 --- a/setup/node-red_setup.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -RETRY_NUM=5 -RETRY_EVERY=3 -NUM=$RETRY_NUM -trap die ERR -trap 'die "Script interrupted."' INT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} - -echo -e "${CHECKMARK} \e[1;92m Setting up Container OS... \e[0m" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -e "${CROSS} \e[1;31m No Network: \e[0m $(date)" - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS} \e[1;31m No Network After $RETRY_NUM Tries \e[0m" - exit 1 - fi -done - echo -e "${CHECKMARK} \e[1;92m Network Connected: \e[0m $(hostname -I)" - -echo -e "${CHECKMARK} \e[1;92m Updating Container OS... \e[0m" -apt-get update &>/dev/null -apt-get -qqy upgrade &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Dependencies... \e[0m" -apt-get update &>/dev/null -apt-get -qqy install \ - curl \ - sudo &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Node-Red... \e[0m" -bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --confirm-root --confirm-install --skip-pi &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Customizing Container... \e[0m" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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//') -systemctl start nodered.service &>/dev/null -systemctl enable nodered.service &>/dev/null -echo -e "${CHECKMARK} \e[1;92m Cleanup... \e[0m" -rm -rf /node-red_setup.sh /var/{cache,log}/* /var/lib/apt/lists/* diff --git a/setup/npm_setup.sh b/setup/npm_setup.sh deleted file mode 100644 index c3917d44..00000000 --- a/setup/npm_setup.sh +++ /dev/null @@ -1,216 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -RETRY_NUM=5 -RETRY_EVERY=3 -NUM=$RETRY_NUM -trap die ERR -trap 'die "Script interrupted."' INT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} -echo -e "${CHECKMARK} \e[1;92m Setting up Container OS... \e[0m" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -e "${CROSS} \e[1;31m No Network: \e[0m $(date)" - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS} \e[1;31m No Network After $RETRY_NUM Tries \e[0m" - exit 1 - fi -done - echo -e "${CHECKMARK} \e[1;92m Network Connected: \e[0m $(hostname -I)" - -echo -e "${CHECKMARK} \e[1;92m Updating Container OS... \e[0m" -apt-get update &>/dev/null -apt-get -qqy upgrade &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Dependencies... \e[0m" -apt-get update &>/dev/null -apt-get -qqy install \ - sudo \ - curl \ - wget \ - gnupg \ - openssl \ - ca-certificates \ - apache2-utils \ - logrotate \ - build-essential \ - python3-dev \ - git \ - lsb-release &>/dev/null - - echo -e "${CHECKMARK} \e[1;92m Installing Python... \e[0m" - apt-get install -y -q --no-install-recommends python3 python3-pip python3-venv &>/dev/null - pip3 install --upgrade setuptools &>/dev/null - pip3 install --upgrade pip &>/dev/null - python3 -m venv /opt/certbot/ &>/dev/null - if [ "$(getconf LONG_BIT)" = "32" ]; then - python3 -m pip install --no-cache-dir -U cryptography==3.3.2 &>/dev/null - fi - python3 -m pip install --no-cache-dir cffi certbot &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Openresty... \e[0m" -wget -q -O - https://openresty.org/package/pubkey.gpg | apt-key add - &>/dev/null -codename=`grep -Po 'VERSION="[0-9]+ \(\K[^)]+' /etc/os-release` &>/dev/null -echo "deb http://openresty.org/package/debian $codename openresty" | tee /etc/apt/sources.list.d/openresty.list &>/dev/null -apt-get -y update &>/dev/null -apt-get -y install --no-install-recommends openresty &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Setting up Node.js Repository... \e[0m" -sudo curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Node.js... \e[0m" -sudo apt-get install -y nodejs git make g++ gcc &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Yarn... \e[0m" -npm install --global yarn &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Downloading NPM v2.9.16... \e[0m" -wget -q https://codeload.github.com/NginxProxyManager/nginx-proxy-manager/tar.gz/v2.9.16 -O - | tar -xz &>/dev/null -cd ./nginx-proxy-manager-2.9.16 - -echo -e "${CHECKMARK} \e[1;92m Setting up Enviroment... \e[0m" -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+#v2.9.16+g" backend/package.json -sed -i "s+0.0.0+#v2.9.16+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 - -echo -e "${CHECKMARK} \e[1;92m Building Frontend... \e[0m" -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 - -echo -e "${CHECKMARK} \e[1;92m Initializing Backend... \e[0m" -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 - -echo -e "${CHECKMARK} \e[1;92m Creating NPM Service... \e[0m" -cat << 'EOF' > /lib/systemd/system/npm.service -[Unit] -Description=Nginx Proxy Manager -After=network.target -Wants=openresty.service - -[Service] -Type=simple -Environment=NODE_ENV=production -ExecStartPre=-mkdir -p /tmp/nginx/body /data/letsencrypt-acme-challenge -ExecStart=/usr/bin/node index.js --abort_on_uncaught_exception --max_old_space_size=250 -WorkingDirectory=/app -Restart=on-failure - -[Install] -WantedBy=multi-user.target -EOF - -echo -e "${CHECKMARK} \e[1;92m Customizing Container... \e[0m" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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//') - -echo -e "${CHECKMARK} \e[1;92m Starting Services... \e[0m" -systemctl enable npm &>/dev/null -systemctl start openresty -systemctl start npm - -echo -e "${CHECKMARK} \e[1;92m Cleanup... \e[0m" -rm -rf /npm_setup.sh /var/{cache,log}/* /var/lib/apt/lists/* diff --git a/setup/omada-install.sh b/setup/omada-install.sh deleted file mode 100644 index 598dabde..00000000 --- a/setup/omada-install.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS (216 packages)" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get -y install curl &>/dev/null -apt-get -y install sudo &>/dev/null -apt-get -y install gnupg &>/dev/null -apt-get -y install openjdk-8-jre-headless &>/dev/null -apt-get -y install jsvc &>/dev/null -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 -sudo dpkg -i mongodb-org-server_3.6.23_amd64.deb &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing Omada Controller" -wget -qL https://static.tp-link.com/upload/software/2022/202205/20220507/Omada_SDN_Controller_v5.3.1_Linux_x64.deb -sudo dpkg -i Omada_SDN_Controller_v5.3.1_Linux_x64.deb &>/dev/null -msg_ok "Installed Omada Controller" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -chmod -x /etc/update-motd.d/* -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/openhab-install.sh b/setup/openhab-install.sh deleted file mode 100644 index c4e69e18..00000000 --- a/setup/openhab-install.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y gnupg &>/dev/null -apt-get install -y apt-transport-https &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing Azul Zulu" -apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xB1998361219BD9C9 &>/dev/null -curl -O https://cdn.azul.com/zulu/bin/zulu-repo_1.0.0-3_all.deb &>/dev/null -apt-get install ./zulu-repo_1.0.0-3_all.deb &>/dev/null -apt-get update &>/dev/null -apt-get -y install zulu11-jdk &>/dev/null -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 -echo 'deb [signed-by=/usr/share/keyrings/openhab.gpg] https://openhab.jfrog.io/artifactory/openhab-linuxpkg stable main' | tee /etc/apt/sources.list.d/openhab.list &>/dev/null -apt update &>/dev/null -apt-get -y install openhab &>/dev/null -systemctl daemon-reload -systemctl enable openhab.service &>/dev/null -systemctl start openhab.service -msg_ok "Installed openHAB" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -chmod -x /etc/update-motd.d/* -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/photoprism-install.sh b/setup/photoprism-install.sh deleted file mode 100644 index 20fa12c9..00000000 --- a/setup/photoprism-install.sh +++ /dev/null @@ -1,182 +0,0 @@ -#!/usr/bin/env bash -AVX=$(grep -o -m1 'avx[^ ]*' /proc/cpuinfo) -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y gcc &>/dev/null -apt-get install -y g++ &>/dev/null -apt-get install -y git &>/dev/null -apt-get install -y gnupg &>/dev/null -apt-get install -y make &>/dev/null -apt-get install -y zip &>/dev/null -apt-get install -y unzip &>/dev/null -apt-get install -y exiftool &>/dev/null -apt-get install -y ffmpeg &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -sudo curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - &>/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 Golang" -wget https://golang.org/dl/go1.18.3.linux-amd64.tar.gz &>/dev/null -tar -xzf go1.18.3.linux-amd64.tar.gz -C /usr/local &>/dev/null -ln -s /usr/local/go/bin/go /usr/local/bin/go &>/dev/null -go install github.com/tianon/gosu@latest &>/dev/null -go install golang.org/x/tools/cmd/goimports@latest &>/dev/null -go install github.com/psampaz/go-mod-outdated@latest &>/dev/null -go install github.com/dsoprea/go-exif/v3/command/exif-read-tool@latest &>/dev/null -go install github.com/mikefarah/yq/v4@latest &>/dev/null -go install github.com/kyoh86/richgo@latest &>/dev/null -cp /root/go/bin/* /usr/local/go/bin/ -cp /usr/local/go/bin/richgo /usr/local/bin/richgo -cp /usr/local/go/bin/gosu /usr/local/sbin/gosu -chown root:root /usr/local/sbin/gosu -chmod 755 /usr/local/sbin/gosu -msg_ok "Installed Golang" - -msg_info "Installing Tensorflow" -if [[ "$AVX" =~ avx2 ]]; then - wget https://dl.photoprism.org/tensorflow/linux/libtensorflow-linux-avx2-1.15.2.tar.gz &>/dev/null - tar -C /usr/local -xzf libtensorflow-linux-avx2-1.15.2.tar.gz &>/dev/null - elif [[ "$AVX" =~ avx ]]; then - wget https://dl.photoprism.org/tensorflow/linux/libtensorflow-linux-avx-1.15.2.tar.gz &>/dev/null - tar -C /usr/local -xzf libtensorflow-linux-avx-1.15.2.tar.gz &>/dev/null - else - wget https://dl.photoprism.org/tensorflow/linux/libtensorflow-linux-cpu-1.15.2.tar.gz &>/dev/null - tar -C /usr/local -xzf libtensorflow-linux-cpu-1.15.2.tar.gz &>/dev/null -fi -ldconfig &>/dev/null -msg_ok "Installed Tensorflow" - -msg_info "Cloning PhotoPrism" -mkdir -p /opt/photoprism/bin -mkdir -p /var/lib/photoprism/storage -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" -NODE_OPTIONS=--max_old_space_size=2048 make all &>/dev/null -./scripts/build.sh prod /opt/photoprism/bin/photoprism &>/dev/null -cp -a assets/ /opt/photoprism/assets/ &>/dev/null -msg_ok "Built PhotoPrism" - -env_path="/var/lib/photoprism/.env" -echo " -PHOTOPRISM_ADMIN_PASSWORD='admin' -PHOTOPRISM_HTTP_HOST='0.0.0.0' -PHOTOPRISM_HTTP_PORT=2342 -PHOTOPRISM_STORAGE_PATH='/var/lib/photoprism/storage' -PHOTOPRISM_ORIGINALS_PATH='/var/lib/photoprism/photos/Originals' -PHOTOPRISM_IMPORT_PATH='/var/lib/photoprism/photos/Import' -" > $env_path - -msg_info "Creating Service" -service_path="/etc/systemd/system/photoprism.service" - -echo "[Unit] -Description=PhotoPrism service -After=network.target - -[Service] -Type=forking -User=root -WorkingDirectory=/opt/photoprism -EnvironmentFile=/var/lib/photoprism/.env -ExecStart=/opt/photoprism/bin/photoprism up -d -ExecStop=/opt/photoprism/bin/photoprism down - -[Install] -WantedBy=multi-user.target" > $service_path -systemctl enable --now photoprism &>/dev/null -msg_ok "Created Service" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/pihole-install.sh b/setup/pihole-install.sh deleted file mode 100644 index 0a47cc07..00000000 --- a/setup/pihole-install.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt-get update &>/dev/null -apt-get -y dist-upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y ufw &>/dev/null -apt-get install -y ntp &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing Pi-hole" -wget -O tteck-install.sh https://install.pi-hole.net &>/dev/null -bash tteck-install.sh -msg_ok "Installed Pi-hole" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* /root/tteck-install.sh -msg_ok "Cleaned" diff --git a/setup/pihole_setup.sh b/setup/pihole_setup.sh deleted file mode 100644 index d6d7eb4e..00000000 --- a/setup/pihole_setup.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -RETRY_NUM=5 -RETRY_EVERY=3 -NUM=$RETRY_NUM -trap die ERR -trap 'die "Script interrupted."' INT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} - -echo -e "${CHECKMARK} \e[1;92m Setting up LXC OS... \e[0m" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -e "${CROSS} \e[1;31m No Network: \e[0m $(date)" - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS} \e[1;31m No Network After $RETRY_NUM Tries \e[0m" - exit 1 - fi -done - echo -e "${CHECKMARK} \e[1;92m Network Connected: \e[0m $(hostname -I)" - -echo -e "${CHECKMARK} \e[1;92m Updating Container OS... \e[0m" -apt-get update &>/dev/null -apt-get -qqy upgrade &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Dependencies... \e[0m" -apt-get update &>/dev/null -apt-get -qqy install \ - curl \ - sudo &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Pi-hole... \e[0m" -curl -sSL https://install.pi-hole.net | bash - -echo -e "${CHECKMARK} \e[1;92m Customizing LXC... \e[0m" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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//') - -echo -e "${CHECKMARK} \e[1;92m Cleanup... \e[0m" -rm -rf /pihole_setup.sh /var/{cache,log}/* /var/lib/apt/lists/* diff --git a/setup/plex-install.sh b/setup/plex-install.sh deleted file mode 100644 index c5030bc2..00000000 --- a/setup/plex-install.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y gnupg &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Setting Up Hardware Acceleration" -apt-get -y install \ - va-driver-all \ - ocl-icd-libopencl1 \ - beignet-opencl-icd &>/dev/null - -/bin/chgrp video /dev/dri -/bin/chmod 755 /dev/dri -/bin/chmod 660 /dev/dri/* -msg_ok "Set Up Hardware Acceleration" - -msg_info "Setting Up Plex Media Server Repository" -wget -q https://downloads.plex.tv/plex-keys/PlexSign.key -O - | sudo apt-key add - &>/dev/null -echo "deb [arch=$( dpkg --print-architecture )] https://downloads.plex.tv/repo/deb/ public main" | tee /etc/apt/sources.list.d/plexmediaserver.list &>/dev/null -msg_ok "Set Up Plex Media Server Repository" - -msg_info "Installing Plex Media Server" -apt-get update &>/dev/null -apt-get -o Dpkg::Options::="--force-confold" install -y plexmediaserver &>/dev/null -msg_ok "Installed Plex Media Server" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -chmod -x /etc/update-motd.d/* -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" - diff --git a/setup/plex_setup.sh b/setup/plex_setup.sh deleted file mode 100644 index 8d10d71a..00000000 --- a/setup/plex_setup.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -RETRY_NUM=10 -RETRY_EVERY=3 -NUM=$RETRY_NUM -trap die ERR -trap 'die "Script interrupted."' INT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} - -echo -e "${CHECKMARK} \e[1;92m Setting up Container OS... \e[0m" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -e "${CROSS} \e[1;31m No Network: \e[0m $(date)" - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS} \e[1;31m No Network After $RETRY_NUM Tries \e[0m" - exit 1 - fi -done - echo -e "${CHECKMARK} \e[1;92m Network Connected: \e[0m $(hostname -I)" - -echo -e "${CHECKMARK} \e[1;92m Updating Container OS... \e[0m" -apt-get update &>/dev/null -apt-get -qqy upgrade &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Dependencies... \e[0m" -apt-get update &>/dev/null -apt-get -qqy install \ - curl \ - sudo \ - gnupg &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Setting Up Hardware Acceleration... \e[0m" -apt-get -y install \ - va-driver-all \ - ocl-icd-libopencl1 \ - beignet-opencl-icd &>/dev/null - -/bin/chgrp video /dev/dri -/bin/chmod 755 /dev/dri -/bin/chmod 660 /dev/dri/* - -echo -e "${CHECKMARK} \e[1;92m Setting Up Plex Media Server Repository... \e[0m" -wget -q https://downloads.plex.tv/plex-keys/PlexSign.key -O - | sudo apt-key add - &>/dev/null -echo "deb [arch=$( dpkg --print-architecture )] https://downloads.plex.tv/repo/deb/ public main" | tee /etc/apt/sources.list.d/plexmediaserver.list &>/dev/null -echo -e "${CHECKMARK} \e[1;92m Installing Plex Media Server... \e[0m" -apt-get update &>/dev/null -apt-get -o Dpkg::Options::="--force-confold" install -y plexmediaserver &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Customizing Container... \e[0m" -chmod -x /etc/update-motd.d/* -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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//') -echo -e "${CHECKMARK} \e[1;92m Cleanup... \e[0m" -rm -rf /plex_setup.sh /var/{cache,log}/* /var/lib/apt/lists/* diff --git a/setup/podman-homeassistant-install.sh b/setup/podman-homeassistant-install.sh deleted file mode 100644 index 43fd53b9..00000000 --- a/setup/podman-homeassistant-install.sh +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y runc &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing Podman" -apt-get -y install podman &>/dev/null -msg_ok "Installed Podman" - -msg_info "Pulling Yacht Image" -podman pull docker.io/selfhostedpro/yacht:latest &>/dev/null -msg_ok "Pulled Yacht Image" - -msg_info "Installing Yacht" -podman volume create yacht >/dev/null -podman run -d \ - --privileged \ - --name yacht \ - --restart always \ - -v /var/run/podman/podman.sock:/var/run/docker.sock \ - -v yacht:/config \ - -v /etc/localtime:/etc/localtime:ro \ - -v /etc/timezone:/etc/timezone:ro \ - -p 8000:8000 \ - selfhostedpro/yacht:latest &>/dev/null -msg_ok "Installed Yacht" - -msg_info "Pulling Home Assistant Image" -podman pull docker.io/homeassistant/home-assistant:stable &>/dev/null -msg_ok "Pulled Home Assistant Image" - -msg_info "Installing Home Assistant" -podman volume create hass_config >/dev/null -podman run -d \ - --privileged \ - --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 &>/dev/null -msg_ok "Installed Home Assistant" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -podman generate systemd \ - --new --name homeassistant \ - > /etc/systemd/system/homeassistant.service -systemctl enable homeassistant &>/dev/null - -podman generate systemd \ - --new --name yacht \ - > /etc/systemd/system/yacht.service -systemctl enable yacht &>/dev/null - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/podman_ha_setup.sh b/setup/podman_ha_setup.sh deleted file mode 100644 index 8cc8d414..00000000 --- a/setup/podman_ha_setup.sh +++ /dev/null @@ -1,157 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap 'die "Script interrupted."' INT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} - -CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' -RD=`echo "\033[01;31m"` -BL=`echo "\033[36m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -RETRY_NUM=10 -RETRY_EVERY=3 -NUM=$RETRY_NUM - -echo -en "${GN} Setting up Container OS... " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -echo -e "${CM}${CL} \r" -echo -en "${GN} Network Connected: ${BL}$(hostname -I)${CL} " -echo -e "${CM}${CL} \r" - -echo -en "${GN} Updating Container OS... " -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Installing Dependencies... " -apt-get update &>/dev/null -apt-get -qqy install \ - curl \ - sudo \ - runc &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Installing Podman... " -apt-get -y install podman &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Pulling Yacht Image... " -podman pull docker.io/selfhostedpro/yacht:latest &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Installing Yacht... " -podman volume create yacht >/dev/null -podman run -d \ - --privileged \ - --name yacht \ - --restart always \ - -v /var/run/podman/podman.sock:/var/run/docker.sock \ - -v yacht:/config \ - -v /etc/localtime:/etc/localtime:ro \ - -v /etc/timezone:/etc/timezone:ro \ - -p 8000:8000 \ - selfhostedpro/yacht:latest &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Pulling Home Assistant Image... " -podman pull docker.io/homeassistant/home-assistant:stable &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Installing Home Assistant... " -podman volume create hass_config >/dev/null -podman run -d \ - --privileged \ - --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 &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Creating Update Script... " -file_path="/root/update.sh" -echo "#!/bin/bash -echo -e '\e[1;33m Pulling New Stable Version... \e[0m' -podman pull docker.io/homeassistant/home-assistant:stable -echo -e '\e[1;33m Stopping Home Assistant... \e[0m' -podman stop homeassistant -echo -e '\e[1;33m Removing Home Assistant... \e[0m' -podman rm homeassistant -echo -e '\e[1;33m Starting Home Assistant... \e[0m' -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 -echo -e '\e[1;33m Removing Old Image... \e[0m' -podman image prune -f -echo -e '\e[1;33m Finished Update! \e[0m'" > $file_path -sudo chmod +x /root/update.sh -echo -e "${CM}${CL} \r" - -echo -en "${GN} Customizing LXC... " -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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//') - -podman generate systemd \ - --new --name homeassistant \ - > /etc/systemd/system/homeassistant.service -systemctl enable homeassistant &>/dev/null - -podman generate systemd \ - --new --name yacht \ - > /etc/systemd/system/yacht.service -systemctl enable yacht &>/dev/null -echo -e "${CM}${CL} \r" - -echo -en "${GN} Cleanup... " -rm -rf /podman_ha_setup.sh /var/{cache,log}/* /var/lib/apt/lists/* -echo -e "${CM}${CL} \n" diff --git a/setup/postgresql-install.sh b/setup/postgresql-install.sh deleted file mode 100644 index c9cc2a7b..00000000 --- a/setup/postgresql-install.sh +++ /dev/null @@ -1,994 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt-get update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y gnupg2 &>/dev/null -apt-get install -y lsb-release &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Setting up PostgreSQL Repository" -sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' &>/dev/null -wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - &>/dev/null -msg_ok "Setup PostgreSQL Repository" - -msg_info "Installing PostgreSQL" -apt-get update &>/dev/null -apt-get install -y postgresql &>/dev/null - -cat <<EOF > /etc/postgresql/14/main/pg_hba.conf -# PostgreSQL Client Authentication Configuration File -# =================================================== -# -# Refer to the "Client Authentication" section in the PostgreSQL -# documentation for a complete description of this file. A short -# synopsis follows. -# -# This file controls: which hosts are allowed to connect, how clients -# are authenticated, which PostgreSQL user names they can use, which -# databases they can access. Records take one of these forms: -# -# local DATABASE USER METHOD [OPTIONS] -# host DATABASE USER ADDRESS METHOD [OPTIONS] -# hostssl DATABASE USER ADDRESS METHOD [OPTIONS] -# hostnossl DATABASE USER ADDRESS METHOD [OPTIONS] -# hostgssenc DATABASE USER ADDRESS METHOD [OPTIONS] -# hostnogssenc DATABASE USER ADDRESS METHOD [OPTIONS] -# -# (The uppercase items must be replaced by actual values.) -# -# The first field is the connection type: "local" is a Unix-domain -# socket, "host" is either a plain or SSL-encrypted TCP/IP socket, -# "hostssl" is an SSL-encrypted TCP/IP socket, and "hostnossl" is a -# non-SSL TCP/IP socket. Similarly, "hostgssenc" uses a -# GSSAPI-encrypted TCP/IP socket, while "hostnogssenc" uses a -# non-GSSAPI socket. -# -# DATABASE can be "all", "sameuser", "samerole", "replication", a -# database name, or a comma-separated list thereof. The "all" -# keyword does not match "replication". Access to replication -# must be enabled in a separate record (see example below). -# -# USER can be "all", a user name, a group name prefixed with "+", or a -# comma-separated list thereof. In both the DATABASE and USER fields -# you can also write a file name prefixed with "@" to include names -# from a separate file. -# -# ADDRESS specifies the set of hosts the record matches. It can be a -# host name, or it is made up of an IP address and a CIDR mask that is -# an integer (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that -# specifies the number of significant bits in the mask. A host name -# that starts with a dot (.) matches a suffix of the actual host name. -# Alternatively, you can write an IP address and netmask in separate -# columns to specify the set of hosts. Instead of a CIDR-address, you -# can write "samehost" to match any of the server's own IP addresses, -# or "samenet" to match any address in any subnet that the server is -# directly connected to. -# -# METHOD can be "trust", "reject", "md5", "password", "scram-sha-256", -# "gss", "sspi", "ident", "peer", "pam", "ldap", "radius" or "cert". -# Note that "password" sends passwords in clear text; "md5" or -# "scram-sha-256" are preferred since they send encrypted passwords. -# -# OPTIONS are a set of options for the authentication in the format -# NAME=VALUE. The available options depend on the different -# authentication methods -- refer to the "Client Authentication" -# section in the documentation for a list of which options are -# available for which authentication methods. -# -# Database and user names containing spaces, commas, quotes and other -# special characters must be quoted. Quoting one of the keywords -# "all", "sameuser", "samerole" or "replication" makes the name lose -# its special character, and just match a database or username with -# that name. -# -# This file is read on server startup and when the server receives a -# SIGHUP signal. If you edit the file on a running system, you have to -# SIGHUP the server for the changes to take effect, run "pg_ctl reload", -# or execute "SELECT pg_reload_conf()". -# -# Put your actual configuration here -# ---------------------------------- -# -# If you want to allow non-local connections, you need to add more -# "host" records. In that case you will also need to make PostgreSQL -# listen on a non-local interface via the listen_addresses -# configuration parameter, or via the -i or -h command line switches. - - - - -# DO NOT DISABLE! -# If you change this first entry you will need to make sure that the -# database superuser can access the database using some other method. -# Noninteractive access to all databases is required during automatic -# maintenance (custom daily cronjobs, replication, and similar tasks). -# -# Database administrative login by Unix domain socket -local all postgres trust -# TYPE DATABASE USER ADDRESS METHOD - -# "local" is for Unix domain socket connections only -local all all trust -# IPv4 local connections: -host all all 127.0.0.1/32 scram-sha-256 -host all all 0.0.0.0/24 md5 -# IPv6 local connections: -host all all ::1/128 scram-sha-256 -host all all 0.0.0.0/0 md5 -EOF - -cat <<EOF > /etc/postgresql/14/main/postgresql.conf -# ----------------------------- -# PostgreSQL configuration file -# ----------------------------- -# -# This file consists of lines of the form: -# -# name = value -# -# (The "=" is optional.) Whitespace may be used. Comments are introduced with -# "#" anywhere on a line. The complete list of parameter names and allowed -# values can be found in the PostgreSQL documentation. -# -# The commented-out settings shown in this file represent the default values. -# Re-commenting a setting is NOT sufficient to revert it to the default value; -# you need to reload the server. -# -# This file is read on server startup and when the server receives a SIGHUP -# signal. If you edit the file on a running system, you have to SIGHUP the -# server for the changes to take effect, run "pg_ctl reload", or execute -# "SELECT pg_reload_conf()". Some parameters, which are marked below, -# require a server shutdown and restart to take effect. -# -# Any parameter can also be given as a command-line option to the server, e.g., -# "postgres -c log_connections=on". Some parameters can be changed at run time -# with the "SET" SQL command. -# -# Memory units: B = bytes Time units: us = microseconds -# kB = kilobytes ms = milliseconds -# MB = megabytes s = seconds -# GB = gigabytes min = minutes -# TB = terabytes h = hours -# d = days - - -#------------------------------------------------------------------------------ -# FILE LOCATIONS -#------------------------------------------------------------------------------ - -# The default values of these variables are driven from the -D command-line -# option or PGDATA environment variable, represented here as ConfigDir. - -data_directory = '/var/lib/postgresql/14/main' # use data in another directory - # (change requires restart) -hba_file = '/etc/postgresql/14/main/pg_hba.conf' # host-based authentication file - # (change requires restart) -ident_file = '/etc/postgresql/14/main/pg_ident.conf' # ident configuration file - # (change requires restart) - -# If external_pid_file is not explicitly set, no extra PID file is written. -external_pid_file = '/var/run/postgresql/14-main.pid' # write an extra PID file - # (change requires restart) - - -#------------------------------------------------------------------------------ -# CONNECTIONS AND AUTHENTICATION -#------------------------------------------------------------------------------ - -# - Connection Settings - - -listen_addresses = '*' # what IP address(es) to listen on; - # comma-separated list of addresses; - # defaults to 'localhost'; use '*' for all - # (change requires restart) -port = 5432 # (change requires restart) -max_connections = 100 # (change requires restart) -#superuser_reserved_connections = 3 # (change requires restart) -unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories - # (change requires restart) -#unix_socket_group = '' # (change requires restart) -#unix_socket_permissions = 0777 # begin with 0 to use octal notation - # (change requires restart) -#bonjour = off # advertise server via Bonjour - # (change requires restart) -#bonjour_name = '' # defaults to the computer name - # (change requires restart) - -# - TCP settings - -# see "man tcp" for details - -#tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds; - # 0 selects the system default -#tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds; - # 0 selects the system default -#tcp_keepalives_count = 0 # TCP_KEEPCNT; - # 0 selects the system default -#tcp_user_timeout = 0 # TCP_USER_TIMEOUT, in milliseconds; - # 0 selects the system default - -# - Authentication - - -#authentication_timeout = 1min # 1s-600s -#password_encryption = md5 # md5 or scram-sha-256 -#db_user_namespace = off - -# GSSAPI using Kerberos -#krb_caseins_users = off - -# - SSL - - -#ssl = on -#ssl_ca_file = '' -#ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem' -#ssl_crl_file = '' -#ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key' -#ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers -#ssl_prefer_server_ciphers = on -#ssl_ecdh_curve = 'prime256v1' -#ssl_min_protocol_version = 'TLSv1.2' -#ssl_max_protocol_version = '' -#ssl_dh_params_file = '' -#ssl_passphrase_command = '' -#ssl_passphrase_command_supports_reload = off - - -#------------------------------------------------------------------------------ -# RESOURCE USAGE (except WAL) -#------------------------------------------------------------------------------ - -# - Memory - - -shared_buffers = 128MB # min 128kB - # (change requires restart) -#huge_pages = try # on, off, or try - # (change requires restart) -#temp_buffers = 8MB # min 800kB -#max_prepared_transactions = 0 # zero disables the feature - # (change requires restart) -# Caution: it is not advisable to set max_prepared_transactions nonzero unless -# you actively intend to use prepared transactions. -#work_mem = 4MB # min 64kB -#hash_mem_multiplier = 1.0 # 1-1000.0 multiplier on hash table work_mem -#maintenance_work_mem = 64MB # min 1MB -#autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem -#logical_decoding_work_mem = 64MB # min 64kB -#max_stack_depth = 2MB # min 100kB -#shared_memory_type = mmap # the default is the first option - # supported by the operating system: - # mmap - # sysv - # windows - # (change requires restart) -dynamic_shared_memory_type = posix # the default is the first option - # supported by the operating system: - # posix - # sysv - # windows - # mmap - # (change requires restart) - -# - Disk - - -#temp_file_limit = -1 # limits per-process temp file space - # in kilobytes, or -1 for no limit - -# - Kernel Resources - - -#max_files_per_process = 1000 # min 64 - # (change requires restart) - -# - Cost-Based Vacuum Delay - - -#vacuum_cost_delay = 0 # 0-100 milliseconds (0 disables) -#vacuum_cost_page_hit = 1 # 0-10000 credits -#vacuum_cost_page_miss = 10 # 0-10000 credits -#vacuum_cost_page_dirty = 20 # 0-10000 credits -#vacuum_cost_limit = 200 # 1-10000 credits - -# - Background Writer - - -#bgwriter_delay = 200ms # 10-10000ms between rounds -#bgwriter_lru_maxpages = 100 # max buffers written/round, 0 disables -#bgwriter_lru_multiplier = 2.0 # 0-10.0 multiplier on buffers scanned/round -#bgwriter_flush_after = 512kB # measured in pages, 0 disables - -# - Asynchronous Behavior - - -#effective_io_concurrency = 1 # 1-1000; 0 disables prefetching -#maintenance_io_concurrency = 10 # 1-1000; 0 disables prefetching -#max_worker_processes = 8 # (change requires restart) -#max_parallel_maintenance_workers = 2 # taken from max_parallel_workers -#max_parallel_workers_per_gather = 2 # taken from max_parallel_workers -#parallel_leader_participation = on -#max_parallel_workers = 8 # maximum number of max_worker_processes that - # can be used in parallel operations -#old_snapshot_threshold = -1 # 1min-60d; -1 disables; 0 is immediate - # (change requires restart) -#backend_flush_after = 0 # measured in pages, 0 disables - - -#------------------------------------------------------------------------------ -# WRITE-AHEAD LOG -#------------------------------------------------------------------------------ - -# - Settings - - -#wal_level = replica # minimal, replica, or logical - # (change requires restart) -#fsync = on # flush data to disk for crash safety - # (turning this off can cause - # unrecoverable data corruption) -#synchronous_commit = on # synchronization level; - # off, local, remote_write, remote_apply, or on -#wal_sync_method = fsync # the default is the first option - # supported by the operating system: - # open_datasync - # fdatasync (default on Linux and FreeBSD) - # fsync - # fsync_writethrough - # open_sync -#full_page_writes = on # recover from partial page writes -#wal_compression = off # enable compression of full-page writes -#wal_log_hints = off # also do full page writes of non-critical updates - # (change requires restart) -#wal_init_zero = on # zero-fill new WAL files -#wal_recycle = on # recycle WAL files -#wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers - # (change requires restart) -#wal_writer_delay = 200ms # 1-10000 milliseconds -#wal_writer_flush_after = 1MB # measured in pages, 0 disables -#wal_skip_threshold = 2MB - -#commit_delay = 0 # range 0-100000, in microseconds -#commit_siblings = 5 # range 1-1000 - -# - Checkpoints - - -#checkpoint_timeout = 5min # range 30s-1d -max_wal_size = 1GB -min_wal_size = 80MB -#checkpoint_completion_target = 0.5 # checkpoint target duration, 0.0 - 1.0 -#checkpoint_flush_after = 256kB # measured in pages, 0 disables -#checkpoint_warning = 30s # 0 disables - -# - Archiving - - -#archive_mode = off # enables archiving; off, on, or always - # (change requires restart) -#archive_command = '' # command to use to archive a logfile segment - # placeholders: %p = path of file to archive - # %f = file name only - # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' -#archive_timeout = 0 # force a logfile segment switch after this - # number of seconds; 0 disables - -# - Archive Recovery - - -# These are only used in recovery mode. - -#restore_command = '' # command to use to restore an archived logfile segment - # placeholders: %p = path of file to restore - # %f = file name only - # e.g. 'cp /mnt/server/archivedir/%f %p' - # (change requires restart) -#archive_cleanup_command = '' # command to execute at every restartpoint -#recovery_end_command = '' # command to execute at completion of recovery - -# - Recovery Target - - -# Set these only when performing a targeted recovery. - -#recovery_target = '' # 'immediate' to end recovery as soon as a - # consistent state is reached - # (change requires restart) -#recovery_target_name = '' # the named restore point to which recovery will proceed - # (change requires restart) -#recovery_target_time = '' # the time stamp up to which recovery will proceed - # (change requires restart) -#recovery_target_xid = '' # the transaction ID up to which recovery will proceed - # (change requires restart) -#recovery_target_lsn = '' # the WAL LSN up to which recovery will proceed - # (change requires restart) -#recovery_target_inclusive = on # Specifies whether to stop: - # just after the specified recovery target (on) - # just before the recovery target (off) - # (change requires restart) -#recovery_target_timeline = 'latest' # 'current', 'latest', or timeline ID - # (change requires restart) -#recovery_target_action = 'pause' # 'pause', 'promote', 'shutdown' - # (change requires restart) - - -#------------------------------------------------------------------------------ -# REPLICATION -#------------------------------------------------------------------------------ - -# - Sending Servers - - -# Set these on the master and on any standby that will send replication data. - -#max_wal_senders = 10 # max number of walsender processes - # (change requires restart) -#wal_keep_size = 0 # in megabytes; 0 disables -#max_slot_wal_keep_size = -1 # in megabytes; -1 disables -#wal_sender_timeout = 60s # in milliseconds; 0 disables - -#max_replication_slots = 10 # max number of replication slots - # (change requires restart) -#track_commit_timestamp = off # collect timestamp of transaction commit - # (change requires restart) - -# - Master Server - - -# These settings are ignored on a standby server. - -#synchronous_standby_names = '' # standby servers that provide sync rep - # method to choose sync standbys, number of sync standbys, - # and comma-separated list of application_name - # from standby(s); '*' = all -#vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed - -# - Standby Servers - - -# These settings are ignored on a master server. - -#primary_conninfo = '' # connection string to sending server -#primary_slot_name = '' # replication slot on sending server -#promote_trigger_file = '' # file name whose presence ends recovery -#hot_standby = on # "off" disallows queries during recovery - # (change requires restart) -#max_standby_archive_delay = 30s # max delay before canceling queries - # when reading WAL from archive; - # -1 allows indefinite delay -#max_standby_streaming_delay = 30s # max delay before canceling queries - # when reading streaming WAL; - # -1 allows indefinite delay -#wal_receiver_create_temp_slot = off # create temp slot if primary_slot_name - # is not set -#wal_receiver_status_interval = 10s # send replies at least this often - # 0 disables -#hot_standby_feedback = off # send info from standby to prevent - # query conflicts -#wal_receiver_timeout = 60s # time that receiver waits for - # communication from master - # in milliseconds; 0 disables -#wal_retrieve_retry_interval = 5s # time to wait before retrying to - # retrieve WAL after a failed attempt -#recovery_min_apply_delay = 0 # minimum delay for applying changes during recovery - -# - Subscribers - - -# These settings are ignored on a publisher. - -#max_logical_replication_workers = 4 # taken from max_worker_processes - # (change requires restart) -#max_sync_workers_per_subscription = 2 # taken from max_logical_replication_workers - - -#------------------------------------------------------------------------------ -# QUERY TUNING -#------------------------------------------------------------------------------ - -# - Planner Method Configuration - - -#enable_bitmapscan = on -#enable_hashagg = on -#enable_hashjoin = on -#enable_indexscan = on -#enable_indexonlyscan = on -#enable_material = on -#enable_mergejoin = on -#enable_nestloop = on -#enable_parallel_append = on -#enable_seqscan = on -#enable_sort = on -#enable_incremental_sort = on -#enable_tidscan = on -#enable_partitionwise_join = off -#enable_partitionwise_aggregate = off -#enable_parallel_hash = on -#enable_partition_pruning = on - -# - Planner Cost Constants - - -#seq_page_cost = 1.0 # measured on an arbitrary scale -#random_page_cost = 4.0 # same scale as above -#cpu_tuple_cost = 0.01 # same scale as above -#cpu_index_tuple_cost = 0.005 # same scale as above -#cpu_operator_cost = 0.0025 # same scale as above -#parallel_tuple_cost = 0.1 # same scale as above -#parallel_setup_cost = 1000.0 # same scale as above - -#jit_above_cost = 100000 # perform JIT compilation if available - # and query more expensive than this; - # -1 disables -#jit_inline_above_cost = 500000 # inline small functions if query is - # more expensive than this; -1 disables -#jit_optimize_above_cost = 500000 # use expensive JIT optimizations if - # query is more expensive than this; - # -1 disables - -#min_parallel_table_scan_size = 8MB -#min_parallel_index_scan_size = 512kB -#effective_cache_size = 4GB - -# - Genetic Query Optimizer - - -#geqo = on -#geqo_threshold = 12 -#geqo_effort = 5 # range 1-10 -#geqo_pool_size = 0 # selects default based on effort -#geqo_generations = 0 # selects default based on effort -#geqo_selection_bias = 2.0 # range 1.5-2.0 -#geqo_seed = 0.0 # range 0.0-1.0 - -# - Other Planner Options - - -#default_statistics_target = 100 # range 1-10000 -#constraint_exclusion = partition # on, off, or partition -#cursor_tuple_fraction = 0.1 # range 0.0-1.0 -#from_collapse_limit = 8 -#join_collapse_limit = 8 # 1 disables collapsing of explicit - # JOIN clauses -#force_parallel_mode = off -#jit = on # allow JIT compilation -#plan_cache_mode = auto # auto, force_generic_plan or - # force_custom_plan - - -#------------------------------------------------------------------------------ -# REPORTING AND LOGGING -#------------------------------------------------------------------------------ - -# - Where to Log - - -#log_destination = 'stderr' # Valid values are combinations of - # stderr, csvlog, syslog, and eventlog, - # depending on platform. csvlog - # requires logging_collector to be on. - -# This is used when logging to stderr: -#logging_collector = off # Enable capturing of stderr and csvlog - # into log files. Required to be on for - # csvlogs. - # (change requires restart) - -# These are only used if logging_collector is on: -#log_directory = 'log' # directory where log files are written, - # can be absolute or relative to PGDATA -#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern, - # can include strftime() escapes -#log_file_mode = 0600 # creation mode for log files, - # begin with 0 to use octal notation -#log_truncate_on_rotation = off # If on, an existing log file with the - # same name as the new log file will be - # truncated rather than appended to. - # But such truncation only occurs on - # time-driven rotation, not on restarts - # or size-driven rotation. Default is - # off, meaning append to existing files - # in all cases. -#log_rotation_age = 1d # Automatic rotation of logfiles will - # happen after that time. 0 disables. -#log_rotation_size = 10MB # Automatic rotation of logfiles will - # happen after that much log output. - # 0 disables. - -# These are relevant when logging to syslog: -#syslog_facility = 'LOCAL0' -#syslog_ident = 'postgres' -#syslog_sequence_numbers = on -#syslog_split_messages = on - -# This is only relevant when logging to eventlog (win32): -# (change requires restart) -#event_source = 'PostgreSQL' - -# - When to Log - - -#log_min_messages = warning # values in order of decreasing detail: - # debug5 - # debug4 - # debug3 - # debug2 - # debug1 - # info - # notice - # warning - # error - # log - # fatal - # panic - -#log_min_error_statement = error # values in order of decreasing detail: - # debug5 - # debug4 - # debug3 - # debug2 - # debug1 - # info - # notice - # warning - # error - # log - # fatal - # panic (effectively off) - -#log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements - # and their durations, > 0 logs only - # statements running at least this number - # of milliseconds - -#log_min_duration_sample = -1 # -1 is disabled, 0 logs a sample of statements - # and their durations, > 0 logs only a sample of - # statements running at least this number - # of milliseconds; - # sample fraction is determined by log_statement_sample_rate - -#log_statement_sample_rate = 1.0 # fraction of logged statements exceeding - # log_min_duration_sample to be logged; - # 1.0 logs all such statements, 0.0 never logs - - -#log_transaction_sample_rate = 0.0 # fraction of transactions whose statements - # are logged regardless of their duration; 1.0 logs all - # statements from all transactions, 0.0 never logs - -# - What to Log - - -#debug_print_parse = off -#debug_print_rewritten = off -#debug_print_plan = off -#debug_pretty_print = on -#log_checkpoints = off -#log_connections = off -#log_disconnections = off -#log_duration = off -#log_error_verbosity = default # terse, default, or verbose messages -#log_hostname = off -log_line_prefix = '%m [%p] %q%u@%d ' # special values: - # %a = application name - # %u = user name - # %d = database name - # %r = remote host and port - # %h = remote host - # %b = backend type - # %p = process ID - # %t = timestamp without milliseconds - # %m = timestamp with milliseconds - # %n = timestamp with milliseconds (as a Unix epoch) - # %i = command tag - # %e = SQL state - # %c = session ID - # %l = session line number - # %s = session start timestamp - # %v = virtual transaction ID - # %x = transaction ID (0 if none) - # %q = stop here in non-session - # processes - # %% = '%' - # e.g. '<%u%%%d> ' -#log_lock_waits = off # log lock waits >= deadlock_timeout -#log_parameter_max_length = -1 # when logging statements, limit logged - # bind-parameter values to N bytes; - # -1 means print in full, 0 disables -#log_parameter_max_length_on_error = 0 # when logging an error, limit logged - # bind-parameter values to N bytes; - # -1 means print in full, 0 disables -#log_statement = 'none' # none, ddl, mod, all -#log_replication_commands = off -#log_temp_files = -1 # log temporary files equal or larger - # than the specified size in kilobytes; - # -1 disables, 0 logs all temp files -log_timezone = 'Etc/UTC' - -#------------------------------------------------------------------------------ -# PROCESS TITLE -#------------------------------------------------------------------------------ - -cluster_name = '14/main' # added to process titles if nonempty - # (change requires restart) -#update_process_title = on - - -#------------------------------------------------------------------------------ -# STATISTICS -#------------------------------------------------------------------------------ - -# - Query and Index Statistics Collector - - -#track_activities = on -#track_counts = on -#track_io_timing = off -#track_functions = none # none, pl, all -#track_activity_query_size = 1024 # (change requires restart) -stats_temp_directory = '/var/run/postgresql/14-main.pg_stat_tmp' - - -# - Monitoring - - -#log_parser_stats = off -#log_planner_stats = off -#log_executor_stats = off -#log_statement_stats = off - - -#------------------------------------------------------------------------------ -# AUTOVACUUM -#------------------------------------------------------------------------------ - -#autovacuum = on # Enable autovacuum subprocess? 'on' - # requires track_counts to also be on. -#log_autovacuum_min_duration = -1 # -1 disables, 0 logs all actions and - # their durations, > 0 logs only - # actions running at least this number - # of milliseconds. -#autovacuum_max_workers = 3 # max number of autovacuum subprocesses - # (change requires restart) -#autovacuum_naptime = 1min # time between autovacuum runs -#autovacuum_vacuum_threshold = 50 # min number of row updates before - # vacuum -#autovacuum_vacuum_insert_threshold = 1000 # min number of row inserts - # before vacuum; -1 disables insert - # vacuums -#autovacuum_analyze_threshold = 50 # min number of row updates before - # analyze -#autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum -#autovacuum_vacuum_insert_scale_factor = 0.2 # fraction of inserts over table - # size before insert vacuum -#autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze -#autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum - # (change requires restart) -#autovacuum_multixact_freeze_max_age = 400000000 # maximum multixact age - # before forced vacuum - # (change requires restart) -#autovacuum_vacuum_cost_delay = 2ms # default vacuum cost delay for - # autovacuum, in milliseconds; - # -1 means use vacuum_cost_delay -#autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for - # autovacuum, -1 means use - # vacuum_cost_limit - - -#------------------------------------------------------------------------------ -# CLIENT CONNECTION DEFAULTS -#------------------------------------------------------------------------------ - -# - Statement Behavior - - -#client_min_messages = notice # values in order of decreasing detail: - # debug5 - # debug4 - # debug3 - # debug2 - # debug1 - # log - # notice - # warning - # error -#row_security = on -#default_tablespace = '' # a tablespace name, '' uses the default -#temp_tablespaces = '' # a list of tablespace names, '' uses - # only default tablespace -#default_table_access_method = 'heap' -#check_function_bodies = on -#default_transaction_isolation = 'read committed' -#default_transaction_read_only = off -#default_transaction_deferrable = off -#session_replication_role = 'origin' -#statement_timeout = 0 # in milliseconds, 0 is disabled -#lock_timeout = 0 # in milliseconds, 0 is disabled -#idle_in_transaction_session_timeout = 0 # in milliseconds, 0 is disabled -#vacuum_freeze_min_age = 50000000 -#vacuum_freeze_table_age = 150000000 -#vacuum_multixact_freeze_min_age = 5000000 -#vacuum_multixact_freeze_table_age = 150000000 -#vacuum_cleanup_index_scale_factor = 0.1 # fraction of total number of tuples - # before index cleanup, 0 always performs - # index cleanup -#bytea_output = 'hex' # hex, escape -#xmlbinary = 'base64' -#xmloption = 'content' -#gin_fuzzy_search_limit = 0 -#gin_pending_list_limit = 4MB - -# - Locale and Formatting - - -datestyle = 'iso, mdy' -#intervalstyle = 'postgres' -timezone = 'Etc/UTC' -#timezone_abbreviations = 'Default' # Select the set of available time zone - # abbreviations. Currently, there are - # Default - # Australia (historical usage) - # India - # You can create your own file in - # share/timezonesets/. -#extra_float_digits = 1 # min -15, max 3; any value >0 actually - # selects precise output mode -#client_encoding = sql_ascii # actually, defaults to database - # encoding - -# These settings are initialized by initdb, but they can be changed. -lc_messages = 'C' # locale for system error message - # strings -lc_monetary = 'C' # locale for monetary formatting -lc_numeric = 'C' # locale for number formatting -lc_time = 'C' # locale for time formatting - -# default configuration for text search -default_text_search_config = 'pg_catalog.english' - -# - Shared Library Preloading - - -#shared_preload_libraries = '' # (change requires restart) -#local_preload_libraries = '' -#session_preload_libraries = '' -#jit_provider = 'llvmjit' # JIT library to use - -# - Other Defaults - - -#extension_destdir = '' # prepend path when loading extensions - # and shared objects (added by Debian) - - -#------------------------------------------------------------------------------ -# LOCK MANAGEMENT -#------------------------------------------------------------------------------ - -#deadlock_timeout = 1s -#max_locks_per_transaction = 64 # min 10 - # (change requires restart) -#max_pred_locks_per_transaction = 64 # min 10 - # (change requires restart) -#max_pred_locks_per_relation = -2 # negative values mean - # (max_pred_locks_per_transaction - # / -max_pred_locks_per_relation) - 1 -#max_pred_locks_per_page = 2 # min 0 - - -#------------------------------------------------------------------------------ -# VERSION AND PLATFORM COMPATIBILITY -#------------------------------------------------------------------------------ - -# - Previous PostgreSQL Versions - - -#array_nulls = on -#backslash_quote = safe_encoding # on, off, or safe_encoding -#escape_string_warning = on -#lo_compat_privileges = off -#operator_precedence_warning = off -#quote_all_identifiers = off -#standard_conforming_strings = on -#synchronize_seqscans = on - -# - Other Platforms and Clients - - -#transform_null_equals = off - - -#------------------------------------------------------------------------------ -# ERROR HANDLING -#------------------------------------------------------------------------------ - -#exit_on_error = off # terminate session on any error? -#restart_after_crash = on # reinitialize after backend crash? -#data_sync_retry = off # retry or panic on failure to fsync - # data? - # (change requires restart) - - -#------------------------------------------------------------------------------ -# CONFIG FILE INCLUDES -#------------------------------------------------------------------------------ - -# These options allow settings to be loaded from files other than the -# default postgresql.conf. Note that these are directives, not variable -# assignments, so they can usefully be given more than once. - -include_dir = 'conf.d' # include files ending in '.conf' from - # a directory, e.g., 'conf.d' -#include_if_exists = '...' # include file only if it exists -#include = '...' # include file - - -#------------------------------------------------------------------------------ -# CUSTOMIZED OPTIONS -#------------------------------------------------------------------------------ - -# Add settings for extensions here -EOF - -sudo systemctl restart postgresql -msg_ok "Installed PostgreSQL" - -msg_info "Installing Adminer" -sudo apt install adminer -y &>/dev/null -sudo a2enconf adminer &>/dev/null -sudo systemctl reload apache2 &>/dev/null -msg_ok "Installed Adminer" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -chmod -x /etc/update-motd.d/* -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -mkdir /var/log/apache2 -chmod 750 /var/log/apache2 -msg_ok "Cleaned" diff --git a/setup/prometheus-install.sh b/setup/prometheus-install.sh deleted file mode 100644 index e83fa5a0..00000000 --- a/setup/prometheus-install.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing Prometheus" -mkdir -p /etc/prometheus -mkdir -p /var/lib/prometheus -wget https://github.com/prometheus/prometheus/releases/download/v2.36.2/prometheus-2.36.2.linux-amd64.tar.gz &>/dev/null -tar -xvf prometheus-2.36.2.linux-amd64.tar.gz &>/dev/null -cd prometheus-2.36.2.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 -sudo systemctl enable --now prometheus &>/dev/null -msg_ok "Created Service" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -chmod -x /etc/update-motd.d/* -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* /root/prometheus-2.36.2.linux-amd64 /root/prometheus-2.36.2.linux-amd64.tar.gz -msg_ok "Cleaned" diff --git a/setup/technitiumdns-install.sh b/setup/technitiumdns-install.sh deleted file mode 100644 index 1a9e5271..00000000 --- a/setup/technitiumdns-install.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing Technitium DNS" -curl -sSL https://download.technitium.com/dns/install.sh | sudo bash &>/dev/null -msg_ok "Installed Technitium DNS" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/ubuntu-install.sh b/setup/ubuntu-install.sh deleted file mode 100644 index 7173f364..00000000 --- a/setup/ubuntu-install.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -msg_ok "Installed Dependencies" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -chmod -x /etc/update-motd.d/* -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/ubuntu_setup.sh b/setup/ubuntu_setup.sh deleted file mode 100644 index ea116c5b..00000000 --- a/setup/ubuntu_setup.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -RETRY_NUM=5 -RETRY_EVERY=3 -NUM=$RETRY_NUM -trap die ERR -trap 'die "Script interrupted."' INT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} - -echo -e "${CHECKMARK} \e[1;92m Setting up Container OS... \e[0m" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -e "${CROSS} \e[1;31m No Network: \e[0m $(date)" - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS} \e[1;31m No Network After $RETRY_NUM Tries \e[0m" - exit 1 - fi -done - echo -e "${CHECKMARK} \e[1;92m Network Connected: \e[0m $(hostname -I)" - -echo -e "${CHECKMARK} \e[1;92m Updating Container OS \e[0m" -apt-get update &>/dev/null -apt-get -qqy upgrade &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Dependencies... \e[0m" -apt-get update &>/dev/null -apt-get -qqy install \ - curl \ - sudo &>/dev/null - -DOCKER_CONFIG_PATH='/etc/docker/daemon.json' -mkdir -p $(dirname $DOCKER_CONFIG_PATH) -cat >$DOCKER_CONFIG_PATH <<'EOF' -{ - "log-driver": "journald" -} -EOF - -echo -e "${CHECKMARK} \e[1;92m Customizing LXC... \e[0m" -chmod -x /etc/update-motd.d/* -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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//') - -echo -e "${CHECKMARK} \e[1;92m Cleanup... \e[0m" -rm -rf /ubuntu_setup.sh /var/{cache,log}/* /var/lib/apt/lists/* diff --git a/setup/unifi-install.sh b/setup/unifi-install.sh deleted file mode 100644 index f47cb3e3..00000000 --- a/setup/unifi-install.sh +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env bash -#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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -msg_ok "Installed Dependencies" - -read -r -p "Local Controller? <Y/n> " prompt -if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "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 && bash unifi-latest.sh --skip --add-repository $LOCAL &>/dev/null -msg_ok "Installed UniFi Network Application" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/uptimekuma-install.sh b/setup/uptimekuma-install.sh deleted file mode 100644 index 948ab37f..00000000 --- a/setup/uptimekuma-install.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y git &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Setting up Node.js Repository" -sudo curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - &>/dev/null -msg_ok "Set up Node.js Repository" - -msg_info "Installing Node.js" -sudo apt-get install -y nodejs &>/dev/null -msg_ok "Installed Node.js" - -msg_info "Installing Uptime Kuma" -git clone https://github.com/louislam/uptime-kuma.git &>/dev/null -mv uptime-kuma /opt/uptime-kuma -cd /opt/uptime-kuma -npm run setup &>/dev/null -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 -systemctl enable --now uptime-kuma.service &>/dev/null -msg_ok "Created Service" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/vault_setup.sh b/setup/vault_setup.sh deleted file mode 100644 index 57f2117c..00000000 --- a/setup/vault_setup.sh +++ /dev/null @@ -1,157 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -RD=`echo "\033[01;31m"` -BL=`echo "\033[36m"` -CM='\xE2\x9C\x94\033' -GN=`echo "\033[1;92m"` -CL=`echo "\033[m"` -RETRY_NUM=10 -RETRY_EVERY=3 -NUM=$RETRY_NUM -trap die ERR -trap 'die "Script interrupted."' INT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} - -echo -e "${CHECKMARK} \e[1;92m Setting up Container OS... \e[0m" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -e "${CROSS} \e[1;31m No Network: \e[0m $(date)" - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS} \e[1;31m No Network After $RETRY_NUM Tries \e[0m" - exit 1 - fi -done - echo -e "${CHECKMARK} \e[1;92m Network Connected: \e[0m $(hostname -I)" - -echo -e "${CHECKMARK} \e[1;92m Updating Container OS... \e[0m" -apt-get update &>/dev/null -apt-get -qqy upgrade &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Dependencies... \e[0m" -apt-get update &>/dev/null -apt-get -qqy install \ - git \ - nano \ - wget \ - htop \ - pkg-config \ - openssl \ - libssl1.1 \ - libssl-dev \ - curl \ - sudo &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Build Essentials... \e[0m" -apt-get install -y build-essential &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Rust... \e[0m" -curl https://sh.rustup.rs -sSf | sh -s -- -y &>/dev/null -echo 'export PATH=~/.cargo/bin:$PATH' >> ~/.bashrc &>/dev/null -export PATH=~/.cargo/bin:$PATH &>/dev/null -which rustc &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Node.js... \e[0m" -curl -fsSL https://deb.nodesource.com/setup_16.x | bash - &>/dev/null -apt-get install -y nodejs &>/dev/null -npm -g install npm@7 &>/dev/null -which npm &>/dev/null -npm i npm@latest -g &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Building Vaultwarden (Patience)... \e[0m" -git clone https://github.com/dani-garcia/vaultwarden &>/dev/null -pushd vaultwarden &>/dev/null -cargo clean &>/dev/null -cargo build --features sqlite --release &>/dev/null -file target/release/vaultwarden &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Building Web-Vault... \e[0m" -pushd target/release/ &>/dev/null -git clone --recurse-submodules https://github.com/bitwarden/web.git web-vault.git &>/dev/null -cd web-vault.git &>/dev/null -git checkout v2.25.1 &>/dev/null -git submodule update --init --recursive &>/dev/null -wget https://raw.githubusercontent.com/dani-garcia/bw_web_builds/master/patches/v2.25.0.patch &>/dev/null -git apply v2.25.0.patch &>/dev/null -npm ci --silent --legacy-peer-deps &>/dev/null -npm audit fix --silent --legacy-peer-deps || true &>/dev/null -npm run --silent dist:oss:selfhost &>/dev/null -cp -a build ../web-vault &>/dev/null -cd .. -mkdir data - -echo -e "${CHECKMARK} \e[1;92m Create Systemd Service... \e[0m" -cp ../../.env.template /etc/vaultwarden.env &>/dev/null -cp vaultwarden /usr/bin/vaultwarden &>/dev/null -chmod +x /usr/bin/vaultwarden &>/dev/null -useradd -m -d /var/lib/vaultwarden vaultwarden &>/dev/null -sudo cp -R data /var/lib/vaultwarden/ &>/dev/null -cp -R web-vault /var/lib/vaultwarden/ &>/dev/null -chown -R vaultwarden:vaultwarden /var/lib/vaultwarden &>/dev/null - -service_path="/etc/systemd/system/vaultwarden.service" &>/dev/null - -echo "[Unit] -Description=Bitwarden Server (Powered by Vaultwarden) -Documentation=https://github.com/dani-garcia/vaultwarden - -After=network.target - -[Service] -User=vaultwarden -Group=vaultwarden -EnvironmentFile=/etc/vaultwarden.env -ExecStart=/usr/bin/vaultwarden -LimitNOFILE=1048576 -LimitNPROC=64 -PrivateTmp=true -PrivateDevices=true -ProtectHome=true -ProtectSystem=strict -WorkingDirectory=/var/lib/vaultwarden -ReadWriteDirectories=/var/lib/vaultwarden -AmbientCapabilities=CAP_NET_BIND_SERVICE - -[Install] -WantedBy=multi-user.target" > $service_path - -echo -e "${CHECKMARK} \e[1;92m Customizing Container... \e[0m" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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//') -systemctl enable vaultwarden.service &>/dev/null -systemctl start vaultwarden.service &>/dev/null -echo -e "${CHECKMARK} \e[1;92m Cleanup... \e[0m" -rm -rf /vault_setup.sh /var/{cache,log}/* /var/lib/apt/lists/* diff --git a/setup/vaultwarden-install.sh b/setup/vaultwarden-install.sh deleted file mode 100644 index ec4da4f3..00000000 --- a/setup/vaultwarden-install.sh +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Setup Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get update &>/dev/null -apt-get -qqy install \ - git \ - build-essential \ - pkgconf \ - libssl-dev \ - libmariadb-dev-compat \ - libpq-dev \ - curl \ - sudo &>/dev/null -msg_ok "Installed Dependencies" - -WEBVAULT=$(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) }') \ - -VAULT=$(curl -s https://api.github.com/repos/dani-garcia/vaultwarden/releases/latest \ -| grep "tag_name" \ -| awk '{print substr($2, 2, length($2)-3) }') \ - -msg_info "Installing Rust" -curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal &>/dev/null -echo 'export PATH=~/.cargo/bin:$PATH' >> ~/.bashrc &>/dev/null -export PATH=~/.cargo/bin:$PATH &>/dev/null -which rustc &>/dev/null -msg_ok "Installed Rust" - -msg_info "Building Vaultwarden ${VAULT} (Patience)" -git clone https://github.com/dani-garcia/vaultwarden &>/dev/null -cd vaultwarden -cargo build --features "sqlite,mysql,postgresql" --release &>/dev/null -msg_ok "Built Vaultwarden ${VAULT}" - -addgroup --system vaultwarden &>/dev/null -adduser --system --home /opt/vaultwarden --shell /usr/sbin/nologin --no-create-home --gecos 'vaultwarden' --ingroup vaultwarden --disabled-login --disabled-password vaultwarden &>/dev/null -mkdir -p /opt/vaultwarden/bin -mkdir -p /opt/vaultwarden/data -cp target/release/vaultwarden /opt/vaultwarden/bin/ - -msg_info "Downloading Web-Vault ${WEBVAULT}" -curl -fsSLO https://github.com/dani-garcia/bw_web_builds/releases/download/$WEBVAULT/bw_web_$WEBVAULT.tar.gz &>/dev/null -tar -xzf bw_web_$WEBVAULT.tar.gz -C /opt/vaultwarden/ &>/dev/null -msg_ok "Downloaded Web-Vault ${WEBVAULT}" - -cat <<EOF > /opt/vaultwarden/.env -## https://github.com/dani-garcia/vaultwarden/blob/main/.env.template -# ADMIN_TOKEN=Vy2VyYTTsKPv8W5aEOWUbB/Bt3DEKePbHmI4m9VcemUMS2rEviDowNAFqYi1xjmp -ROCKET_ADDRESS=0.0.0.0 -DATA_FOLDER=/opt/vaultwarden/data -DATABASE_MAX_CONNS=10 -WEB_VAULT_FOLDER=/opt/vaultwarden/web-vault -WEB_VAULT_ENABLED=true -EOF - -msg_info "Creating Service" -chown -R vaultwarden:vaultwarden /opt/vaultwarden/ -chown root:root /opt/vaultwarden/bin/vaultwarden -chmod +x /opt/vaultwarden/bin/vaultwarden -chown -R root:root /opt/vaultwarden/web-vault/ -chmod +r /opt/vaultwarden/.env -service_path="/etc/systemd/system/vaultwarden.service" &>/dev/null - -echo "[Unit] -Description=Bitwarden Server (Powered by Vaultwarden) -Documentation=https://github.com/dani-garcia/vaultwarden -After=network.target -[Service] -User=vaultwarden -Group=vaultwarden -EnvironmentFile=-/opt/vaultwarden/.env -ExecStart=/opt/vaultwarden/bin/vaultwarden -LimitNOFILE=65535 -LimitNPROC=4096 -PrivateTmp=true -PrivateDevices=true -ProtectHome=true -ProtectSystem=strict -DevicePolicy=closed -ProtectControlGroups=yes -ProtectKernelModules=yes -ProtectKernelTunables=yes -RestrictNamespaces=yes -RestrictRealtime=yes -MemoryDenyWriteExecute=yes -LockPersonality=yes -WorkingDirectory=/opt/vaultwarden -ReadWriteDirectories=/opt/vaultwarden/data -AmbientCapabilities=CAP_NET_BIND_SERVICE -[Install] -WantedBy=multi-user.target" > $service_path -systemctl daemon-reload -systemctl enable --now vaultwarden.service &>/dev/null -msg_ok "Created Service" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/whoogle-install.sh b/setup/whoogle-install.sh deleted file mode 100644 index 52d65c56..00000000 --- a/setup/whoogle-install.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing pip3" -apt-get install python3-pip -y &>/dev/null -msg_ok "Installed pip3" - -msg_info "Installing Whoogle" -pip install whoogle-search &>/dev/null - -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 - -systemctl enable --now whoogle.service &>/dev/null -msg_ok "Installed Whoogle" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -chmod -x /etc/update-motd.d/* -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/wireguard-install.sh b/setup/wireguard-install.sh deleted file mode 100644 index 4804a3c6..00000000 --- a/setup/wireguard-install.sh +++ /dev/null @@ -1,152 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -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" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y gunicorn &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing WireGuard (using pivpn.io)" -curl -s -L https://install.pivpn.io > install.sh -chmod +x install.sh -./install.sh --unattended options.conf &>/dev/null -msg_ok "Installed WireGuard" - -msg_info "Installing pip3" -apt-get install python3-pip -y &>/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 pip3" - -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=netword.service - -[Service] -WorkingDirectory=/etc/wgdashboard/src -ExecStart=/usr/bin/python3 /etc/wgdashboard/src/dashboard.py -Restart=always - - -[Install] -WantedBy=default.target" > $service_path -sudo chmod 664 /etc/systemd/system/wg-dashboard.service -sudo systemctl daemon-reload -sudo systemctl enable wg-dashboard.service &>/dev/null -sudo systemctl start wg-dashboard.service -msg_ok "Created Service" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/zigbee2mqtt-install.sh b/setup/zigbee2mqtt-install.sh deleted file mode 100644 index 8056c2b6..00000000 --- a/setup/zigbee2mqtt-install.sh +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -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" -curl -fsSL https://deb.nodesource.com/setup_18.x | bash - &>/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 "Setting up Zigbee2MQTT Repository" -sudo git clone --depth 1 https://github.com/Koenkk/zigbee2mqtt.git /opt/zigbee2mqtt &>/dev/null -msg_ok "Set up Zigbee2MQTT Repository" - -msg_info "Installing Zigbee2MQTT" -cd /opt/zigbee2mqtt &>/dev/null -npm ci &>/dev/null -msg_ok "Installed Zigbee2MQTT" - -msg_info "Creating Service" -service_path="/etc/systemd/system/zigbee2mqtt.service" -echo "[Unit] -Description=zigbee2mqtt -After=network.target -[Service] -ExecStart=/usr/bin/npm start -WorkingDirectory=/opt/zigbee2mqtt -StandardOutput=inherit -StandardError=inherit -Restart=always -User=root -[Install] -WantedBy=multi-user.target" > $service_path -systemctl enable zigbee2mqtt.service &>/dev/null -msg_ok "Created Service" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/zigbee2mqtt_setup.sh b/setup/zigbee2mqtt_setup.sh deleted file mode 100644 index d0ce0c01..00000000 --- a/setup/zigbee2mqtt_setup.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -RETRY_NUM=5 -RETRY_EVERY=3 -NUM=$RETRY_NUM -trap die ERR -trap 'die "Script interrupted."' INT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} - -echo -e "${CHECKMARK} \e[1;92m Setting up Container OS... \e[0m" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -e "${CROSS} \e[1;31m No Network: \e[0m $(date)" - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS} \e[1;31m No Network After $RETRY_NUM Tries \e[0m" - exit 1 - fi -done - echo -e "${CHECKMARK} \e[1;92m Network Connected: \e[0m $(hostname -I)" - -echo -e "${CHECKMARK} \e[1;92m Updating Container OS... \e[0m" -apt-get update &>/dev/null -apt-get -qqy upgrade &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Dependencies... \e[0m" -apt-get update &>/dev/null -apt-get -qqy install \ - curl \ - sudo &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Setting up Node.js Repository... \e[0m" -sudo curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Node.js... \e[0m" -sudo apt-get install -y nodejs git make g++ gcc &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Setting up Zigbee2MQTT Repository... \e[0m" -sudo git clone https://github.com/Koenkk/zigbee2mqtt.git /opt/zigbee2mqtt &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Zigbee2MQTT... \e[0m" -cd /opt/zigbee2mqtt &>/dev/null -npm ci &>/dev/null - -service_path="/etc/systemd/system/zigbee2mqtt.service" -echo "[Unit] -Description=zigbee2mqtt -After=network.target -[Service] -ExecStart=/usr/bin/npm start -WorkingDirectory=/opt/zigbee2mqtt -StandardOutput=inherit -StandardError=inherit -Restart=always -User=root -[Install] -WantedBy=multi-user.target" > $service_path - -echo -e "${CHECKMARK} \e[1;92m Customizing LXC... \e[0m" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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//') -systemctl enable zigbee2mqtt.service &>/dev/null -echo -e "${CHECKMARK} \e[1;92m Cleanup... \e[0m" -rm -rf /zigbee2mqtt_setup.sh /var/{cache,log}/* /var/lib/apt/lists/* diff --git a/setup/zwavejs2mqtt-install.sh b/setup/zwavejs2mqtt-install.sh deleted file mode 100644 index 06aabdda..00000000 --- a/setup/zwavejs2mqtt-install.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env bash -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 -NUM=$RETRY_NUM -CM="${GN}✓${CL}" -CROSS="${RD}✗${CL}" -BFR="\\r\\033[K" -HOLD="-" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR - -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}" -} - -msg_info "Setting up Container OS " -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" - exit 1 - fi -done -msg_ok "Set up Container OS" -msg_ok "Network Connected: ${BL}$(hostname -I)" - -msg_info "Updating Container OS" -apt update &>/dev/null -apt-get -qqy upgrade &>/dev/null -msg_ok "Updated Container OS" - -msg_info "Installing Dependencies" -apt-get install -y curl &>/dev/null -apt-get install -y sudo &>/dev/null -apt-get install -y unzip &>/dev/null -msg_ok "Installed Dependencies" - -msg_info "Installing Zwavejs2MQTT" -mkdir /opt/zwavejs2mqtt -cd /opt/zwavejs2mqtt -mkdir store -curl -s https://api.github.com/repos/zwave-js/zwavejs2mqtt/releases/latest | grep "browser_download_url.*zip" | cut -d : -f 2,3 | tr -d \" | wget -i - &>/dev/null -unzip zwavejs2mqtt-v*.zip zwavejs2mqtt &>/dev/null -msg_ok "Installed Zwavejs2MQTT" - -msg_info "Creating Service" -service_path="/etc/systemd/system/zwavejs2mqtt.service" -echo "[Unit] -Description=ZWavejs2MQTT -Wants=network-online.target -After=network-online.target -[Service] -User=root -WorkingDirectory=/opt/zwavejs2mqtt -ExecStart=/opt/zwavejs2mqtt/zwavejs2mqtt -[Install] -WantedBy=multi-user.target" > $service_path -systemctl start zwavejs2mqtt -systemctl enable zwavejs2mqtt &>/dev/null -msg_ok "Created Service" - -PASS=$(grep -w "root" /etc/shadow | cut -b6); - if [[ $PASS != $ ]]; then -msg_info "Customizing Container" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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 - -msg_info "Cleaning up" -rm zwavejs2mqtt-v*.zip -apt-get autoremove >/dev/null -apt-get autoclean >/dev/null -rm -rf /var/{cache,log}/* /var/lib/apt/lists/* -msg_ok "Cleaned" diff --git a/setup/zwavejs2mqtt_setup.sh b/setup/zwavejs2mqtt_setup.sh deleted file mode 100644 index b4cdd610..00000000 --- a/setup/zwavejs2mqtt_setup.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' -RETRY_NUM=5 -RETRY_EVERY=3 -NUM=$RETRY_NUM -trap die ERR -trap 'die "Script interrupted."' INT - -function error_exit() { - trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" - exit $EXIT -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" -} - -echo -e "${CHECKMARK} \e[1;92m Setting up Container OS... \e[0m" -sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen -locale-gen >/dev/null -while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -e "${CROSS} \e[1;31m No Network: \e[0m $(date)" - sleep $RETRY_EVERY - ((NUM--)) - if [ $NUM -eq 0 ] - then - 1>&2 echo -e "${CROSS} \e[1;31m No Network After $RETRY_NUM Tries \e[0m" - exit 1 - fi -done - echo -e "${CHECKMARK} \e[1;92m Network Connected: \e[0m $(hostname -I)" - -echo -e "${CHECKMARK} \e[1;92m Updating Container OS... \e[0m" -apt-get update &>/dev/null -apt-get -qqy upgrade &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Installing Prerequisites... \e[0m" -apt-get update &>/dev/null -apt-get -qqy install \ - curl \ - sudo \ - unzip &>/dev/null - - echo -e "${CHECKMARK} \e[1;92m Setting up Node.js Repository... \e[0m" - sudo curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - &>/dev/null - - echo -e "${CHECKMARK} \e[1;92m Installing Node.js... \e[0m" - sudo apt-get install -y nodejs git make g++ gcc &>/dev/null - - echo -e "${CHECKMARK} \e[1;92m Installing yarn... \e[0m" - npm install --global yarn &>/dev/null - - echo -e "${CHECKMARK} \e[1;92m Build/Install Zwavejs2MQTT (5-6 min)... \e[0m" - sudo git clone https://github.com/zwave-js/zwavejs2mqtt /opt/zwavejs2mqtt &>/dev/null - cd /opt/zwavejs2mqtt &>/dev/null - yarn install &>/dev/null - yarn run build &>/dev/null - -echo -e "${CHECKMARK} \e[1;92m Creating Service file zwavejs2mqtt.service... \e[0m" -service_path="/etc/systemd/system/zwavejs2mqtt.service" - -echo "[Unit] -Description=zwavejs2mqtt -After=network.target -[Service] -ExecStart=/usr/bin/npm start -WorkingDirectory=/opt/zwavejs2mqtt -StandardOutput=inherit -StandardError=inherit -Restart=always -User=root -[Install] -WantedBy=multi-user.target" > $service_path - -echo -e "${CHECKMARK} \e[1;92m Customizing container... \e[0m" -rm /etc/motd -rm /etc/update-motd.d/10-uname -touch ~/.hushlogin -GETTY_OVERRIDE="/etc/systemd/system/container-getty@1.service.d/override.conf" -mkdir -p $(dirname $GETTY_OVERRIDE) -cat << EOF > $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//') - -echo -e "${CHECKMARK} \e[1;92m Cleanup... \e[0m" -rm -rf /zwavejs2mqtt_setup.sh /var/{cache,log}/* /var/lib/apt/lists/* -systemctl start zwavejs2mqtt -systemctl enable zwavejs2mqtt &>/dev/null diff --git a/turnkey/turnkey.sh b/turnkey/turnkey.sh new file mode 100644 index 00000000..202143cf --- /dev/null +++ b/turnkey/turnkey.sh @@ -0,0 +1,241 @@ +#!/usr/bin/env bash +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + clear + cat <<"EOF" + ______ __ __ __ _ _______ +/_ __/_ _________ / //_/__ __ __ / / | |/_/ ___/ + / / / // / __/ _ \/ ,< / -_) // / / /___> </ /__ +/_/ \_,_/_/ /_//_/_/|_|\__/\_, / /____/_/|_|\___/ + /___/ +EOF +} + +set -euo pipefail +shopt -s expand_aliases +alias die='EXIT=$? LINE=$LINENO error_exit' +trap die ERR +function error_exit() { + trap - ERR + local DEFAULT='Unknown failure occured.' + local REASON="\e[97m${1:-$DEFAULT}\e[39m" + local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" + msg "$FLAG $REASON" 1>&2 + [ ! -z ${CTID-} ] && cleanup_ctid + exit $EXIT +} +function warn() { + local REASON="\e[97m$1\e[39m" + local FLAG="\e[93m[WARNING]\e[39m" + msg "$FLAG $REASON" +} +function info() { + local REASON="$1" + local FLAG="\e[36m[INFO]\e[39m" + msg "$FLAG $REASON" +} +function msg() { + local TEXT="$1" + echo -e "$TEXT" +} +function cleanup_ctid() { + if pct status $CTID &>/dev/null; then + if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then + pct stop $CTID + fi + pct destroy $CTID + fi +} + +# Stop Proxmox VE Monitor-All if running +if systemctl is-active -q ping-instances.service; then + systemctl stop ping-instances.service +fi +header_info +whiptail --backtitle "Proxmox VE Helper Scripts" --title "TurnKey LXCs" --yesno "This will allow for the creation of one of the many TurnKey LXC Containers. Proceed?" 10 68 || exit +TURNKEY_MENU=() +MSG_MAX_LENGTH=0 +while read -r TAG ITEM; do + OFFSET=2 + ((${#ITEM} + OFFSET > MSG_MAX_LENGTH)) && MSG_MAX_LENGTH=${#ITEM}+OFFSET + TURNKEY_MENU+=("$TAG" "$ITEM " "OFF") +done < <( + cat <<EOF +ansible Ansible +bookstack BookStack +core Core +faveo-helpdesk Faveo Helpdesk +fileserver File Server +gallery Gallery +gameserver Game Server +gitea Gitea +gitlab GitLab +invoice-ninja Invoice Ninja +mediaserver Media Server +nextcloud Nextcloud +observium Observium +odoo Odoo +openvpn OpenVPN +owncloud ownCloud +phpbb phpBB +torrentserver Torrent Server +wireguard WireGuard +wordpress Wordpress +zoneminder ZoneMinder +EOF +) +turnkey=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "TurnKey LXCs" --radiolist "\nSelect a TurnKey LXC to create:\n" 16 $((MSG_MAX_LENGTH + 58)) 6 "${TURNKEY_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"') || exit +[ -z "$turnkey" ] && { + whiptail --backtitle "Proxmox VE Helper Scripts" --title "No TurnKey LXC Selected" --msgbox "It appears that no TurnKey LXC container was selected" 10 68 + msg "Done" + exit +} + +# Setup script environment +PASS="$(openssl rand -base64 8)" +CTID=$(pvesh get /cluster/nextid) +PCT_OPTIONS=" + -features keyctl=1,nesting=1 + -hostname turnkey-${turnkey} + -tags proxmox-helper-scripts + -onboot 1 + -cores 2 + -memory 2048 + -password $PASS + -net0 name=eth0,bridge=vmbr0,ip=dhcp + -unprivileged 1 + " +DEFAULT_PCT_OPTIONS=( + -arch $(dpkg --print-architecture) +) + +# Set the CONTENT and CONTENT_LABEL variables +function select_storage() { + local CLASS=$1 + local CONTENT + local CONTENT_LABEL + case $CLASS in + container) + CONTENT='rootdir' + CONTENT_LABEL='Container' + ;; + template) + CONTENT='vztmpl' + CONTENT_LABEL='Container template' + ;; + *) false || die "Invalid storage class." ;; + esac + + # Query all storage locations + local -a MENU + while read -r line; do + local TAG=$(echo $line | awk '{print $1}') + local TYPE=$(echo $line | awk '{printf "%-10s", $2}') + local FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') + local ITEM=" Type: $TYPE Free: $FREE " + local OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + MENU+=("$TAG" "$ITEM" "OFF") + done < <(pvesm status -content $CONTENT | awk 'NR>1') + + # Select storage location + if [ $((${#MENU[@]} / 3)) -eq 0 ]; then + warn "'$CONTENT_LABEL' needs to be selected for at least one storage location." + die "Unable to detect valid storage location." + elif [ $((${#MENU[@]} / 3)) -eq 1 ]; then + printf ${MENU[0]} + else + local STORAGE + while [ -z "${STORAGE:+x}" ]; do + STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Storage Pools" --radiolist \ + "Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${MENU[@]}" 3>&1 1>&2 2>&3) || die "Menu aborted." + done + printf $STORAGE + fi +} + +# Get template storage +TEMPLATE_STORAGE=$(select_storage template) || exit +info "Using '$TEMPLATE_STORAGE' for template storage." + +# Get container storage +CONTAINER_STORAGE=$(select_storage container) || exit +info "Using '$CONTAINER_STORAGE' for container storage." + +# Update LXC template list +msg "Updating LXC template list..." +pveam update >/dev/null + +# Get LXC template string +mapfile -t TEMPLATES < <(pveam available -section turnkeylinux | awk -v turnkey="${turnkey}" '$0 ~ turnkey {print $2}' | sort -t - -k 2 -V) +[ ${#TEMPLATES[@]} -gt 0 ] || die "Unable to find a template when searching for '${turnkey}'." +TEMPLATE="${TEMPLATES[-1]}" + +# Download LXC template +if ! pveam list $TEMPLATE_STORAGE | grep -q $TEMPLATE; then + msg "Downloading LXC template (Patience)..." + pveam download $TEMPLATE_STORAGE $TEMPLATE >/dev/null || + die "A problem occured while downloading the LXC template." +fi + +# Create variable for 'pct' options +PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}}) +[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=(-rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8}) + +# Create LXC +msg "Creating LXC container..." +pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null || + die "A problem occured while trying to create container." + +# Save password +echo "TurnKey ${turnkey} password: ${PASS}" >>~/turnkey-${turnkey}.creds # file is located in the Proxmox root directory + +# Start container +msg "Starting LXC Container..." +pct start "$CTID" +sleep 5 + +# Get container IP +set +euo pipefail # Turn off error checking +max_attempts=5 +attempt=1 +IP="" +while [[ $attempt -le $max_attempts ]]; do + IP=$(pct exec $CTID ip a show dev eth0 | grep -oP 'inet \K[^/]+') + if [[ -n $IP ]]; then + break + else + warn "Attempt $attempt: IP address not found. Pausing for 5 seconds..." + sleep 5 + ((attempt++)) + fi +done + +if [[ -z $IP ]]; then + warn "Maximum number of attempts reached. IP address not found." + IP="NOT FOUND" +fi + +# Start Proxmox VE Monitor-All if available +if [[ -f /etc/systemd/system/ping-instances.service ]]; then + systemctl start ping-instances.service +fi + +# Success message +header_info +echo +info "LXC container '$CTID' was successfully created, and its IP address is ${IP}." +echo +info "Proceed to the LXC console to complete the setup." +echo +info "login: root" +info "password: $PASS" +echo diff --git a/vm/debian-vm.sh b/vm/debian-vm.sh new file mode 100644 index 00000000..d6159317 --- /dev/null +++ b/vm/debian-vm.sh @@ -0,0 +1,426 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 "\n Loading..." +GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//') +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") +BFR="\\r\\033[K" +HOLD="-" +CM="${GN}✓${CL}" +CROSS="${RD}✗${CL}" +THIN="discard=on,ssd=1," +set -e +trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +trap cleanup EXIT +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" + cleanup_vmid +} + +function cleanup_vmid() { + if qm status $VMID &>/dev/null; then + qm stop $VMID &>/dev/null + qm destroy $VMID &>/dev/null + fi +} + +function cleanup() { + popd >/dev/null + rm -rf $TEMP_DIR +} + +TEMP_DIR=$(mktemp -d) +pushd $TEMP_DIR >/dev/null +if whiptail --backtitle "Proxmox VE Helper Scripts" --title "Debian 12 VM" --yesno "This will create a New Debian 12 VM. Proceed?" 10 58; then + : +else + header_info && echo -e "⚠ User exited script \n" && exit +fi + +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 check_root() { + if [[ "$(id -u)" -ne 0 || $(ps -o comm= -p $PPID) == "sudo" ]]; then + clear + msg_error "Please run this script as root." + echo -e "\nExiting..." + sleep 2 + exit + fi +} + +function pve_check() { + if ! pveversion | grep -Eq "pve-manager/8.[1-3]"; then + msg_error "This version of Proxmox Virtual Environment is not supported" + echo -e "Requires Proxmox Virtual Environment Version 8.1 or later." + echo -e "Exiting..." + sleep 2 + exit +fi +} + +function arch_check() { + if [ "$(dpkg --print-architecture)" != "amd64" ]; then + msg_error "This script will not work with PiMox! \n" + echo -e "Exiting..." + sleep 2 + exit + fi +} + +function ssh_check() { + if command -v pveversion >/dev/null 2>&1; then + if [ -n "${SSH_CLIENT:+x}" ]; then + if whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SSH DETECTED" --yesno "It's suggested to use the Proxmox shell instead of SSH, since SSH can create issues while gathering variables. Would you like to proceed with using SSH?" 10 62; then + echo "you've been warned" + else + clear + exit + fi + fi + fi +} + +function exit-script() { + clear + echo -e "⚠ User exited script \n" + exit +} + +function default_settings() { + VMID="$NEXTID" + FORMAT=",efitype=4m" + MACHINE="" + DISK_CACHE="" + HN="debian" + CPU_TYPE="" + CORE_COUNT="2" + RAM_SIZE="2048" + BRG="vmbr0" + MAC="$GEN_MAC" + VLAN="" + MTU="" + START_VM="yes" + echo -e "${DGN}Using Virtual Machine ID: ${BGN}${VMID}${CL}" + echo -e "${DGN}Using Machine Type: ${BGN}i440fx${CL}" + echo -e "${DGN}Using Disk Cache: ${BGN}None${CL}" + echo -e "${DGN}Using Hostname: ${BGN}${HN}${CL}" + echo -e "${DGN}Using CPU Model: ${BGN}KVM64${CL}" + echo -e "${DGN}Allocated Cores: ${BGN}${CORE_COUNT}${CL}" + echo -e "${DGN}Allocated RAM: ${BGN}${RAM_SIZE}${CL}" + echo -e "${DGN}Using Bridge: ${BGN}${BRG}${CL}" + echo -e "${DGN}Using MAC Address: ${BGN}${MAC}${CL}" + echo -e "${DGN}Using VLAN: ${BGN}Default${CL}" + echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" + echo -e "${DGN}Start VM when completed: ${BGN}yes${CL}" + echo -e "${BL}Creating a Debian 12 VM using the above default settings${CL}" +} + +function advanced_settings() { + while true; do + if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z "$VMID" ]; then + VMID="$NEXTID" + fi + 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 + else + exit-script + fi + done + + if MACH=$(whiptail --backtitle "Proxmox VE Helper Scripts" --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); then + 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 + else + exit-script + fi + + if DISK_CACHE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "DISK CACHE" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \ + "0" "None (Default)" ON \ + "1" "Write Through" OFF \ + 3>&1 1>&2 2>&3); then + if [ $DISK_CACHE = "1" ]; then + echo -e "${DGN}Using Disk Cache: ${BGN}Write Through${CL}" + DISK_CACHE="cache=writethrough," + else + echo -e "${DGN}Using Disk Cache: ${BGN}None${CL}" + DISK_CACHE="" + fi + else + exit-script + fi + + if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 debian --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $VM_NAME ]; then + HN="debian" + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + else + HN=$(echo ${VM_NAME,,} | tr -d ' ') + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + fi + else + exit-script + fi + + if CPU_TYPE1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "CPU MODEL" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \ + "0" "KVM64 (Default)" ON \ + "1" "Host" OFF \ + 3>&1 1>&2 2>&3); then + if [ $CPU_TYPE1 = "1" ]; then + echo -e "${DGN}Using CPU Model: ${BGN}Host${CL}" + CPU_TYPE=" -cpu host" + else + echo -e "${DGN}Using CPU Model: ${BGN}KVM64${CL}" + CPU_TYPE="" + fi + else + exit-script + fi + + if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $CORE_COUNT ]; then + CORE_COUNT="2" + 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 --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 2048 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $RAM_SIZE ]; then + RAM_SIZE="2048" + 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 --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 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 MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $MAC1 ]; then + MAC="$GEN_MAC" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}" + else + MAC="$MAC1" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" + fi + else + exit-script + fi + + if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); 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 + else + exit-script + fi + + if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); 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 + else + exit-script + fi + + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 + echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" + START_VM="no" + fi + + if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create a Debian 12 VM?" --no-button Do-Over 10 58); then + echo -e "${RD}Creating a Debian 12 VM using the above advanced settings${CL}" + else + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi +} + +function start_script() { + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 +} + +check_root +arch_check +pve_check +ssh_check +start_script + +msg_info "Validating Storage" +while read -r line; do + TAG=$(echo $line | awk '{print $1}') + TYPE=$(echo $line | awk '{printf "%-10s", $2}') + FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') + ITEM=" Type: $TYPE Free: $FREE " + OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + 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." + exit +elif [ $((${#STORAGE_MENU[@]} / 3)) -eq 1 ]; then + STORAGE=${STORAGE_MENU[0]} +else + while [ -z "${STORAGE:+x}" ]; do + STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Storage Pools" --radiolist \ + "Which storage pool you would like to use for ${HN}?\nTo make a selection, use the Spacebar.\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 the Debian 12 Qcow2 Disk Image" +URL=https://cloud.debian.org/images/cloud/bookworm/20240507-1740/debian-12-nocloud-amd64-20240507-1740.qcow2 +sleep 2 +msg_ok "${CL}${BL}${URL}${CL}" +wget -q --show-progress $URL +echo -en "\e[1A\e[0K" +FILE=$(basename $URL) +msg_ok "Downloaded ${CL}${BL}${FILE}${CL}" + +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" + 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" + eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-} + eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk} +done + +msg_info "Creating a Debian 12 VM" +qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \ + -name $HN -tags proxmox-helper-scripts -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci +pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null +qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null +qm set $VMID \ + -efidisk0 ${DISK0_REF}${FORMAT} \ + -scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=2G \ + -boot order=scsi0 \ + -serial0 socket \ + -description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/logo-81x112.png'/></a> + + # Debian 12 VM + + <a href='https://ko-fi.com/D1D7EP4GF'><img src='https://img.shields.io/badge/☕-Buy me a coffee-blue' /></a> + </div>" >/dev/null +msg_ok "Created a Debian 12 VM ${CL}${BL}(${HN})" +if [ "$START_VM" == "yes" ]; then + msg_info "Starting Debian 12 VM" + qm start $VMID + msg_ok "Started Debian 12 VM" +fi +msg_ok "Completed Successfully!\n" +echo "More Info at https://github.com/tteck/Proxmox/discussions/1988" diff --git a/vm/haos-vm-v3.sh b/vm/haos-vm-v3.sh deleted file mode 100644 index 105aad6d..00000000 --- a/vm/haos-vm-v3.sh +++ /dev/null @@ -1,351 +0,0 @@ -#!/usr/bin/env bash -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) -RELEASE=$(curl -sX GET "https://api.github.com/repos/home-assistant/operating-system/releases" | awk '/tag_name/{print $4;exit}' FS='[""]') -STABLE=$(curl -s https://raw.githubusercontent.com/home-assistant/version/master/stable.json | grep "ova" | awk '{print substr($2, 2, length($2)-3) }') -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}" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -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 - [ ! -z ${VMID-} ] && cleanup_vmid - exit $EXIT -} - -function cleanup_vmid() { - if $(qm status $VMID &>/dev/null); then - if [ "$(qm status $VMID | awk '{print $2}')" == "running" ]; then - qm stop $VMID - fi - qm destroy $VMID - fi -} - -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -while true; do - clear - read -p "This will create a New Home Assistant OS VM. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear - -function header_info { -echo -e "${BL} - _ _ ____ _____ - | | | | /\ / __ \ / ____| - | |__| | / \ | | | | (___ - | __ | / /\ \| | | |\___ \ - | | | |/ ____ \ |__| |____) | - |_| |_/_/ ${CL}${YW}v3${CL}${BL} \_\____/|_____/ -${CL}" -} -header_info - -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 default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using Version ${BGN}${STABLE}${CL}" - BRANCH=${STABLE} - echo -e "${DGN}Using VM ID ${BGN}$NEXTID${CL}" - VMID=$NEXTID - echo -e "${DGN}Using VM Name ${BGN}haos${STABLE}${CL}" - VM_NAME=haos${STABLE} - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}4096${CL}${DGN}MiB RAM${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 Tag ${BGN}NONE${CL}" - VLAN="" - echo -e "${DGN}Start VM when completed ${BGN}yes${CL}" - START_VM="yes" - -} -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Latest for Version ${RELEASE}, or Press [ENTER] for Stable Version ${STABLE} " - read BRANCH - if [ -z $BRANCH ]; then BRANCH=$STABLE; - else - BRANCH=$RELEASE; fi; - echo -en "${DGN}Set Version To ${BL}$BRANCH${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${YW}Enter the VM ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read VMID - if [ -z $VMID ]; then VMID=$NEXTID; fi; - echo -en "${DGN}Set VM ID To ${BL}$VMID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${YW}Enter VM Name (no-spaces), or Press [ENTER] for Default: haos${BRANCH} " - read VMNAME - if [ -z $VMNAME ]; then - VM_NAME=haos${BRANCH} - else - VM_NAME=$(echo ${VMNAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$VM_NAME${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}${CORE_COUNT}${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 4096 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="4096"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Valid MAC Address, or Press [ENTER] for Generated MAC: $GEN_MAC " - read MAC - if [ -z $MAC ]; then MAC=$GEN_MAC; fi; - echo -en "${DGN}Set MAC Address To ${BL}$MAC${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using MAC Address ${BGN}$MAC${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using MAC Address ${BGN}$MAC${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - echo -e "${YW}Start VM when completed, or Press [ENTER] for Default: yes " - read START_VM - if [ -z $START_VM ]; then START_VM="yes"; - else - START_VM="no"; fi; - echo -en "${DGN}Starting VM when completed ${BL}$START_VM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using MAC Address ${BGN}$MAC${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - echo -e "${DGN}Start VM when completed ${BGN}$START_VM${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced (Latest ${RELEASE}), or Press [ENTER] for Default Settings (Stable ${STABLE}) " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content images | awk 'NR>1') -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 - 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 - 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 "Getting URL for Home Assistant ${BRANCH} Disk Image" -URL=https://github.com/home-assistant/operating-system/releases/download/${BRANCH}/haos_ova-${BRANCH}.qcow2.xz -sleep 2 -msg_ok "${CL}${BL}${URL}${CL}" -wget -q --show-progress $URL -echo -en "\e[1A\e[0K" -FILE=$(basename $URL) -msg_ok "Downloaded ${CL}${BL}haos_ova-${BRANCH}.qcow2.xz${CL}" -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=".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" - eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-} - eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk} -done -msg_ok "Extracted KVM Disk Image" - -msg_info "Creating HAOS VM" -qm create $VMID -agent 1 -bios ovmf -cores $CORE_COUNT -memory $RAM_SIZE -name $VM_NAME -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN \ - -onboot 1 -ostype l26 -scsihw virtio-scsi-pci -pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null -qm importdisk $VMID ${FILE%.*} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null -qm set $VMID \ - -efidisk0 ${DISK0_REF},efitype=4m,size=4M \ - -scsi0 ${DISK1_REF},size=32G >/dev/null -qm set $VMID \ - -boot order=scsi0 >/dev/null -qm set $VMID -description "# Home Assistant OS -### https://github.com/tteck/Proxmox" >/dev/null -msg_ok "Created HAOS VM ${CL}${BL}${VM_NAME}" - -if [ "$START_VM" == "yes" ]; then -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/haos-vm.sh b/vm/haos-vm.sh new file mode 100644 index 00000000..90bb9751 --- /dev/null +++ b/vm/haos-vm.sh @@ -0,0 +1,466 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 "\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) +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") +BFR="\\r\\033[K" +HOLD=" " +CM="${GN}✓${CL}" +CROSS="${RD}✗${CL}" +THIN="discard=on,ssd=1," +SPINNER_PID="" +set -Eeuo pipefail +trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +trap cleanup EXIT + +function error_handler() { + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi + printf "\e[?25h" + 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" + cleanup_vmid +} + +function cleanup_vmid() { + if qm status $VMID &>/dev/null; then + qm stop $VMID &>/dev/null + qm destroy $VMID &>/dev/null + fi +} + +function cleanup() { + popd >/dev/null + rm -rf $TEMP_DIR +} + +TEMP_DIR=$(mktemp -d) +pushd $TEMP_DIR >/dev/null +if whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOME ASSISTANT OS VM" --yesno "This will create a New Home Assistant OS VM. Proceed?" 10 58; then + : +else + header_info && echo -e "⚠ User exited script \n" && exit +fi + +function spinner() { + local chars="/-\|" + local spin_i=0 + printf "\e[?25l" + while true; do + printf "\r \e[36m%s\e[0m" "${chars:spin_i++%${#chars}:1}" + sleep 0.1 + done +} + +function msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg} " + spinner & + SPINNER_PID=$! +} + +function msg_ok() { + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi + printf "\e[?25h" + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" +} + +function msg_error() { + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi + printf "\e[?25h" + local msg="$1" + echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" +} + +function check_root() { + if [[ "$(id -u)" -ne 0 || $(ps -o comm= -p $PPID) == "sudo" ]]; then + clear + msg_error "Please run this script as root." + echo -e "\nExiting..." + sleep 2 + exit + fi +} + +function pve_check() { + if ! pveversion | grep -Eq "pve-manager/8.[1-3]"; then + msg_error "This version of Proxmox Virtual Environment is not supported" + echo -e "Requires Proxmox Virtual Environment Version 8.1 or later." + echo -e "Exiting..." + sleep 2 + exit +fi +} + +function arch_check() { + if [ "$(dpkg --print-architecture)" != "amd64" ]; then + msg_error "This script will not work with PiMox! \n" + echo -e "Exiting..." + sleep 2 + exit + fi +} + +function ssh_check() { + if command -v pveversion >/dev/null 2>&1; then + if [ -n "${SSH_CLIENT:+x}" ]; then + if whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SSH DETECTED" --yesno "It's suggested to use the Proxmox shell instead of SSH, since SSH can create issues while gathering variables. Would you like to proceed with using SSH?" 10 62; then + echo "you've been warned" + else + clear + exit + fi + fi + fi +} + +function exit-script() { + clear + echo -e "⚠ User exited script \n" + exit +} + +function default_settings() { + BRANCH="$stable" + VMID="$NEXTID" + FORMAT=",efitype=4m" + MACHINE="" + DISK_CACHE="cache=writethrough," + HN="haos$stable" + CPU_TYPE=" -cpu host" + CORE_COUNT="2" + RAM_SIZE="4096" + BRG="vmbr0" + MAC="$GEN_MAC" + VLAN="" + MTU="" + START_VM="yes" + echo -e "${DGN}Using HAOS Version: ${BGN}${BRANCH}${CL}" + echo -e "${DGN}Using Virtual Machine ID: ${BGN}${VMID}${CL}" + echo -e "${DGN}Using Machine Type: ${BGN}i440fx${CL}" + echo -e "${DGN}Using Disk Cache: ${BGN}Write Through${CL}" + echo -e "${DGN}Using Hostname: ${BGN}${HN}${CL}" + echo -e "${DGN}Using CPU Model: ${BGN}Host${CL}" + echo -e "${DGN}Allocated Cores: ${BGN}${CORE_COUNT}${CL}" + echo -e "${DGN}Allocated RAM: ${BGN}${RAM_SIZE}${CL}" + echo -e "${DGN}Using Bridge: ${BGN}${BRG}${CL}" + echo -e "${DGN}Using MAC Address: ${BGN}${MAC}${CL}" + echo -e "${DGN}Using VLAN: ${BGN}Default${CL}" + echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" + echo -e "${DGN}Start VM when completed: ${BGN}yes${CL}" + echo -e "${BL}Creating a HAOS VM using the above default settings${CL}" +} + +function advanced_settings() { + if BRANCH=$(whiptail --backtitle "Proxmox VE Helper Scripts" --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); then + echo -e "${DGN}Using HAOS Version: ${BGN}$BRANCH${CL}" + else + exit-script + fi + + while true; do + if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z "$VMID" ]; then + VMID="$NEXTID" + fi + 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 + else + exit-script + fi + done + + if MACH=$(whiptail --backtitle "Proxmox VE Helper Scripts" --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); then + 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 + else + exit-script + fi + + if DISK_CACHE1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "DISK CACHE" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \ + "0" "None" OFF \ + "1" "Write Through (Default)" ON \ + 3>&1 1>&2 2>&3); then + if [ $DISK_CACHE1 = "1" ]; then + echo -e "${DGN}Using Disk Cache: ${BGN}Write Through${CL}" + DISK_CACHE="cache=writethrough," + else + echo -e "${DGN}Using Disk Cache: ${BGN}None${CL}" + DISK_CACHE="" + fi + else + exit-script + fi + + if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 haos${BRANCH} --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $VM_NAME ]; then + HN="haos${BRANCH}" + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + else + HN=$(echo ${VM_NAME,,} | tr -d ' ') + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + fi + else + exit-script + fi + + if CPU_TYPE1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "CPU MODEL" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \ + "0" "KVM64" OFF \ + "1" "Host (Default)" ON \ + 3>&1 1>&2 2>&3); then + if [ $CPU_TYPE1 = "1" ]; then + echo -e "${DGN}Using CPU Model: ${BGN}Host${CL}" + CPU_TYPE=" -cpu host" + else + echo -e "${DGN}Using CPU Model: ${BGN}KVM64${CL}" + CPU_TYPE="" + fi + else + exit-script + fi + + if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $CORE_COUNT ]; then + CORE_COUNT="2" + 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 --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 4096 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $RAM_SIZE ]; then + RAM_SIZE="4096" + 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 --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 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 MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $MAC1 ]; then + MAC="$GEN_MAC" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}" + else + MAC="$MAC1" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" + fi + else + exit-script + fi + + if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); 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 + else + exit-script + fi + + if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); 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 + else + exit-script + fi + + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 + echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" + START_VM="no" + fi + + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 +} + +function start_script() { + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 +} + +check_root +arch_check +pve_check +ssh_check +start_script + +msg_info "Validating Storage" +while read -r line; do + TAG=$(echo $line | awk '{print $1}') + TYPE=$(echo $line | awk '{printf "%-10s", $2}') + FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') + ITEM=" Type: $TYPE Free: $FREE " + OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + 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." + exit +elif [ $((${#STORAGE_MENU[@]} / 3)) -eq 1 ]; then + STORAGE=${STORAGE_MENU[0]} +else + while [ -z "${STORAGE:+x}" ]; do + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi + printf "\e[?25h" + STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Storage Pools" --radiolist \ + "Which storage pool you would like to use for ${HN}?\nTo make a selection, use the Spacebar.\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-artifacts.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 +fi +sleep 2 +msg_ok "${CL}${BL}${URL}${CL}" +wget -q --show-progress $URL +echo -en "\e[1A\e[0K" +FILE=$(basename $URL) +msg_ok "Downloaded ${CL}${BL}haos_ova-${BRANCH}.qcow2.xz${CL}" +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 | local-zfs) + DISK_EXT=".raw" + DISK_REF="$VMID/" + DISK_IMPORT="-format raw" + FORMAT=",efitype=4m" + THIN="" + ;; +esac +for i in {0,1}; do + disk="DISK$i" + eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-} + eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk} +done +msg_ok "Extracted KVM Disk Image" +msg_info "Creating HAOS VM" +qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \ + -name $HN -tags proxmox-helper-scripts -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci +pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null +qm importdisk $VMID ${FILE%.*} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null +qm set $VMID \ + -efidisk0 ${DISK0_REF}${FORMAT} \ + -scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=32G \ + -boot order=scsi0 \ + -description "<div align='center'><a href='https://Helper-Scripts.com' target='_blank' rel='noopener noreferrer'><img src='https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/logo-81x112.png'/></a> + + # Home Assistant OS + + <a href='https://ko-fi.com/D1D7EP4GF'><img src='https://img.shields.io/badge/☕-Buy me a coffee-blue' /></a> + </div>" >/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" +fi +msg_ok "Completed Successfully!\n" diff --git a/vm/haos_vm.sh b/vm/haos_vm.sh deleted file mode 100644 index 1153be37..00000000 --- a/vm/haos_vm.sh +++ /dev/null @@ -1,352 +0,0 @@ -#!/usr/bin/env bash -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) -RELEASE=$(curl -sX GET "https://api.github.com/repos/home-assistant/operating-system/releases" | awk '/tag_name/{print $4;exit}' FS='[""]') -STABLE="8.1" -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}" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -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 - [ ! -z ${VMID-} ] && cleanup_vmid - exit $EXIT -} - -function cleanup_vmid() { - if $(qm status $VMID &>/dev/null); then - if [ "$(qm status $VMID | awk '{print $2}')" == "running" ]; then - qm stop $VMID - fi - qm destroy $VMID - fi -} - -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -while true; do - clear - read -p "This will create a New Home Assistant OS VM. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear - -function header_info { -echo -e "${BL} - _ _ ____ _____ - | | | | /\ / __ \ / ____| - | |__| | / \ | | | | (___ - | __ | / /\ \| | | |\___ \ - | | | |/ ____ \ |__| |____) | - |_| |_/_/ ${CL}${YW}v3${CL}${BL} \_\____/|_____/ -${CL}" -} -header_info - -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 default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using Version ${BGN}${STABLE}${CL}" - BRANCH=${STABLE} - echo -e "${DGN}Using VM ID ${BGN}$NEXTID${CL}" - VMID=$NEXTID - echo -e "${DGN}Using VM Name ${BGN}haos${STABLE}${CL}" - VM_NAME=haos${STABLE} - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}4096${CL}${DGN}MiB RAM${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 Tag ${BGN}NONE${CL}" - VLAN="" - echo -e "${DGN}Start VM when completed ${BGN}yes${CL}" - START_VM="yes" - -} -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Latest for Version ${RELEASE}, or Press [ENTER] for Stable Version ${STABLE} " - read BRANCH - if [ -z $BRANCH ]; then BRANCH=$STABLE; - else - BRANCH=$RELEASE; fi; - echo -en "${DGN}Set Version To ${BL}$BRANCH${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${YW}Enter the VM ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read VMID - if [ -z $VMID ]; then VMID=$NEXTID; fi; - echo -en "${DGN}Set VM ID To ${BL}$VMID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${YW}Enter VM Name (no-spaces), or Press [ENTER] for Default: haos${BRANCH} " - read VMNAME - if [ -z $VMNAME ]; then - VM_NAME=haos${BRANCH} - else - VM_NAME=$(echo ${VMNAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$VM_NAME${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}${CORE_COUNT}${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 4096 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="4096"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Valid MAC Address, or Press [ENTER] for Generated MAC: $GEN_MAC " - read MAC - if [ -z $MAC ]; then MAC=$GEN_MAC; fi; - echo -en "${DGN}Set MAC Address To ${BL}$MAC${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using MAC Address ${BGN}$MAC${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using MAC Address ${BGN}$MAC${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - echo -e "${YW}Start VM when completed, or Press [ENTER] for Default: yes " - read START_VM - if [ -z $START_VM ]; then START_VM="yes"; - else - START_VM="no"; fi; - echo -en "${DGN}Starting VM when completed ${BL}$START_VM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using MAC Address ${BGN}$MAC${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - echo -e "${DGN}Start VM when completed ${BGN}$START_VM${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content images | awk 'NR>1') -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 - 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 - 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 "Getting URL for Home Assistant ${BRANCH} Disk Image" -URL=https://github.com/home-assistant/operating-system/releases/download/${BRANCH}/haos_ova-${BRANCH}.qcow2.xz -sleep 2 -msg_ok "${CL}${BL}${URL}${CL}" -wget -q --show-progress $URL -echo -en "\e[1A\e[0K" -FILE=$(basename $URL) -msg_ok "Downloaded ${CL}${BL}haos_ova-${BRANCH}.qcow2.xz${CL}" -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=".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" - eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-} - eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk} -done -msg_ok "Extracted KVM Disk Image" - -msg_info "Creating HAOS VM" -qm create $VMID -agent 1 -bios ovmf -cores $CORE_COUNT -memory $RAM_SIZE -name $VM_NAME -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN \ - -onboot 1 -ostype l26 -scsihw virtio-scsi-pci -pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null -qm importdisk $VMID ${FILE%.*} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null -qm set $VMID \ - -efidisk0 ${DISK0_REF},efitype=4m,size=4M \ - -scsi0 ${DISK1_REF},size=32G >/dev/null -qm set $VMID \ - -boot order=scsi0 >/dev/null -qm set $VMID -description "# Home Assistant OS -### https://github.com/tteck/Proxmox" >/dev/null - -msg_ok "Created HAOS VM ${CL}${BL}${VM_NAME}" - -if [ "$START_VM" == "yes" ]; then -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.sh b/vm/mikrotik-routeros.sh new file mode 100644 index 00000000..29b41892 --- /dev/null +++ b/vm/mikrotik-routeros.sh @@ -0,0 +1,285 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + cat <<"EOF" + __ ____ __ __ _ __ ____ __ ____ _____ ________ ______ + / |/ (_) /___________ / /_(_) /__ / __ \____ __ __/ /____ _____/ __ \/ ___/ / ____/ / / / __ \ + / /|_/ / / //_/ ___/ __ \/ __/ / //_/ / /_/ / __ \/ / / / __/ _ \/ ___/ / / /\__ \ / / / /_/ / /_/ / + / / / / / ,< / / / /_/ / /_/ / ,< / _, _/ /_/ / /_/ / /_/ __/ / / /_/ /___/ / / /___/ __ / _, _/ +/_/ /_/_/_/|_/_/ \____/\__/_/_/|_| /_/ |_|\____/\__,_/\__/\___/_/ \____//____/ \____/_/ /_/_/ |_| + +EOF +} +clear +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") +BFR="\\r\\033[K" +HOLD="-" +CM="${GN}✓${CL}" +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail +shopt -s expand_aliases +alias die='EXIT=$? LINE=$LINENO error_exit' +trap die ERR +trap cleanup EXIT +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 + [ ! -z ${VMID-} ] && cleanup_vmid + exit $EXIT +} +function cleanup_vmid() { + if $(qm status $VMID &>/dev/null); then + if [ "$(qm status $VMID | awk '{print $2}')" == "running" ]; then + qm stop $VMID + fi + qm destroy $VMID + fi +} +function cleanup() { + popd >/dev/null + rm -rf $TEMP_DIR +} +TEMP_DIR=$(mktemp -d) +pushd $TEMP_DIR >/dev/null +if ! pveversion | grep -Eq "pve-manager/8.[1-3]"; then + msg_error "This version of Proxmox Virtual Environment is not supported" + echo -e "Requires Proxmox Virtual Environment Version 8.1 or later." + echo -e "Exiting..." + sleep 2 + exit +fi +if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "Mikrotik RouterOS CHR VM" --yesno "This will create a New Mikrotik RouterOS CHR VM. Proceed?" 10 58); then + echo "User selected Yes" +else + clear + echo -e "⚠ User exited script \n" + exit +fi + +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 default_settings() { + echo -e "${DGN}Using Virtual Machine ID: ${BGN}$NEXTID${CL}" + VMID=$NEXTID + echo -e "${DGN}Using Hostname: ${BGN}mikrotik-routeros-chr${CL}" + HN=mikrotik-routeros-chr + echo -e "${DGN}Allocated Cores: ${BGN}1${CL}" + CORE_COUNT="2" + echo -e "${DGN}Allocated RAM: ${BGN}256${CL}" + RAM_SIZE="512" + 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 CHR VM using the above default settings${CL}" +} +function advanced_settings() { + VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --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 + exit + fi + VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 mikrotik-routeros-chr --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 + exit + fi + CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" 3>&1 1>&2 2>&3) + exitstatus=$? + if [ $exitstatus = 0 ]; then + echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" + else + exit + fi + RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 512 --title "RAM" 3>&1 1>&2 2>&3) + exitstatus=$? + if [ $exitstatus = 0 ]; then + echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" + else + exit + fi + BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --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 + exit + fi + MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --title "START VIRTUAL MACHINE" --yesno "Start Mikrotik RouterOS CHR VM when completed?" 10 58); then + echo -e "${DGN}Start Mikrotik RouterOS CHR VM when completed: ${BGN}yes${CL}" + START_VM="yes" + else + echo -e "${DGN}Start Mikrotik RouterOS CHR VM when completed: ${BGN}no${CL}" + START_VM="no" + fi + if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create Mikrotik RouterOS VM?" 10 58); then + echo -e "${RD}Creating Mikrotik RouterOS CHR VM using the above advanced settings${CL}" + else + clear + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi +} +function start_script() { + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 +} +start_script +msg_info "Validating Storage" +while read -r line; do + TAG=$(echo $line | awk '{print $1}') + TYPE=$(echo $line | awk '{printf "%-10s", $2}') + FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') + ITEM=" Type: $TYPE Free: $FREE " + OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + 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 + STORAGE=${STORAGE_MENU[0]} +else + while [ -z "${STORAGE:+x}" ]; do + STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Storage Pools" --radiolist \ + "Which storage pool you would like to use for the Mikrotik RouterOS CHR 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 "Getting URL for Mikrotik RouterOS CHR Disk Image" + +URL=https://download.mikrotik.com/routeros/7.15.2/chr-7.15.2.img.zip + +sleep 2 +msg_ok "${CL}${BL}${URL}${CL}" +wget -q --show-progress $URL +echo -en "\e[1A\e[0K" +FILE=$(basename $URL) +msg_ok "Downloaded ${CL}${BL}$FILE${CL}" +msg_info "Extracting Mikrotik RouterOS CHR 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 | zfspool) + DISK_EXT="" + DISK_REF="$VMID/" + DISK_IMPORT="-format raw" + ;; +esac + +DISK_VAR="vm-${VMID}-disk-0${DISK_EXT:-}" +DISK_REF="${STORAGE}:${DISK_REF:-}${DISK_VAR:-}" + +msg_ok "Extracted Mikrotik RouterOS CHR Disk Image" +msg_info "Creating Mikrotik RouterOS CHR VM" +qm create $VMID -tablet 0 -localtime 1 -cores $CORE_COUNT -memory $RAM_SIZE -name $HN \ + -tags proxmox-helper-scripts -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU \ + -onboot 1 -ostype l26 -scsihw virtio-scsi-pci +qm importdisk $VMID ${FILE%.*} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null +qm set $VMID \ + -scsi0 "$DISK_REF" \ + -boot order=scsi0 \ + -description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/logo-81x112.png'/></a> + + # Mikrotik RouterOS CHR + + <a href='https://ko-fi.com/D1D7EP4GF'><img src='https://img.shields.io/badge/☕-Buy me a coffee-blue' /></a> + </div>" >/dev/null +msg_ok "Mikrotik RouterOS CHR VM ${CL}${BL}(${HN})" +if [ "$START_VM" == "yes" ]; then + msg_info "Starting Mikrotik RouterOS CHR VM" + qm start $VMID + msg_ok "Started Mikrotik RouterOS CHR VM" +fi +msg_ok "Completed Successfully!\n" diff --git a/vm/nextcloud-vm.sh b/vm/nextcloud-vm.sh new file mode 100644 index 00000000..1e50c37d --- /dev/null +++ b/vm/nextcloud-vm.sh @@ -0,0 +1,423 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 "\n Loading..." +GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//') +NEXTID=$(pvesh get /cluster/nextid) +NAME="TurnKey Nexcloud VM" +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}" +CROSS="${RD}✗${CL}" +THIN="discard=on,ssd=1," +set -e +trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +trap cleanup EXIT +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" + cleanup_vmid +} + +function cleanup_vmid() { + if qm status $VMID &>/dev/null; then + qm stop $VMID &>/dev/null + qm destroy $VMID &>/dev/null + fi +} + +function cleanup() { + popd >/dev/null + rm -rf $TEMP_DIR +} + +TEMP_DIR=$(mktemp -d) +pushd $TEMP_DIR >/dev/null +if whiptail --backtitle "Proxmox VE Helper Scripts" --title "$NAME" --yesno "This will create a New $NAME. Proceed?" 10 58; then + : +else + header_info && echo -e "⚠ User exited script \n" && exit +fi + +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 check_root() { + if [[ "$(id -u)" -ne 0 || $(ps -o comm= -p $PPID) == "sudo" ]]; then + clear + msg_error "Please run this script as root." + echo -e "\nExiting..." + sleep 2 + exit + fi +} + +function pve_check() { + if ! pveversion | grep -Eq "pve-manager/8.[1-3]"; then + msg_error "This version of Proxmox Virtual Environment is not supported" + echo -e "Requires Proxmox Virtual Environment Version 8.1 or later." + echo -e "Exiting..." + sleep 2 + exit +fi +} + +function arch_check() { + if [ "$(dpkg --print-architecture)" != "amd64" ]; then + msg_error "This script will not work with PiMox! \n" + echo -e "Exiting..." + sleep 2 + exit + fi +} + +function ssh_check() { + if command -v pveversion >/dev/null 2>&1; then + if [ -n "${SSH_CLIENT:+x}" ]; then + if whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SSH DETECTED" --yesno "It's suggested to use the Proxmox shell instead of SSH, since SSH can create issues while gathering variables. Would you like to proceed with using SSH?" 10 62; then + echo "you've been warned" + else + clear + exit + fi + fi + fi +} + +function exit-script() { + clear + echo -e "⚠ User exited script \n" + exit +} + +function default_settings() { + VMID="$NEXTID" + FORMAT=",efitype=4m" + MACHINE="" + DISK_CACHE="" + HN="turnkey-nextcloud-vm" + CPU_TYPE="" + CORE_COUNT="2" + RAM_SIZE="2048" + BRG="vmbr0" + MAC="$GEN_MAC" + VLAN="" + MTU="" + START_VM="no" + echo -e "${DGN}Using Virtual Machine ID: ${BGN}${VMID}${CL}" + echo -e "${DGN}Using Machine Type: ${BGN}i440fx${CL}" + echo -e "${DGN}Using Disk Cache: ${BGN}None${CL}" + echo -e "${DGN}Using Hostname: ${BGN}${HN}${CL}" + echo -e "${DGN}Using CPU Model: ${BGN}KVM64${CL}" + echo -e "${DGN}Allocated Cores: ${BGN}${CORE_COUNT}${CL}" + echo -e "${DGN}Allocated RAM: ${BGN}${RAM_SIZE}${CL}" + echo -e "${DGN}Using Bridge: ${BGN}${BRG}${CL}" + echo -e "${DGN}Using MAC Address: ${BGN}${MAC}${CL}" + echo -e "${DGN}Using VLAN: ${BGN}Default${CL}" + echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" + echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" + echo -e "${BL}Creating a $NAME using the above default settings${CL}" +} + +function advanced_settings() { + while true; do + if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z "$VMID" ]; then + VMID="$NEXTID" + fi + 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 + else + exit-script + fi + done + + if MACH=$(whiptail --backtitle "Proxmox VE Helper Scripts" --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); then + 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 + else + exit-script + fi + + if DISK_CACHE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "DISK CACHE" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \ + "0" "None (Default)" ON \ + "1" "Write Through" OFF \ + 3>&1 1>&2 2>&3); then + if [ $DISK_CACHE = "1" ]; then + echo -e "${DGN}Using Disk Cache: ${BGN}Write Through${CL}" + DISK_CACHE="cache=writethrough," + else + echo -e "${DGN}Using Disk Cache: ${BGN}None${CL}" + DISK_CACHE="" + fi + else + exit-script + fi + + if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 $HN --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $VM_NAME ]; then + HN="$HN" + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + else + HN=$(echo ${VM_NAME,,} | tr -d ' ') + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + fi + else + exit-script + fi + + if CPU_TYPE1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "CPU MODEL" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \ + "0" "KVM64 (Default)" ON \ + "1" "Host" OFF \ + 3>&1 1>&2 2>&3); then + if [ $CPU_TYPE1 = "1" ]; then + echo -e "${DGN}Using CPU Model: ${BGN}Host${CL}" + CPU_TYPE=" -cpu host" + else + echo -e "${DGN}Using CPU Model: ${BGN}KVM64${CL}" + CPU_TYPE="" + fi + else + exit-script + fi + + if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $CORE_COUNT ]; then + CORE_COUNT="2" + 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 --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 2048 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $RAM_SIZE ]; then + RAM_SIZE="2048" + 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 --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 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 MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $MAC1 ]; then + MAC="$GEN_MAC" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}" + else + MAC="$MAC1" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" + fi + else + exit-script + fi + + if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); 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 + else + exit-script + fi + + if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); 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 + else + exit-script + fi + + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 + echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" + START_VM="no" + fi + + if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create a $NAME?" --no-button Do-Over 10 58); then + echo -e "${RD}Creating a $NAME using the above advanced settings${CL}" + else + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi +} + +function start_script() { + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 +} + +check_root +arch_check +pve_check +ssh_check +start_script + +msg_info "Validating Storage" +while read -r line; do + TAG=$(echo $line | awk '{print $1}') + TYPE=$(echo $line | awk '{printf "%-10s", $2}') + FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') + ITEM=" Type: $TYPE Free: $FREE " + OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + 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." + exit +elif [ $((${#STORAGE_MENU[@]} / 3)) -eq 1 ]; then + STORAGE=${STORAGE_MENU[0]} +else + while [ -z "${STORAGE:+x}" ]; do + STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Storage Pools" --radiolist \ + "Which storage pool you would like to use for ${HN}?\nTo make a selection, use the Spacebar.\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 the $NAME Disk Image" +URL=http://mirror.turnkeylinux.org/turnkeylinux/images/iso/turnkey-nextcloud-18.0-bookworm-amd64.iso +sleep 2 +msg_ok "${CL}${BL}${URL}${CL}" +wget -q --show-progress $URL +echo -en "\e[1A\e[0K" +FILE=$(basename $URL) +msg_ok "Downloaded ${CL}${BL}${FILE}${CL}" + +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="" + ;; +esac +for i in {0,1}; do + disk="DISK$i" + eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-} + eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk} +done + +msg_info "Creating a $NAME" +qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios seabios${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \ + -name $HN -tags proxmox-helper-scripts -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci +pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null +qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null +qm set $VMID \ + -efidisk0 ${DISK0_REF}${FORMAT} \ + -scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=12G \ + -boot order=scsi0 \ + -description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/logo-81x112.png'/></a> + + # $NAME + + <a href='https://ko-fi.com/D1D7EP4GF'><img src='https://img.shields.io/badge/☕-Buy me a coffee-blue' /></a> + </div>" >/dev/null +msg_ok "Created a $NAME ${CL}${BL}(${HN})" +if [ "$START_VM" == "yes" ]; then + msg_info "Starting $NAME" + qm start $VMID + msg_ok "Started $NAME" +fi +msg_ok "Completed Successfully!\n" diff --git a/vm/openwrt.sh b/vm/openwrt.sh new file mode 100644 index 00000000..3cdd38f3 --- /dev/null +++ b/vm/openwrt.sh @@ -0,0 +1,523 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# Jon Spriggs (jontheniceguy) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE +# Based on work from https://i12bretro.github.io/tutorials/0405.html + +function header_info { + clear + cat <<"EOF" + ____ _ __ __ + / __ \____ ___ ____| | / /____/ /_ + / / / / __ \/ _ \/ __ \ | /| / / ___/ __/ +/ /_/ / /_/ / __/ / / / |/ |/ / / / /_ +\____/ .___/\___/_/ /_/|__/|__/_/ \__/ + /_/ W I R E L E S S F R E E D O M + +EOF +} +header_info +echo -e "Loading..." +GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//') +GEN_MAC_LAN=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//') +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") +BFR="\\r\\033[K" +HOLD="-" +CM="${GN}✓${CL}" +CROSS="${RD}✗${CL}" +set -Eeo pipefail +trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +trap cleanup EXIT +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" + cleanup_vmid +} + +function cleanup_vmid() { + if qm status $VMID &>/dev/null; then + qm stop $VMID &>/dev/null + qm destroy $VMID &>/dev/null + fi +} + +function cleanup() { + popd >/dev/null + rm -rf $TEMP_DIR +} + +TEMP_DIR=$(mktemp -d) +pushd $TEMP_DIR >/dev/null +function send_line_to_vm() { + echo -e "${DGN}Sending line: ${YW}$1${CL}" + for ((i = 0; i < ${#1}; i++)); do + character=${1:i:1} + case $character in + " ") character="spc" ;; + "-") character="minus" ;; + "=") character="equal" ;; + ",") character="comma" ;; + ".") character="dot" ;; + "/") character="slash" ;; + "'") character="apostrophe" ;; + ";") character="semicolon" ;; + '\') character="backslash" ;; + '`') character="grave_accent" ;; + "[") character="bracket_left" ;; + "]") character="bracket_right" ;; + "_") character="shift-minus" ;; + "+") character="shift-equal" ;; + "?") character="shift-slash" ;; + "<") character="shift-comma" ;; + ">") character="shift-dot" ;; + '"') character="shift-apostrophe" ;; + ":") character="shift-semicolon" ;; + "|") character="shift-backslash" ;; + "~") character="shift-grave_accent" ;; + "{") character="shift-bracket_left" ;; + "}") character="shift-bracket_right" ;; + "A") character="shift-a" ;; + "B") character="shift-b" ;; + "C") character="shift-c" ;; + "D") character="shift-d" ;; + "E") character="shift-e" ;; + "F") character="shift-f" ;; + "G") character="shift-g" ;; + "H") character="shift-h" ;; + "I") character="shift-i" ;; + "J") character="shift-j" ;; + "K") character="shift-k" ;; + "L") character="shift-l" ;; + "M") character="shift-m" ;; + "N") character="shift-n" ;; + "O") character="shift-o" ;; + "P") character="shift-p" ;; + "Q") character="shift-q" ;; + "R") character="shift-r" ;; + "S") character="shift-s" ;; + "T") character="shift-t" ;; + "U") character="shift-u" ;; + "V") character="shift-v" ;; + "W") character="shift-w" ;; + "X") character="shift=x" ;; + "Y") character="shift-y" ;; + "Z") character="shift-z" ;; + "!") character="shift-1" ;; + "@") character="shift-2" ;; + "#") character="shift-3" ;; + '$') character="shift-4" ;; + "%") character="shift-5" ;; + "^") character="shift-6" ;; + "&") character="shift-7" ;; + "*") character="shift-8" ;; + "(") character="shift-9" ;; + ")") character="shift-0" ;; + esac + qm sendkey $VMID "$character" + done + qm sendkey $VMID ret +} + +TEMP_DIR=$(mktemp -d) +pushd $TEMP_DIR >/dev/null + +if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "OpenWrt VM" --yesno "This will create a New OpenWrt VM. Proceed?" 10 58); then + : +else + header_info && echo -e "⚠ User exited script \n" && exit +fi + +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 -Eq "pve-manager/8.[1-3]"; then + msg_error "This version of Proxmox Virtual Environment is not supported" + echo -e "Requires Proxmox Virtual Environment Version 8.1 or later." + 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 ssh_check() { + if command -v pveversion >/dev/null 2>&1; then + if [ -n "${SSH_CLIENT:+x}" ]; then + if whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SSH DETECTED" --yesno "It's suggested to use the Proxmox shell instead of SSH, since SSH can create issues while gathering variables. Would you like to proceed with using SSH?" 10 62; then + echo "you've been warned" + else + clear + exit + fi + fi + fi +} + +function exit-script() { + clear + echo -e "⚠ User exited script \n" + exit +} + +function default_settings() { + VMID=$NEXTID + HN=openwrt + CORE_COUNT="1" + RAM_SIZE="256" + BRG="vmbr0" + VLAN="" + MAC=$GEN_MAC + LAN_MAC=$GEN_MAC_LAN + LAN_BRG="vmbr0" + LAN_IP_ADDR="192.168.1.1" + LAN_NETMASK="255.255.255.0" + LAN_VLAN=",tag=999" + MTU="" + START_VM="yes" + echo -e "${DGN}Using Virtual Machine ID: ${BGN}${VMID}${CL}" + echo -e "${DGN}Using Hostname: ${BGN}${HN}${CL}" + echo -e "${DGN}Allocated Cores: ${BGN}${CORE_COUNT}${CL}" + echo -e "${DGN}Allocated RAM: ${BGN}${RAM_SIZE}${CL}" + echo -e "${DGN}Using WAN Bridge: ${BGN}${BRG}${CL}" + echo -e "${DGN}Using WAN VLAN: ${BGN}Default${CL}" + echo -e "${DGN}Using WAN MAC Address: ${BGN}${MAC}${CL}" + echo -e "${DGN}Using LAN MAC Address: ${BGN}${LAN_MAC}${CL}" + echo -e "${DGN}Using LAN Bridge: ${BGN}${LAN_BRG}${CL}" + echo -e "${DGN}Using LAN VLAN: ${BGN}999${CL}" + echo -e "${DGN}Using LAN IP Address: ${BGN}${LAN_IP_ADDR}${CL}" + echo -e "${DGN}Using LAN NETMASK: ${BGN}${LAN_NETMASK}${CL}" + echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" + echo -e "${DGN}Start VM when completed: ${BGN}yes${CL}" + echo -e "${BL}Creating a OpenWRT VM using the above default settings${CL}" +} + +function advanced_settings() { + while true; do + if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z "$VMID" ]; then + VMID="$NEXTID" + fi + 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 + else + exit-script + fi + done + + if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 openwrt --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $VM_NAME ]; then + HN="openwrt" + else + HN=$(echo ${VM_NAME,,} | tr -d ' ') + fi + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + else + exit-script + fi + + if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 1 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $CORE_COUNT ]; then + CORE_COUNT="1" + fi + echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}" + else + exit-script + fi + + if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 256 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $RAM_SIZE ]; then + RAM_SIZE="256" + fi + echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}" + else + exit-script + fi + + if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN Bridge" 8 58 vmbr0 --title "WAN BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $BRG ]; then + BRG="vmbr0" + fi + echo -e "${DGN}Using WAN Bridge: ${BGN}$BRG${CL}" + else + exit-script + fi + + if LAN_BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN Bridge" 8 58 vmbr0 --title "LAN BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $LAN_BRG ]; then + LAN_BRG="vmbr0" + fi + echo -e "${DGN}Using LAN Bridge: ${BGN}$LAN_BRG${CL}" + else + exit-script + fi + + if LAN_IP_ADDR=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a router IP" 8 58 $LAN_IP_ADDR --title "LAN IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $LAN_IP_ADDR ]; then + LAN_IP_ADDR="192.168.1.1" + fi + echo -e "${DGN}Using LAN IP ADDRESS: ${BGN}$LAN_IP_ADDR${CL}" + else + exit-script + fi + + if LAN_NETMASK=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a router netmmask" 8 58 $LAN_NETMASK --title "LAN NETMASK" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $LAN_NETMASK ]; then + LAN_NETMASK="255.255.255.0" + fi + echo -e "${DGN}Using LAN NETMASK: ${BGN}$LAN_NETMASK${CL}" + else + exit-script + fi + + if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN MAC Address" 8 58 $GEN_MAC --title "WAN MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $MAC1 ]; then + MAC="$GEN_MAC" + else + MAC="$MAC1" + fi + echo -e "${DGN}Using WAN MAC Address: ${BGN}$MAC${CL}" + else + exit-script + fi + + if MAC2=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN MAC Address" 8 58 $GEN_MAC_LAN --title "LAN MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $MAC2 ]; then + LAN_MAC="$GEN_MAC_LAN" + else + LAN_MAC="$MAC2" + fi + echo -e "${DGN}Using LAN MAC Address: ${BGN}$LAN_MAC${CL}" + else + exit-script + fi + + if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN Vlan (leave blank for default)" 8 58 --title "WAN VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $VLAN1 ]; then + VLAN1="Default" + VLAN="" + else + VLAN=",tag=$VLAN1" + fi + echo -e "${DGN}Using WAN Vlan: ${BGN}$VLAN1${CL}" + else + exit-script + fi + + if VLAN2=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN Vlan" 8 58 999 --title "LAN VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $VLAN2 ]; then + VLAN2="999" + LAN_VLAN=",tag=$VLAN2" + else + LAN_VLAN=",tag=$VLAN2" + fi + echo -e "${DGN}Using LAN Vlan: ${BGN}$VLAN2${CL}" + else + exit-script + fi + + if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 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 (whiptail --backtitle "Proxmox VE Helper Scripts" --title "START VIRTUAL MACHINE" --yesno "Start VM when completed?" 10 58); then + START_VM="yes" + else + START_VM="no" + fi + echo -e "${DGN}Start VM when completed: ${BGN}$START_VM${CL}" + + if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create OpenWrt VM?" --no-button Do-Over 10 58); then + echo -e "${RD}Creating a OpenWrt VM using the above advanced settings${CL}" + else + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi +} + +function start_script() { + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 +ssh_check +start_script + +msg_info "Validating Storage" +while read -r line; do + TAG=$(echo $line | awk '{print $1}') + TYPE=$(echo $line | awk '{printf "%-10s", $2}') + FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') + ITEM=" Type: $TYPE Free: $FREE " + OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + 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 + STORAGE=${STORAGE_MENU[0]} +else + while [ -z "${STORAGE:+x}" ]; do + STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Storage Pools" --radiolist \ + "Which storage pool you would like to use for the OpenWrt 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 "Getting URL for OpenWrt Disk Image" + +response=$(curl -s https://openwrt.org) +stableversion=$(echo "$response" | sed -n 's/.*Current stable release - OpenWrt \([0-9.]\+\).*/\1/p') +URL="https://downloads.openwrt.org/releases/$stableversion/targets/x86/64/openwrt-$stableversion-x86-64-generic-ext4-combined.img.gz" + +sleep 2 +msg_ok "${CL}${BL}${URL}${CL}" +wget -q --show-progress $URL +echo -en "\e[1A\e[0K" +FILE=$(basename $URL) +msg_ok "Downloaded ${CL}${BL}$FILE${CL}" +gunzip -f $FILE >/dev/null 2>/dev/null || true +NEWFILE="${FILE%.*}" +FILE="$NEWFILE" +mv $FILE ${FILE%.*} +qemu-img resize -f raw ${FILE%.*} 512M >/dev/null 2>/dev/null +msg_ok "Extracted & Resized OpenWrt Disk Image ${CL}${BL}$FILE${CL}" +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_IMPORT="-format raw" + ;; +esac +for i in {0,1}; do + disk="DISK$i" + eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-} + eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk} +done + +msg_info "Creating OpenWrt VM" +qm create $VMID -cores $CORE_COUNT -memory $RAM_SIZE -name $HN \ + -onboot 1 -ostype l26 -scsihw virtio-scsi-pci --tablet 0 +pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null +qm importdisk $VMID ${FILE%.*} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null +qm set $VMID \ + -efidisk0 ${DISK0_REF},efitype=4m,size=4M \ + -scsi0 ${DISK1_REF},size=512M \ + -boot order=scsi0 \ + -tags proxmox-helper-scripts \ + -description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/logo-81x112.png'/></a> + + # OpenWRT + + <a href='https://ko-fi.com/D1D7EP4GF'><img src='https://img.shields.io/badge/☕-Buy me a coffee-blue' /></a> + </div>" >/dev/null +msg_ok "Created OpenWrt VM ${CL}${BL}(${HN})" +msg_info "OpenWrt is being started in order to configure the network interfaces." +qm start $VMID +sleep 15 +msg_ok "Network interfaces are being configured as OpenWrt initiates." +send_line_to_vm "" +send_line_to_vm "uci delete network.@device[0]" +send_line_to_vm "uci set network.wan=interface" +send_line_to_vm "uci set network.wan.device=eth1" +send_line_to_vm "uci set network.wan.proto=dhcp" +send_line_to_vm "uci delete network.lan" +send_line_to_vm "uci set network.lan=interface" +send_line_to_vm "uci set network.lan.device=eth0" +send_line_to_vm "uci set network.lan.proto=static" +send_line_to_vm "uci set network.lan.ipaddr=${LAN_IP_ADDR}" +send_line_to_vm "uci set network.lan.netmask=${LAN_NETMASK}" +send_line_to_vm "uci set firewall.@zone[1].input='ACCEPT'" +send_line_to_vm "uci set firewall.@zone[1].forward='ACCEPT'" +send_line_to_vm "uci commit" +send_line_to_vm "halt" +msg_ok "Network interfaces have been successfully configured." +until qm status $VMID | grep -q "stopped"; do + sleep 2 +done +msg_info "Bridge interfaces are being added." +qm set $VMID \ + -net0 virtio,bridge=${LAN_BRG},macaddr=${LAN_MAC}${LAN_VLAN}${MTU} \ + -net1 virtio,bridge=${BRG},macaddr=${MAC}${VLAN}${MTU} >/dev/null 2>/dev/null +msg_ok "Bridge interfaces have been successfully added." +if [ "$START_VM" == "yes" ]; then + msg_info "Starting OpenWrt VM" + qm start $VMID + msg_ok "Started OpenWrt VM" +fi +VLAN_FINISH="" +if [ "$VLAN" == "" ] && [ "$VLAN2" != "999" ]; then + VLAN_FINISH=" Please remember to adjust the VLAN tags to suit your network." +fi +msg_ok "Completed Successfully!\n${VLAN_FINISH}" diff --git a/vm/owncloud-vm.sh b/vm/owncloud-vm.sh new file mode 100644 index 00000000..871f5eeb --- /dev/null +++ b/vm/owncloud-vm.sh @@ -0,0 +1,423 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 "\n Loading..." +GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//') +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") +BFR="\\r\\033[K" +HOLD="-" +CM="${GN}✓${CL}" +CROSS="${RD}✗${CL}" +THIN="discard=on,ssd=1," +set -e +trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +trap cleanup EXIT +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" + cleanup_vmid +} + +function cleanup_vmid() { + if qm status $VMID &>/dev/null; then + qm stop $VMID &>/dev/null + qm destroy $VMID &>/dev/null + fi +} + +function cleanup() { + popd >/dev/null + rm -rf $TEMP_DIR +} + +TEMP_DIR=$(mktemp -d) +pushd $TEMP_DIR >/dev/null +if whiptail --backtitle "Proxmox VE Helper Scripts" --title "TurnKey-ownCloud VM" --yesno "This will create a New TurnKey-ownCloud VM. Proceed?" 10 58; then + : +else + header_info && echo -e "⚠ User exited script \n" && exit +fi + +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 check_root() { + if [[ "$(id -u)" -ne 0 || $(ps -o comm= -p $PPID) == "sudo" ]]; then + clear + msg_error "Please run this script as root." + echo -e "\nExiting..." + sleep 2 + exit + fi +} + +function pve_check() { + if ! pveversion | grep -Eq "pve-manager/8.[1-3]"; then + msg_error "This version of Proxmox Virtual Environment is not supported" + echo -e "Requires Proxmox Virtual Environment Version 8.1 or later." + echo -e "Exiting..." + sleep 2 + exit +fi +} + +function arch_check() { + if [ "$(dpkg --print-architecture)" != "amd64" ]; then + msg_error "This script will not work with PiMox! \n" + echo -e "Exiting..." + sleep 2 + exit + fi +} + +function ssh_check() { + if command -v pveversion >/dev/null 2>&1; then + if [ -n "${SSH_CLIENT:+x}" ]; then + if whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SSH DETECTED" --yesno "It's suggested to use the Proxmox shell instead of SSH, since SSH can create issues while gathering variables. Would you like to proceed with using SSH?" 10 62; then + echo "you've been warned" + else + clear + exit + fi + fi + fi +} + +function exit-script() { + clear + echo -e "⚠ User exited script \n" + exit +} + +function default_settings() { + VMID="$NEXTID" + FORMAT=",efitype=4m" + MACHINE="" + DISK_CACHE="" + HN="turnkey-owncloud-vm" + CPU_TYPE="" + CORE_COUNT="2" + RAM_SIZE="2048" + BRG="vmbr0" + MAC="$GEN_MAC" + VLAN="" + MTU="" + START_VM="no" + echo -e "${DGN}Using Virtual Machine ID: ${BGN}${VMID}${CL}" + echo -e "${DGN}Using Machine Type: ${BGN}i440fx${CL}" + echo -e "${DGN}Using Disk Cache: ${BGN}None${CL}" + echo -e "${DGN}Using Hostname: ${BGN}${HN}${CL}" + echo -e "${DGN}Using CPU Model: ${BGN}KVM64${CL}" + echo -e "${DGN}Allocated Cores: ${BGN}${CORE_COUNT}${CL}" + echo -e "${DGN}Allocated RAM: ${BGN}${RAM_SIZE}${CL}" + echo -e "${DGN}Using Bridge: ${BGN}${BRG}${CL}" + echo -e "${DGN}Using MAC Address: ${BGN}${MAC}${CL}" + echo -e "${DGN}Using VLAN: ${BGN}Default${CL}" + echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" + echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" + echo -e "${BL}Creating a TurnKey ownCloud VM using the above default settings${CL}" +} + +function advanced_settings() { + while true; do + if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z "$VMID" ]; then + VMID="$NEXTID" + fi + 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 + else + exit-script + fi + done + + if MACH=$(whiptail --backtitle "Proxmox VE Helper Scripts" --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); then + 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 + else + exit-script + fi + + if DISK_CACHE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "DISK CACHE" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \ + "0" "None (Default)" ON \ + "1" "Write Through" OFF \ + 3>&1 1>&2 2>&3); then + if [ $DISK_CACHE = "1" ]; then + echo -e "${DGN}Using Disk Cache: ${BGN}Write Through${CL}" + DISK_CACHE="cache=writethrough," + else + echo -e "${DGN}Using Disk Cache: ${BGN}None${CL}" + DISK_CACHE="" + fi + else + exit-script + fi + + if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 turnkey-owncloud-vm --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $VM_NAME ]; then + HN="turnkey-owncloud-vm" + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + else + HN=$(echo ${VM_NAME,,} | tr -d ' ') + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + fi + else + exit-script + fi + + if CPU_TYPE1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "CPU MODEL" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \ + "0" "KVM64 (Default)" ON \ + "1" "Host" OFF \ + 3>&1 1>&2 2>&3); then + if [ $CPU_TYPE1 = "1" ]; then + echo -e "${DGN}Using CPU Model: ${BGN}Host${CL}" + CPU_TYPE=" -cpu host" + else + echo -e "${DGN}Using CPU Model: ${BGN}KVM64${CL}" + CPU_TYPE="" + fi + else + exit-script + fi + + if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $CORE_COUNT ]; then + CORE_COUNT="2" + 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 --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 2048 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $RAM_SIZE ]; then + RAM_SIZE="2048" + 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 --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 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 MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $MAC1 ]; then + MAC="$GEN_MAC" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}" + else + MAC="$MAC1" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" + fi + else + exit-script + fi + + if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); 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 + else + exit-script + fi + + if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); 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 + else + exit-script + fi + + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 + echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" + START_VM="no" + fi + + if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create a TurnKey ownCloud VM?" --no-button Do-Over 10 58); then + echo -e "${RD}Creating a TurnKey ownCloud VM using the above advanced settings${CL}" + else + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi +} + +function start_script() { + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 +} + +check_root +arch_check +pve_check +ssh_check +start_script + +msg_info "Validating Storage" +while read -r line; do + TAG=$(echo $line | awk '{print $1}') + TYPE=$(echo $line | awk '{printf "%-10s", $2}') + FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') + ITEM=" Type: $TYPE Free: $FREE " + OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + 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." + exit +elif [ $((${#STORAGE_MENU[@]} / 3)) -eq 1 ]; then + STORAGE=${STORAGE_MENU[0]} +else + while [ -z "${STORAGE:+x}" ]; do + STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Storage Pools" --radiolist \ + "Which storage pool you would like to use for ${HN}?\nTo make a selection, use the Spacebar.\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 the TurnKey ownCloud ISO Disk Image" +URL=http://mirror.turnkeylinux.org/turnkeylinux/images/iso/turnkey-owncloud-18.0-bookworm-amd64.iso +sleep 2 +msg_ok "${CL}${BL}${URL}${CL}" +wget -q --show-progress $URL +echo -en "\e[1A\e[0K" +FILE=$(basename $URL) +msg_ok "Downloaded ${CL}${BL}${FILE}${CL}" + +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="" + ;; +esac +for i in {0,1}; do + disk="DISK$i" + eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-} + eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk} +done + +msg_info "Creating a TurnKey ownCloud VM" +qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios seabios${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \ + -name $HN -tags proxmox-helper-scripts -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci +pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null +qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null +qm set $VMID \ + -efidisk0 ${DISK0_REF}${FORMAT} \ + -scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=12G \ + -boot order=scsi0 \ + -description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/logo-81x112.png'/></a> + + # TurnKey ownCloud VM + + <a href='https://ko-fi.com/D1D7EP4GF'><img src='https://img.shields.io/badge/☕-Buy me a coffee-blue' /></a> + </div>" >/dev/null +msg_ok "Created a TurnKey ownCloud VM ${CL}${BL}(${HN})" +if [ "$START_VM" == "yes" ]; then + msg_info "Starting TurnKey ownCloud VM" + qm start $VMID + msg_ok "Started TurnKey ownCloud VM" +fi +msg_ok "Completed Successfully!\n" diff --git a/vm/pimox-haos-vm.sh b/vm/pimox-haos-vm.sh new file mode 100644 index 00000000..4e1c4766 --- /dev/null +++ b/vm/pimox-haos-vm.sh @@ -0,0 +1,325 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { + cat <<"EOF" + ____ _ __ ___ + / __ \(_) |/ /___ _ __ + / /_/ / / /|_/ / __ \| |/_/ + / ____/ / / / / /_/ /> < + __ __ /_/_ /_/_/ /_/\____/_/|_| __ ____ _____ + / / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____ / /_ / __ \/ ___/ + / /_/ / __ \/ __ `__ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ `/ __ \/ __/ / / / /\__ \ + / __ / /_/ / / / / / / __/ / ___ |(__ |__ ) (__ ) /_/ /_/ / / / / /_ / /_/ /___/ / +/_/ /_/\____/_/ /_/ /_/\___/ /_/ |_/____/____/_/____/\__/\__,_/_/ /_/\__/ \____//____/ + +EOF +} +clear +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:]') +USEDID=$(pvesh get /cluster/resources --type vm --output-format yaml | egrep -i 'vmid' | awk '{print substr($2, 1, length($2)-0) }') +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") +BFR="\\r\\033[K" +HOLD="-" +CM="${GN}✓${CL}" +CROSS="${RD}✗${CL}" +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail +shopt -s expand_aliases +alias die='EXIT=$? LINE=$LINENO error_exit' +trap die ERR +trap cleanup EXIT +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 + [ ! -z ${VMID-} ] && cleanup_vmid + exit $EXIT +} +function cleanup_vmid() { + if $(qm status $VMID &>/dev/null); then + if [ "$(qm status $VMID | awk '{print $2}')" == "running" ]; then + qm stop $VMID + fi + qm destroy $VMID + fi +} +function cleanup() { + popd >/dev/null + rm -rf $TEMP_DIR +} +TEMP_DIR=$(mktemp -d) +pushd $TEMP_DIR >/dev/null +if ! command -v whiptail &> /dev/null; then + echo "Installing whiptail..." + apt-get update &>/dev/null + apt-get install -y whiptail &>/dev/null +fi +if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "PiMox HAOS VM" --yesno "This will create a New PiMox HAOS VM. Proceed?" 10 58); then + echo "User selected Yes" +else + clear + echo -e "⚠ User exited script \n" + exit +fi +function ARCH_CHECK() { + ARCH=$(dpkg --print-architecture) + if [[ "$ARCH" == "amd64" ]]; then + echo -e "\n ❌ This script only works with PiMox! \n" + echo -e "Exiting..." + sleep 2 + exit + fi +} +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 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}" +} +function advanced_settings() { + BRANCH=$(whiptail --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 + echo -e "\n🚨 ${RD}ID $VMID is already in use${CL} \n" + echo -e "Exiting Script \n" + sleep 2 + exit + else + if [ $exitstatus = 0 ]; then echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}"; fi + fi + fi + VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 --backtitle "Proxmox VE Helper Scripts" --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 + echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" + START_VM="no" + fi + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 +} +function START_SCRIPT() { + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 +START_SCRIPT +while read -r line; do + TAG=$(echo $line | awk '{print $1}') + TYPE=$(echo $line | awk '{printf "%-10s", $2}') + FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') + ITEM=" Type: $TYPE Free: $FREE " + OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + STORAGE_MENU+=("$TAG" "$ITEM" "OFF") +done < <(pvesm status -content images | awk 'NR>1') +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 + STORAGE=${STORAGE_MENU[0]} +else + while [ -z "${STORAGE:+x}" ]; do + STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --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 + 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 "Getting URL for Home Assistant ${BRANCH} Disk Image" +URL=https://github.com/home-assistant/operating-system/releases/download/${BRANCH}/haos_generic-aarch64-${BRANCH}.qcow2.xz +sleep 2 +msg_ok "${CL}${BL}${URL}${CL}" +wget -q --show-progress $URL +echo -en "\e[1A\e[0K" +FILE=$(basename $URL) +msg_ok "Downloaded ${CL}${BL}haos_generic-aarch64-${BRANCH}.qcow2.xz${CL}" +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" + ;; +esac +for i in {0,1}; do + disk="DISK$i" + eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-} + eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk} +done +msg_ok "Extracted Disk Image" +msg_info "Creating HAOS VM" +qm create $VMID -bios ovmf -cores $CORE_COUNT -memory $RAM_SIZE -name $HN \ + -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci +pvesm alloc $STORAGE $VMID $DISK0 64M 1>&/dev/null +qm importdisk $VMID ${FILE%.*} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null +qm set $VMID \ + -efidisk0 ${DISK0_REF},efitype=4m,size=64M \ + -scsi0 ${DISK1_REF},size=32G >/dev/null +qm set $VMID \ + -boot order=scsi0 \ + -description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/logo-81x112.png'/></a> + + # Home Assistant OS + + <a href='https://ko-fi.com/D1D7EP4GF'><img src='https://img.shields.io/badge/☕-Buy me a coffee-blue' /></a> + </div>" >/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" +fi +msg_ok "Completed Successfully!\n" diff --git a/vm/pimox-haos.sh b/vm/pimox-haos.sh deleted file mode 100644 index 38b009ae..00000000 --- a/vm/pimox-haos.sh +++ /dev/null @@ -1,343 +0,0 @@ -#!/usr/bin/env bash -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) -RELEASE=$(curl -sX GET "https://api.github.com/repos/home-assistant/operating-system/releases" | awk '/tag_name/{print $4;exit}' FS='[""]') -STABLE="8.2" -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}" -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' -trap die ERR -trap cleanup EXIT - -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 - [ ! -z ${VMID-} ] && cleanup_vmid - exit $EXIT -} - -function cleanup_vmid() { - if $(qm status $VMID &>/dev/null); then - if [ "$(qm status $VMID | awk '{print $2}')" == "running" ]; then - qm stop $VMID - fi - qm destroy $VMID - fi -} - -function cleanup() { - popd >/dev/null - rm -rf $TEMP_DIR -} - -TEMP_DIR=$(mktemp -d) -pushd $TEMP_DIR >/dev/null - -while true; do - read -p "This will create a New PiMox Home Assistant OS VM. Proceed(y/n)?" yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac -done -clear - -function header_info { -echo -e "${YW} - - _____ _ _ _ ____ _____ - | __ (_) | | | | /\ / __ \ / ____| - | |__) | ______| |__| | / \ | | | | (___ - | ___/ |__v3__| __ | / /\ \| | | |\___ \ - | | | | | | | |/ ____ \ |__| |____) | - |_| |_| |_| |_/_/ \_\____/|_____/ -${CL}" -} -header_info - -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 default_settings() { - clear - header_info - echo -e "${BL}Using Default Settings${CL}" - echo -e "${DGN}Using Version ${BGN}${STABLE}${CL}" - BRANCH=${STABLE} - echo -e "${DGN}Using VM ID ${BGN}$NEXTID${CL}" - VMID=$NEXTID - echo -e "${DGN}Using VM Name ${BGN}pi-haos${STABLE}${CL}" - VM_NAME=pi-haos${STABLE} - echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}" - CORE_COUNT="2" - echo -e "${DGN}Using ${BGN}4096${CL}${DGN}MiB RAM${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 Tag ${BGN}NONE${CL}" - VLAN="" - echo -e "${DGN}Start VM when completed ${BGN}yes${CL}" - START_VM="yes" - -} -function advanced_settings() { - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${YW}Type Latest for Version ${RELEASE}, or Press [ENTER] for Stable Version ${STABLE} " - read BRANCH - if [ -z $BRANCH ]; then BRANCH=$STABLE; - else - BRANCH=$RELEASE; fi; - echo -en "${DGN}Set Version To ${BL}$BRANCH${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - clear - header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${YW}Enter the VM ID, or Press [ENTER] to automatically generate (${NEXTID}) " - read VMID - if [ -z $VMID ]; then VMID=$NEXTID; fi; - echo -en "${DGN}Set VM ID To ${BL}$VMID${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${YW}Enter VM Name (no-spaces), or Press [ENTER] for Default: pi-haos${BRANCH} " - read VMNAME - if [ -z $VMNAME ]; then - VM_NAME=pi-haos${BRANCH} - else - VM_NAME=$(echo ${VMNAME,,} | tr -d ' ') - fi - echo -en "${DGN}Set CT Name To ${BL}$VM_NAME${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 " - read CORE_COUNT - if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi; - echo -en "${DGN}Set Cores To ${BL}${CORE_COUNT}${CL}" -echo -e " ${CM}${CL} \r" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 4096 " - read RAM_SIZE - if [ -z $RAM_SIZE ]; then RAM_SIZE="4096"; fi; - echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 " - read BRG - if [ -z $BRG ]; then BRG="vmbr0"; fi; - echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${YW}Enter a Valid MAC Address, or Press [ENTER] for Generated MAC: $GEN_MAC " - read MAC - if [ -z $MAC ]; then MAC=$GEN_MAC; fi; - echo -en "${DGN}Set MAC Address To ${BL}$MAC${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using MAC Address ${BGN}$MAC${CL}" - echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE " - read VLAN1 - if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN=""; - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - else - VLAN=",tag=$VLAN1" - echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}" - fi; -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using MAC Address ${BGN}$MAC${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - echo -e "${YW}Start VM when completed, or Press [ENTER] for Default: yes " - read START_VM - if [ -z $START_VM ]; then START_VM="yes"; - else - START_VM="no"; fi; - echo -en "${DGN}Starting VM when completed ${BL}$START_VM${CL}" -echo -e " ${CM}${CL} \n" -sleep 1 -clear -header_info - echo -e "${RD}Using Advanced Settings${CL}" - echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" - echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" - echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" - echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}" - echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB${CL}" - echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}" - echo -e "${DGN}Using MAC Address ${BGN}$MAC${CL}" - echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}" - echo -e "${DGN}Start VM when completed ${BGN}$START_VM${CL}" - -read -p "Are these settings correct(y/n)? " -n 1 -r -echo -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - advanced_settings -fi -} - -function start_script() { - echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings " - read SETTINGS - if [ -z $SETTINGS ]; then default_settings; - else - advanced_settings - fi; -} - -start_script - -while read -r line; do - TAG=$(echo $line | awk '{print $1}') - TYPE=$(echo $line | awk '{printf "%-10s", $2}') - FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') - ITEM=" Type: $TYPE Free: $FREE " - OFFSET=2 - if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then - MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) - fi - STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) -done < <(pvesm status -content images | awk 'NR>1') -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 - 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 Pi-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 "Getting URL for Home Assistant ${BRANCH} Disk Image" -URL=https://github.com/home-assistant/operating-system/releases/download/${BRANCH}/haos_generic-aarch64-${BRANCH}.img.xz -sleep 2 -msg_ok "${CL}${BL}${URL}${CL}" -wget -q --show-progress $URL -echo -en "\e[1A\e[0K" -FILE=$(basename $URL) -msg_ok "Downloaded ${CL}${BL}haos_generic-aarch64-${BRANCH}.img.xz${CL}" -msg_info "Extracting Disk Image" -unxz $FILE -STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') -case $STORAGE_TYPE in - btrfs|nfs|dir) - DISK_EXT=".raw" - DISK_REF="$VMID/" - DISK_IMPORT="-format raw" -esac -for i in {0,1}; do - disk="DISK$i" - eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-} - eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk} -done -msg_ok "Extracted Disk Image" - -msg_info "Creating Pi-HAOS VM" -qm create $VMID -agent 1 -bios ovmf -cores $CORE_COUNT -memory $RAM_SIZE -name $VM_NAME -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN \ - -onboot 1 -ostype l26 -scsihw virtio-scsi-pci -pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null -qm importdisk $VMID ${FILE%.*} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null -qm set $VMID \ - -efidisk0 ${DISK0_REF},efitype=4m,size=4M \ - -scsi0 ${DISK1_REF},size=32G >/dev/null -qm set $VMID \ - -boot order=scsi0 >/dev/null -#qm resize $VMID scsi0 +26G >/dev/null -qm set $VMID -description "# Home Assistant OS -### https://github.com/tteck/Proxmox" >/dev/null - -msg_ok "Created Pi-HAOS VM ${CL}${BL}${VM_NAME}" - -if [ "$START_VM" == "yes" ]; then -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/ubuntu2204-vm.sh b/vm/ubuntu2204-vm.sh new file mode 100644 index 00000000..cb6884d8 --- /dev/null +++ b/vm/ubuntu2204-vm.sh @@ -0,0 +1,428 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 "\n Loading..." +GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//') +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") +BFR="\\r\\033[K" +HOLD="-" +CM="${GN}✓${CL}" +CROSS="${RD}✗${CL}" +THIN="discard=on,ssd=1," +set -e +trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +trap cleanup EXIT +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" + cleanup_vmid +} + +function cleanup_vmid() { + if qm status $VMID &>/dev/null; then + qm stop $VMID &>/dev/null + qm destroy $VMID &>/dev/null + fi +} + +function cleanup() { + popd >/dev/null + rm -rf $TEMP_DIR +} + +TEMP_DIR=$(mktemp -d) +pushd $TEMP_DIR >/dev/null +if whiptail --backtitle "Proxmox VE Helper Scripts" --title "Ubuntu 22.04 VM" --yesno "This will create a New Ubuntu 22.04 VM. Proceed?" 10 58; then + : +else + header_info && echo -e "⚠ User exited script \n" && exit +fi + +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 check_root() { + if [[ "$(id -u)" -ne 0 || $(ps -o comm= -p $PPID) == "sudo" ]]; then + clear + msg_error "Please run this script as root." + echo -e "\nExiting..." + sleep 2 + exit + fi +} + +function pve_check() { + if ! pveversion | grep -Eq "pve-manager/8.[1-3]"; then + msg_error "This version of Proxmox Virtual Environment is not supported" + echo -e "Requires Proxmox Virtual Environment Version 8.1 or later." + echo -e "Exiting..." + sleep 2 + exit +fi +} + +function arch_check() { + if [ "$(dpkg --print-architecture)" != "amd64" ]; then + msg_error "This script will not work with PiMox! \n" + echo -e "Exiting..." + sleep 2 + exit + fi +} + +function ssh_check() { + if command -v pveversion >/dev/null 2>&1; then + if [ -n "${SSH_CLIENT:+x}" ]; then + if whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SSH DETECTED" --yesno "It's suggested to use the Proxmox shell instead of SSH, since SSH can create issues while gathering variables. Would you like to proceed with using SSH?" 10 62; then + echo "you've been warned" + else + clear + exit + fi + fi + fi +} + +function exit-script() { + clear + echo -e "⚠ User exited script \n" + exit +} + +function default_settings() { + VMID="$NEXTID" + FORMAT=",efitype=4m" + MACHINE="" + DISK_CACHE="" + HN="ubuntu" + CPU_TYPE="" + CORE_COUNT="2" + RAM_SIZE="2048" + BRG="vmbr0" + MAC="$GEN_MAC" + VLAN="" + MTU="" + START_VM="no" + echo -e "${DGN}Using Virtual Machine ID: ${BGN}${VMID}${CL}" + echo -e "${DGN}Using Machine Type: ${BGN}i440fx${CL}" + echo -e "${DGN}Using Disk Cache: ${BGN}None${CL}" + echo -e "${DGN}Using Hostname: ${BGN}${HN}${CL}" + echo -e "${DGN}Using CPU Model: ${BGN}KVM64${CL}" + echo -e "${DGN}Allocated Cores: ${BGN}${CORE_COUNT}${CL}" + echo -e "${DGN}Allocated RAM: ${BGN}${RAM_SIZE}${CL}" + echo -e "${DGN}Using Bridge: ${BGN}${BRG}${CL}" + echo -e "${DGN}Using MAC Address: ${BGN}${MAC}${CL}" + echo -e "${DGN}Using VLAN: ${BGN}Default${CL}" + echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" + echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" + echo -e "${BL}Creating an Ubuntu 22.04 VM using the above default settings${CL}" +} + +function advanced_settings() { + while true; do + if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z "$VMID" ]; then + VMID="$NEXTID" + fi + 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 + else + exit-script + fi + done + + if MACH=$(whiptail --backtitle "Proxmox VE Helper Scripts" --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); then + 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 + else + exit-script + fi + + if DISK_CACHE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "DISK CACHE" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \ + "0" "None (Default)" ON \ + "1" "Write Through" OFF \ + 3>&1 1>&2 2>&3); then + if [ $DISK_CACHE = "1" ]; then + echo -e "${DGN}Using Disk Cache: ${BGN}Write Through${CL}" + DISK_CACHE="cache=writethrough," + else + echo -e "${DGN}Using Disk Cache: ${BGN}None${CL}" + DISK_CACHE="" + fi + else + exit-script + fi + + if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 ubuntu --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $VM_NAME ]; then + HN="ubuntu" + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + else + HN=$(echo ${VM_NAME,,} | tr -d ' ') + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + fi + else + exit-script + fi + + if CPU_TYPE1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "CPU MODEL" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \ + "0" "KVM64 (Default)" ON \ + "1" "Host" OFF \ + 3>&1 1>&2 2>&3); then + if [ $CPU_TYPE1 = "1" ]; then + echo -e "${DGN}Using CPU Model: ${BGN}Host${CL}" + CPU_TYPE=" -cpu host" + else + echo -e "${DGN}Using CPU Model: ${BGN}KVM64${CL}" + CPU_TYPE="" + fi + else + exit-script + fi + + if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $CORE_COUNT ]; then + CORE_COUNT="2" + 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 --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 2048 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $RAM_SIZE ]; then + RAM_SIZE="2048" + 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 --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 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 MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $MAC1 ]; then + MAC="$GEN_MAC" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}" + else + MAC="$MAC1" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" + fi + else + exit-script + fi + + if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); 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 + else + exit-script + fi + + if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); 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 + else + exit-script + fi + + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 + echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" + START_VM="no" + fi + + if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create an Ubuntu 22.04 VM?" --no-button Do-Over 10 58); then + echo -e "${RD}Creating an Ubuntu 22.04 VM using the above advanced settings${CL}" + else + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi +} + +function start_script() { + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 +} + +check_root +arch_check +pve_check +ssh_check +start_script + +msg_info "Validating Storage" +while read -r line; do + TAG=$(echo $line | awk '{print $1}') + TYPE=$(echo $line | awk '{printf "%-10s", $2}') + FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') + ITEM=" Type: $TYPE Free: $FREE " + OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + 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." + exit +elif [ $((${#STORAGE_MENU[@]} / 3)) -eq 1 ]; then + STORAGE=${STORAGE_MENU[0]} +else + while [ -z "${STORAGE:+x}" ]; do + STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Storage Pools" --radiolist \ + "Which storage pool you would like to use for ${HN}?\nTo make a selection, use the Spacebar.\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 the Ubuntu 22.04 Disk Image" +URL=https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img +sleep 2 +msg_ok "${CL}${BL}${URL}${CL}" +wget -q --show-progress $URL +echo -en "\e[1A\e[0K" +FILE=$(basename $URL) +msg_ok "Downloaded ${CL}${BL}${FILE}${CL}" + +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" + 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" + eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-} + eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk} +done + +msg_info "Creating a Ubuntu 22.04 VM" +qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \ + -name $HN -tags proxmox-helper-scripts -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci +pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null +qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null +qm set $VMID \ + -efidisk0 ${DISK0_REF}${FORMAT} \ + -scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=2G \ + -ide2 ${STORAGE}:cloudinit \ + -boot order=scsi0 \ + -serial0 socket \ + -description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/logo-81x112.png'/></a> + + # Ubuntu 22.04 VM + + <a href='https://ko-fi.com/D1D7EP4GF'><img src='https://img.shields.io/badge/☕-Buy me a coffee-blue' /></a> + </div>" >/dev/null +msg_ok "Created a Ubuntu 22.04 VM ${CL}${BL}(${HN})" +if [ "$START_VM" == "yes" ]; then + msg_info "Starting Ubuntu 22.04 VM" + qm start $VMID + msg_ok "Started Ubuntu 22.04 VM" +fi +msg_ok "Completed Successfully!\n" +echo -e "Setup Cloud-Init before starting \n +More info at https://github.com/tteck/Proxmox/discussions/2072 \n" diff --git a/vm/ubuntu2404-vm.sh b/vm/ubuntu2404-vm.sh new file mode 100644 index 00000000..c3dd1750 --- /dev/null +++ b/vm/ubuntu2404-vm.sh @@ -0,0 +1,428 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2024 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 "\n Loading..." +GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//') +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") +BFR="\\r\\033[K" +HOLD="-" +CM="${GN}✓${CL}" +CROSS="${RD}✗${CL}" +THIN="discard=on,ssd=1," +set -e +trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +trap cleanup EXIT +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" + cleanup_vmid +} + +function cleanup_vmid() { + if qm status $VMID &>/dev/null; then + qm stop $VMID &>/dev/null + qm destroy $VMID &>/dev/null + fi +} + +function cleanup() { + popd >/dev/null + rm -rf $TEMP_DIR +} + +TEMP_DIR=$(mktemp -d) +pushd $TEMP_DIR >/dev/null +if whiptail --backtitle "Proxmox VE Helper Scripts" --title "Ubuntu 24.04 VM" --yesno "This will create a New Ubuntu 24.04 VM. Proceed?" 10 58; then + : +else + header_info && echo -e "⚠ User exited script \n" && exit +fi + +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 check_root() { + if [[ "$(id -u)" -ne 0 || $(ps -o comm= -p $PPID) == "sudo" ]]; then + clear + msg_error "Please run this script as root." + echo -e "\nExiting..." + sleep 2 + exit + fi +} + +function pve_check() { + if ! pveversion | grep -Eq "pve-manager/8.[1-3]"; then + msg_error "This version of Proxmox Virtual Environment is not supported" + echo -e "Requires Proxmox Virtual Environment Version 8.1 or later." + echo -e "Exiting..." + sleep 2 + exit +fi +} + +function arch_check() { + if [ "$(dpkg --print-architecture)" != "amd64" ]; then + msg_error "This script will not work with PiMox! \n" + echo -e "Exiting..." + sleep 2 + exit + fi +} + +function ssh_check() { + if command -v pveversion >/dev/null 2>&1; then + if [ -n "${SSH_CLIENT:+x}" ]; then + if whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SSH DETECTED" --yesno "It's suggested to use the Proxmox shell instead of SSH, since SSH can create issues while gathering variables. Would you like to proceed with using SSH?" 10 62; then + echo "you've been warned" + else + clear + exit + fi + fi + fi +} + +function exit-script() { + clear + echo -e "⚠ User exited script \n" + exit +} + +function default_settings() { + VMID="$NEXTID" + FORMAT=",efitype=4m" + MACHINE="" + DISK_CACHE="" + HN="ubuntu" + CPU_TYPE="" + CORE_COUNT="2" + RAM_SIZE="2048" + BRG="vmbr0" + MAC="$GEN_MAC" + VLAN="" + MTU="" + START_VM="no" + echo -e "${DGN}Using Virtual Machine ID: ${BGN}${VMID}${CL}" + echo -e "${DGN}Using Machine Type: ${BGN}i440fx${CL}" + echo -e "${DGN}Using Disk Cache: ${BGN}None${CL}" + echo -e "${DGN}Using Hostname: ${BGN}${HN}${CL}" + echo -e "${DGN}Using CPU Model: ${BGN}KVM64${CL}" + echo -e "${DGN}Allocated Cores: ${BGN}${CORE_COUNT}${CL}" + echo -e "${DGN}Allocated RAM: ${BGN}${RAM_SIZE}${CL}" + echo -e "${DGN}Using Bridge: ${BGN}${BRG}${CL}" + echo -e "${DGN}Using MAC Address: ${BGN}${MAC}${CL}" + echo -e "${DGN}Using VLAN: ${BGN}Default${CL}" + echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}" + echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" + echo -e "${BL}Creating an Ubuntu 24.04 VM using the above default settings${CL}" +} + +function advanced_settings() { + while true; do + if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z "$VMID" ]; then + VMID="$NEXTID" + fi + 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 + else + exit-script + fi + done + + if MACH=$(whiptail --backtitle "Proxmox VE Helper Scripts" --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); then + 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 + else + exit-script + fi + + if DISK_CACHE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "DISK CACHE" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \ + "0" "None (Default)" ON \ + "1" "Write Through" OFF \ + 3>&1 1>&2 2>&3); then + if [ $DISK_CACHE = "1" ]; then + echo -e "${DGN}Using Disk Cache: ${BGN}Write Through${CL}" + DISK_CACHE="cache=writethrough," + else + echo -e "${DGN}Using Disk Cache: ${BGN}None${CL}" + DISK_CACHE="" + fi + else + exit-script + fi + + if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 ubuntu --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $VM_NAME ]; then + HN="ubuntu" + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + else + HN=$(echo ${VM_NAME,,} | tr -d ' ') + echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" + fi + else + exit-script + fi + + if CPU_TYPE1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "CPU MODEL" --radiolist "Choose" --cancel-button Exit-Script 10 58 2 \ + "0" "KVM64 (Default)" ON \ + "1" "Host" OFF \ + 3>&1 1>&2 2>&3); then + if [ $CPU_TYPE1 = "1" ]; then + echo -e "${DGN}Using CPU Model: ${BGN}Host${CL}" + CPU_TYPE=" -cpu host" + else + echo -e "${DGN}Using CPU Model: ${BGN}KVM64${CL}" + CPU_TYPE="" + fi + else + exit-script + fi + + if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $CORE_COUNT ]; then + CORE_COUNT="2" + 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 --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 2048 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $RAM_SIZE ]; then + RAM_SIZE="2048" + 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 --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 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 MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then + if [ -z $MAC1 ]; then + MAC="$GEN_MAC" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}" + else + MAC="$MAC1" + echo -e "${DGN}Using MAC Address: ${BGN}$MAC1${CL}" + fi + else + exit-script + fi + + if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); 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 + else + exit-script + fi + + if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); 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 + else + exit-script + fi + + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 + echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" + START_VM="no" + fi + + if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create an Ubuntu 24.04 VM?" --no-button Do-Over 10 58); then + echo -e "${RD}Creating an Ubuntu 24.04 VM using the above advanced settings${CL}" + else + header_info + echo -e "${RD}Using Advanced Settings${CL}" + advanced_settings + fi +} + +function start_script() { + if (whiptail --backtitle "Proxmox VE Helper Scripts" --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 +} + +check_root +arch_check +pve_check +ssh_check +start_script + +msg_info "Validating Storage" +while read -r line; do + TAG=$(echo $line | awk '{print $1}') + TYPE=$(echo $line | awk '{printf "%-10s", $2}') + FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') + ITEM=" Type: $TYPE Free: $FREE " + OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + 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." + exit +elif [ $((${#STORAGE_MENU[@]} / 3)) -eq 1 ]; then + STORAGE=${STORAGE_MENU[0]} +else + while [ -z "${STORAGE:+x}" ]; do + STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Storage Pools" --radiolist \ + "Which storage pool you would like to use for ${HN}?\nTo make a selection, use the Spacebar.\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 the Ubuntu 24.04 Disk Image" +URL=https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img +sleep 2 +msg_ok "${CL}${BL}${URL}${CL}" +wget -q --show-progress $URL +echo -en "\e[1A\e[0K" +FILE=$(basename $URL) +msg_ok "Downloaded ${CL}${BL}${FILE}${CL}" + +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" + 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" + eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-} + eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk} +done + +msg_info "Creating a Ubuntu 24.04 VM" +qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \ + -name $HN -tags proxmox-helper-scripts -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci +pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null +qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null +qm set $VMID \ + -efidisk0 ${DISK0_REF}${FORMAT} \ + -scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=2G \ + -ide2 ${STORAGE}:cloudinit \ + -boot order=scsi0 \ + -serial0 socket \ + -description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/logo-81x112.png'/></a> + + # Ubuntu 24.04 VM + + <a href='https://ko-fi.com/D1D7EP4GF'><img src='https://img.shields.io/badge/☕-Buy me a coffee-blue' /></a> + </div>" >/dev/null +msg_ok "Created a Ubuntu 24.04 VM ${CL}${BL}(${HN})" +if [ "$START_VM" == "yes" ]; then + msg_info "Starting Ubuntu 24.04 VM" + qm start $VMID + msg_ok "Started Ubuntu 24.04 VM" +fi +msg_ok "Completed Successfully!\n" +echo -e "Setup Cloud-Init before starting \n +More info at https://github.com/tteck/Proxmox/discussions/2072 \n"