├── .gitignore ├── LICENSE ├── README.md ├── archive ├── composerize-2022.08.07.txz └── composerize-20231029.txz ├── build.sh ├── plugin ├── composerize.plg └── composerize.png └── source └── composerize └── usr └── local └── emhttp └── plugins └── composerize ├── Composerize.page ├── README.md ├── api.php ├── images └── composerize.png ├── include └── composerize.php └── js └── composerize.min.js /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.bak 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Liam Lalonde 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # unraid-plugin-composerize 2 | 3 | Automatically convert community application docker templates to compose stacks 4 | using [composerize](https://github.com/magicmark/composerize). 5 | 6 | Required plugins: 7 | 8 | - [Compose.Manager](https://forums.unraid.net/topic/114415-plugin-docker-compose-manager/) 9 | - [Community Applications](https://forums.unraid.net/topic/38582-plug-in-community-applications/) -------------------------------------------------------------------------------- /archive/composerize-2022.08.07.txz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llalon/unraid-plugin-composerize/86748bc6fd771ca83276282e39efc17bfd9136de/archive/composerize-2022.08.07.txz -------------------------------------------------------------------------------- /archive/composerize-20231029.txz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llalon/unraid-plugin-composerize/86748bc6fd771ca83276282e39efc17bfd9136de/archive/composerize-20231029.txz -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Detect MAC OSX 4 | if [ "$(uname)" == "Darwin" ]; then 5 | PREFIX="g" 6 | else 7 | PREFIX="" 8 | fi 9 | 10 | set -e 11 | 12 | USAGE="Usage: $(basename "$0") [branch] [version]" 13 | ARCHIVE_DIR="./archive" 14 | SOURCE_DIR="./source" 15 | 16 | PLUGIN_FILE="$1" 17 | BRANCH="$2" 18 | VERSION="$3" 19 | 20 | # Validate arguments 21 | if [ "$#" -lt 1 ] || [ "$#" -gt 3 ]; then 22 | echo "$USAGE" 23 | exit 1 24 | fi 25 | 26 | if [[ $PLUGIN_FILE != *.plg ]]; then 27 | echo "$USAGE" 28 | exit 1 29 | fi 30 | 31 | if [ -z "$BRANCH" ]; then 32 | BRANCH="main" 33 | fi 34 | 35 | if [ -z "$VERSION" ]; then 36 | VERSION=$(date +%Y%m%d) 37 | fi 38 | 39 | # Extract name from plugin file - source dir must match 40 | NAME=$("${PREFIX}sed" -n 's//\1/p' "$PLUGIN_FILE") 41 | if [ -z "$NAME" ]; then 42 | echo "Error: Pattern not found in the file." 43 | exit 1 44 | fi 45 | 46 | FILE_NAME="$NAME-$VERSION.txz" 47 | PACKAGE_DIR="$SOURCE_DIR/$NAME" 48 | 49 | # Validate source 50 | if [ -d "$PACKAGE_DIR" ]; then 51 | if [ -z "$(ls -A "$PACKAGE_DIR")" ]; then 52 | echo "Folder exists but is empty." 53 | exit 1 54 | fi 55 | else 56 | echo "Folder does not exist." 57 | exit 1 58 | fi 59 | 60 | echo "================================================" 61 | echo " Building UnRaid plugin package" 62 | echo "================================================" 63 | echo "Plugin: ${PLUGIN_FILE}" 64 | echo "Name: ${NAME}" 65 | echo "Source: ${PACKAGE_DIR}" 66 | echo "Archive: ${ARCHIVE_DIR}" 67 | echo "================================================" 68 | 69 | mkdir -p "$ARCHIVE_DIR" 70 | FILE="$(realpath ${ARCHIVE_DIR})/$FILE_NAME" 71 | 72 | 73 | pushd "$PACKAGE_DIR" 74 | echo "Setting file permissions..." 75 | find usr -type f -exec dos2unix {} \; 76 | chmod -R 755 usr/ 77 | 78 | echo "Creating archive..." 79 | "${PREFIX}tar" -cJf "$FILE" --owner=0 --group=0 usr/ 80 | popd 81 | 82 | echo "Verifying package" 83 | if [ -f "$FILE" ]; then 84 | hash=$(md5sum "$FILE" | cut -f 1 -d " ") 85 | 86 | if [ -z "$hash" ]; then 87 | echo "Could not verify archive" 88 | exit 1 89 | fi 90 | 91 | echo "Packaged successfully: ${hash}" 92 | 93 | echo "Updating plugin info..." 94 | "${PREFIX}sed" -i.bak '/'""'/' "${PLUGIN_FILE}" 95 | "${PREFIX}sed" -i.bak '/'""'/' "${PLUGIN_FILE}" 96 | "${PREFIX}sed" -i.bak '/'""'/' "${PLUGIN_FILE}" 97 | else 98 | echo "Failed to build package!" 99 | fi 100 | 101 | echo "Done." -------------------------------------------------------------------------------- /plugin/composerize.plg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | ]> 16 | 17 | 18 | 19 | 20 | ### 2023.11.01 21 | - General enhancements and bug fixes 22 | - Moved composerize to client side. 23 | ### 2022.08.01 24 | - Initial Release 25 | 26 | 27 | 28 | 29 | rm -f $(ls /boot/config/plugins/&name;/&name;*.txz 2>/dev/null|grep -v '&version;') 30 | 31 | 32 | 33 | 34 | &releaseURL;/archive/&file; 35 | &md5; 36 | 37 | 38 | 39 | 40 | echo "" 41 | echo "----------------------------------------------------" 42 | echo " &name; has been installed." 43 | echo " Version: &version;" 44 | echo "" 45 | echo " This plugin required docker and docker compose plugins to be installed." 46 | echo "----------------------------------------------------" 47 | echo "" 48 | 49 | 50 | 51 | 52 | 53 | removepkg &name;-&version; 54 | rm -r /usr/local/emhttp/plugins/&name; 55 | rm -r /boot/config/plugins/&name; 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /plugin/composerize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llalon/unraid-plugin-composerize/86748bc6fd771ca83276282e39efc17bfd9136de/plugin/composerize.png -------------------------------------------------------------------------------- /source/composerize/usr/local/emhttp/plugins/composerize/Composerize.page: -------------------------------------------------------------------------------- 1 | Title="Composerize" 2 | Icon="composerize.png" 3 | Type="xmenu" 4 | Menu="Utilities" 5 | --- 6 | 7 | 13 | 14 | 15 | 111 | 112 |
113 | 114 | 115 |
116 |

Template

117 | 123 |
124 | 125 | 126 | 127 |
128 |

Preview Compose

129 | 131 | 132 | 133 | 134 |
135 | 136 | 137 |
-------------------------------------------------------------------------------- /source/composerize/usr/local/emhttp/plugins/composerize/README.md: -------------------------------------------------------------------------------- 1 | **Composerize** 2 | 3 | Turns docker templates into docker-compose stacks using [Composerize](https://github.com/composerize/composerize) -------------------------------------------------------------------------------- /source/composerize/usr/local/emhttp/plugins/composerize/api.php: -------------------------------------------------------------------------------- 1 | $status, 42 | 'force' => $force 43 | ))); -------------------------------------------------------------------------------- /source/composerize/usr/local/emhttp/plugins/composerize/images/composerize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llalon/unraid-plugin-composerize/86748bc6fd771ca83276282e39efc17bfd9136de/source/composerize/usr/local/emhttp/plugins/composerize/images/composerize.png -------------------------------------------------------------------------------- /source/composerize/usr/local/emhttp/plugins/composerize/include/composerize.php: -------------------------------------------------------------------------------- 1 | 80 | * 81 | * @return array docker templates and run commands 82 | */ 83 | function getDockerTemplateList(): array 84 | { 85 | $dockerTemplates = array(); 86 | 87 | $files = glob(DOCKER_TEMPLATE_DIRECTORY . "*.xml"); 88 | 89 | foreach ($files as $file) { 90 | $info = xmlToCommand($file, false); 91 | 92 | $command = str_replace("/usr/local/emhttp/plugins/dynamix.docker.manager/scripts/docker create", 'docker run', $info[0]); 93 | $name = $info[1]; 94 | 95 | $dockerTemplates[$name] = $command; 96 | } 97 | 98 | return $dockerTemplates; 99 | } 100 | --------------------------------------------------------------------------------