├── .github
└── workflows
│ ├── docker-build.yml
│ └── shellcheck.yml
├── Dockerfile
├── apache.conf
├── cron.sh
├── occ
├── readme.md
├── remote.sh
└── start.sh
/.github/workflows/docker-build.yml:
--------------------------------------------------------------------------------
1 | name: Docker Publish
2 |
3 | on:
4 | workflow_dispatch:
5 | inputs:
6 | tagName:
7 | description: "Tag name"
8 | required: true
9 | default: 'latest'
10 |
11 | jobs:
12 | push_to_registry:
13 | runs-on: ubuntu-latest
14 |
15 | name: Push Docker image nextcloud-easy-test:${{ github.event.inputs.tagName }} to GitHub Packages
16 |
17 | permissions:
18 | packages: write
19 | contents: read
20 |
21 | steps:
22 | - name: Check out the repo
23 | uses: actions/checkout@v2
24 |
25 | - name: Set up QEMU
26 | uses: docker/setup-qemu-action@v1
27 |
28 | - name: Set up Docker Buildx
29 | uses: docker/setup-buildx-action@v1
30 |
31 | - name: Log in to GitHub Docker Registry
32 | uses: docker/login-action@v1
33 | with:
34 | registry: docker.pkg.github.com
35 | username: ${{ github.actor }}
36 | password: ${{ secrets.GITHUB_TOKEN }}
37 |
38 | - name: Log in to GitHub Container Registry
39 | uses: docker/login-action@v1
40 | with:
41 | registry: ghcr.io
42 | username: ${{ github.actor }}
43 | password: ${{ secrets.GITHUB_TOKEN }}
44 |
45 | - name: Build container image
46 | uses: docker/build-push-action@v2
47 | with:
48 | push: true
49 | platforms: linux/amd64,linux/arm64
50 | context: './'
51 | file: 'Dockerfile'
52 | tags: |
53 | ghcr.io/szaimen/nextcloud-easy-test:${{ github.event.inputs.tagName }}
54 |
--------------------------------------------------------------------------------
/.github/workflows/shellcheck.yml:
--------------------------------------------------------------------------------
1 | name: Shellcheck
2 |
3 | on:
4 | pull_request:
5 | push:
6 | branches:
7 | - main
8 |
9 | jobs:
10 | shellcheck:
11 | name: Check Shell
12 | runs-on: ubuntu-latest
13 | steps:
14 | - uses: actions/checkout@v3
15 | - name: Run Shellcheck
16 | uses: ludeeus/action-shellcheck@master
17 | with:
18 | check_together: 'yes'
19 | additional_files: 'occ'
20 | env:
21 | SHELLCHECK_OPTS: --shell bash
22 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | # From https://github.com/juliusknorr/nextcloud-docker-dev/blob/master/docker/Dockerfile.php81
2 | FROM ghcr.io/juliusknorr/nextcloud-dev-php81
3 |
4 | # Get other dependencies
5 | RUN apt-get update; \
6 | apt-get install -y --no-install-recommends \
7 | openssl \
8 | nano \
9 | openssh-client \
10 | unzip \
11 | ; \
12 | rm -rf /var/lib/apt/lists/*
13 |
14 | # Install composer
15 | RUN curl -sS https://getcomposer.org/installer | php && \
16 | mv composer.phar /usr/local/bin/composer && \
17 | chmod +x /usr/local/bin/composer
18 |
19 | # Generate self signed certificate
20 | RUN mkdir -p /certs && \
21 | cd /certs && \
22 | openssl req -new -newkey rsa:4096 -days 3650 -nodes -x509 -subj "/C=DE/ST=BE/L=Local/O=Dev/CN=localhost" -keyout ./ssl.key -out ./ssl.crt && \
23 | chmod -R +r ./
24 |
25 | # Remove default ports
26 | RUN rm /etc/apache2/ports.conf; \
27 | sed -s -i -e "s/Include ports.conf//" /etc/apache2/apache2.conf; \
28 | sed -i "/^Listen /d" /etc/apache2/apache2.conf
29 |
30 | # Enable apache mods
31 | RUN a2enmod rewrite \
32 | headers \
33 | proxy \
34 | proxy_fcgi \
35 | setenvif \
36 | env \
37 | mime \
38 | dir \
39 | authz_core \
40 | alias \
41 | ssl
42 |
43 | # Copy apache conf
44 | COPY apache.conf /etc/apache2/sites-available/
45 |
46 | # Adjust apache sites
47 | RUN a2dissite 000-default && \
48 | a2dissite default-ssl && \
49 | a2ensite apache.conf
50 |
51 | # Copy start script
52 | COPY cron.sh /cron.sh
53 | COPY start.sh /usr/bin/
54 |
55 | # Replace occ script with fixed version
56 | COPY occ /usr/local/bin/occ
57 |
58 | # Make scripts executable
59 | RUN chmod +x /usr/bin/start.sh; \
60 | chmod +x /usr/local/bin/occ; \
61 | chmod +x /cron.sh
62 |
63 | # Correctly set rights and add directories
64 | RUN cd /var/www; \
65 | rm -rf nextcloud; \
66 | mkdir nextcloud; \
67 | chown www-data:www-data -R /var/www
68 |
69 | # Switch to www-data user to make container more secure
70 | USER www-data
71 |
72 | # Install NVM (Hydrogen = v18, Iron = v20, Jod = v22)
73 | RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash \
74 | && export NVM_DIR="/var/www/.nvm" \
75 | && . "$NVM_DIR/nvm.sh" \
76 | && nvm install lts/jod \
77 | && nvm install-latest-npm \
78 | && nvm install lts/hydrogen \
79 | && nvm install-latest-npm \
80 | && nvm install lts/iron \
81 | && nvm install-latest-npm
82 |
83 | ENV APACHE_PORT 443
84 |
85 | # Set entrypoint
86 | ENTRYPOINT ["start.sh"]
87 |
88 | # Set CMD
89 | CMD ["apache2-foreground"]
90 |
91 |
--------------------------------------------------------------------------------
/apache.conf:
--------------------------------------------------------------------------------
1 | Listen ${APACHE_PORT}
2 |
3 |
4 | # PHP match
5 |
6 | SetHandler application/x-httpd-php
7 |
8 | # Nextcloud dir
9 | DocumentRoot /var/www/nextcloud/
10 |
11 | Options Indexes FollowSymLinks
12 | Require all granted
13 | AllowOverride All
14 | Options FollowSymLinks MultiViews
15 | Satisfy Any
16 |
17 | Dav off
18 |
19 |
20 | # SSL
21 | SSLCertificateKeyFile /certs/ssl.key
22 | SSLCertificateFile /certs/ssl.crt
23 | SSLEngine on
24 | SSLProtocol -all +TLSv1.2 +TLSv1.3
25 | # Deny access to .ht files
26 |
27 | Require all denied
28 |
29 |
30 |
--------------------------------------------------------------------------------
/cron.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | while true; do
4 | php -f /var/www/nextcloud/cron.php &
5 | sleep 5m
6 | done
7 |
--------------------------------------------------------------------------------
/occ:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | exec php -f /var/www/nextcloud/occ "$@"
4 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # Nextcloud-easy-test
2 | This is a one-command Nextcloud instance that makes it possible to test different branches and apps with just one command.
3 |
4 | ## How to use this?
5 |
6 | ### Preparation (only needed if not done yet):
7 | Install Docker on your OS:
8 | - On Linux via:
9 | ```shell
10 | curl -fsSL https://get.docker.com | sudo sh
11 | ```
12 | - On macOS and Windows via Docker Desktop:
13 | https://www.docker.com/products/docker-desktop
14 |
15 | ### Execution
16 | Run the container:
17 | (You can change the branch by changing `master` in `SERVER_BRANCH=master` to the branch that you want to test during the initial container creation.)
18 |
19 | On Linux and macOS:
20 | ```
21 | docker run -it \
22 | -e SERVER_BRANCH=master \
23 | --name nextcloud-easy-test \
24 | -p 127.0.0.1:8443:443 \
25 | --volume="nextcloud_easy_test_npm_cache_volume:/var/www/.npm" \
26 | ghcr.io/szaimen/nextcloud-easy-test:latest
27 | ```
28 |
29 |
30 | On Windows
31 |
32 | ```
33 | docker run -it ^
34 | -e SERVER_BRANCH=master ^
35 | --name nextcloud-easy-test ^
36 | -p 127.0.0.1:8443:443 ^
37 | --volume="nextcloud_easy_test_npm_cache_volume:/var/www/.npm" ^
38 | ghcr.io/szaimen/nextcloud-easy-test:latest
39 | ```
40 |
41 |
42 |
43 |
44 | Explanation of the command
45 |
46 | `docker run -it`
47 | This command creates a new docker container.
48 |
49 | `-e SERVER_BRANCH=master`
50 | This inserts the environment variable `SERVER_BRANCH` into the container and sets it to the value `master`.
51 |
52 | `--name nextcloud-easy-test`
53 | This gives the container a distinct name `nextcloud-easy-test` so that you are able to easily run other docker commands on the container.
54 |
55 | `-p 127.0.0.1:8443:443`
56 | This makes the container listen on `localhost` and maps the host port `8443` to the container port `443` so that you are able to access the container by opening https://localhost:8443.
57 |
58 | `--volume="nextcloud_easy_test_npm_cache_volume:/var/www/.npm"`
59 | This stores the npm cache in a docker volume so that compiling apps takes less time from the second time. You can clean it with `sudo docker volume rm nextcloud_easy_test_npm_cache_volume`.
60 |
61 | `ghcr.io/szaimen/nextcloud-easy-test:latest`
62 | This is the image name that you will use as base for the container. `latest` is the tag that will be used.
63 |
64 | ---
65 |
66 |
67 |
68 | After the initial startup you will be able to access the instance via https://localhost:8443 and using `admin` as username and `nextcloud` as password.
69 |
70 | ### Follow up
71 |
72 | **After you are done testing**, you can simply stop the container by pressing `[CTRL] + [c]` and delete the container by running:
73 | ```
74 | docker stop nextcloud-easy-test
75 | docker rm nextcloud-easy-test
76 | ```
77 |
78 | ### Running in a VM
79 | If you want to run this in a VM, you need to change the port in the initial command from `-p 127.0.0.1:8443:443` to `-p 8443:443` and add the following flag: `-e TRUSTED_DOMAIN=ip.of.the.VM` in order to automatically make it work.
80 |
81 | ### Available APPS
82 | Additionally, the container currently reacts on the following apps variables and installs and compiles those automatically if provided:
83 | ```
84 | ACTIVITY_BRANCH
85 | ANNOUNCEMENTS_BRANCH
86 | APPROVAL_BRANCH
87 | BOOKMARKS_BRANCH
88 | BRUTEFORCESETTINGS_BRANCH
89 | CALENDAR_BRANCH
90 | CIRCLES_BRANCH
91 | CONTACTS_BRANCH
92 | DECK_BRANCH
93 | DOWNLOADLIMIT_BRANCH
94 | E2EE_BRANCH
95 | FILES_LOCK_BRANCH
96 | FIRSTRUNWIZARD_BRANCH
97 | FORMS_BRANCH
98 | GROUPFOLDERS_BRANCH
99 | GUESTS_BRANCH
100 | IMPERSONATE_BRANCH
101 | INTEGRATIONGITHUB_BRANCH
102 | ISSUTEMPLATE_BRANCH
103 | LOGREADER_BRANCH
104 | MAIL_BRANCH
105 | MAPS_BRANCH
106 | NEWS_BRANCH
107 | NOTES_BRANCH
108 | NOTIFICATIONS_BRANCH
109 | OCS_API_VIEWER_BRANCH
110 | PASSWORDPOLICY_BRANCH
111 | PDFVIEWER_BRANCH
112 | PHOTOS_BRANCH
113 | POLLS_BRANCH
114 | PRIVACY_BRANCH
115 | RECOMMENDATIONS_BRANCH
116 | RELATEDRESOURCES_BRANCH
117 | RIGHTCLICK_BRANCH
118 | SERVERINFO_BRANCH
119 | SURVEYCLIENT_BRANCH
120 | SUSPICIOUSLOGIN_BRANCH
121 | TALK_BRANCH
122 | TASKS_BRANCH
123 | TEXT_BRANCH
124 | TWOFACTORWEBAUTHN_BRANCH
125 | TWOFACTORTOTP_BRANCH
126 | VIEWER_BRANCH
127 | ZIPPER_BRANCH
128 | ```
129 |
130 |
131 | For easy copy and paste
132 |
133 | ```
134 | -e ACTIVITY_BRANCH=master \
135 | -e ANNOUNCEMENTS_BRANCH=master \
136 | -e APPROVAL_BRANCH=main \
137 | -e BOOKMARKS_BRANCH=master \
138 | -e BRUTEFORCESETTINGS_BRANCH=master \
139 | -e CALENDAR_BRANCH=main \
140 | -e CIRCLES_BRANCH=master \
141 | -e CONTACTS_BRANCH=main \
142 | -e DECK_BRANCH=main \
143 | -e DOWNLOADLIMIT_BRANCH=master \
144 | -e E2EE_BRANCH=master \
145 | -e FILES_LOCK_BRANCH=main \
146 | -e FIRSTRUNWIZARD_BRANCH=master \
147 | -e FORMS_BRANCH=main \
148 | -e GROUPFOLDERS_BRANCH=master \
149 | -e GUESTS_BRANCH=master \
150 | -e IMPERSONATE_BRANCH=master \
151 | -e INTEGRATIONGITHUB_BRANCH=main \
152 | -e ISSUTEMPLATE_BRANCH=master \
153 | -e LOGREADER_BRANCH=master \
154 | -e MAIL_BRANCH=main \
155 | -e MAPS_BRANCH=master \
156 | -e NEWS_BRANCH=master \
157 | -e NOTES_BRANCH=main \
158 | -e NOTIFICATIONS_BRANCH=master \
159 | -e OCS_API_VIEWER_BRANCH=main \
160 | -e PASSWORDPOLICY_BRANCH=master \
161 | -e PDFVIEWER_BRANCH=master \
162 | -e PHOTOS_BRANCH=master \
163 | -e POLLS_BRANCH=master \
164 | -e PRIVACY_BRANCH=master \
165 | -e RECOMMENDATIONS_BRANCH=master \
166 | -e RELATEDRESOURCES_BRANCH=master \
167 | -e RIGHTCLICK_BRANCH=master \
168 | -e SERVERINFO_BRANCH=master \
169 | -e SURVEYCLIENT_BRANCH=master \
170 | -e SUSPICIOUSLOGIN_BRANCH=master \
171 | -e TALK_BRANCH=main \
172 | -e TASKS_BRANCH=master \
173 | -e TEXT_BRANCH=main \
174 | -e TWOFACTORWEBAUTHN_BRANCH=main \
175 | -e TWOFACTORTOTP_BRANCH=master \
176 | -e VIEWER_BRANCH=master \
177 | -e ZIPPER_BRANCH=main \
178 | ```
179 |
180 |
181 |
182 | If one of the above variables are set via e.g. `-e CALENDAR_BRANCH=main` during the initial container creation, then will the container automatically get the chosen branch from github and compile and enable the chosen apps on the instance during the startup.
183 |
184 | Branches from custom forks can be installed as well. Use `-e CALENDAR_BRANCH=user:main` to install the `main` branch from the fork of `user`. If the fork has a different name (e.g. nextcloud-calendar), you can use the extended format `-e CALENDAR_BRANCH=user:main@nextcloud-calendar` to pull the branch `main` of the repo `user/nextcloud-calendar`. This format can be used with all app branch variables including `SERVER_BRANCH` and `NEXTCLOUDVUE_BRANCH`.
185 |
186 | ### Other variables
187 | - `MANUAL_INSTALL` if the variable is set, it will skip all apps variables and only clone the given server branch and start Apache directly. You will then be able to provide your own credentials and install recommended apps.
188 | - `SKELETON_ARCHIVE_URL` if the variable is set it will try to download a tar.gz file from a remote server, will untar it and will try to use that as a skeletondir which will make them the default files for new users ony the test instance.
189 | - `COMPILE_SERVER` if the variable is set (so e.g. via `-e COMPILE_SERVER=1`) it will compile javascript files for the chosen server branch. This only works for branches starting from version 24.0.0.
190 | - `FULL_INSTANCE_BRANCH` if the variable is set it will download and install all apps that are bundled by default with a default Nextcloud instance. Set it for example to `stable28`. (**Please note**: Only stable branches are supported and not master or main. Also the support app and the suspicious_login app are never included. Additionally, any js compiling will be skipped if this variable is set).
191 | - `APACHE_PORT` if the variable is set, it will instead of the default port 443 inside the container, use the chosen Port for APACHE.
192 | - `NEXTCLOUDVUE_BRANCH` if the variable is set it will compile javascript files for the chosen nextcloud vue branch and automatically link all chosen apps that use nextcloud vue and additionally the server if COMPILE_SERVER is set.
193 | - `XDEBUG_MODE` if the variable is set it will change the Xdebug mode to the set value. For example `debug`, `trace` or `profile` can be used. If the variable is not set, Xdebug mode will be `off` by default.
194 |
195 | `NEXTCLOUD_LOGLEVEL` this can modify the loglevel of Nextcloud and must be an integer. By default it is set to 3. Valid values are: 0 = Debug, 1 = Info, 2 = Warning, 3 = Error, and 4 = Fatal.
196 |
197 | ## How does it work?
198 | The docker image comes pre-bundled with all needed dependencies for a minimal instance of Nextcloud and allows to define a target branch via environmental variables that will automatically be cloned and compiled during the container startup. For a refresh, you need to recreate the container by first removing it and then running the same command again.
199 |
--------------------------------------------------------------------------------
/remote.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Function to show text in green
4 | print_green() {
5 | local TEXT="$1"
6 | printf "%b%s%b\n" "\e[0;92m" "$TEXT" "\e[0m"
7 | }
8 |
9 | # Show how to reach the server
10 | show_startup_info() {
11 | local SHOWN_PORT
12 | if [ "$APACHE_PORT" = 443 ]; then
13 | SHOWN_PORT=8443
14 | else
15 | SHOWN_PORT="$APACHE_PORT"
16 | fi
17 | if [ -z "$TRUSTED_DOMAIN" ]; then
18 | print_green "The server should now be reachable via https://localhost:$SHOWN_PORT/"
19 | else
20 | print_green "The server should now be reachable via https://$TRUSTED_DOMAIN:$SHOWN_PORT/"
21 | fi
22 | }
23 |
24 | # Manual install: will skip everything and just start apache
25 | manual_install() {
26 | if [ -n "$MANUAL_INSTALL" ]; then
27 | touch /var/www/server-completed
28 | show_startup_info
29 | exit 0
30 | fi
31 | }
32 |
33 | # version_greater A B returns whether A > B
34 | version_greater() {
35 | [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 -k3,3 -k4,4 | head -n 1)" != "$1" ]
36 | }
37 |
38 | # Handle node versions
39 | handle_node_version() {
40 | set -x
41 | if [ -f package.json ]; then
42 | local NODE_LINE
43 | NODE_LINE=$(grep '"node":' package.json | head -1)
44 | fi
45 | if [ -n "$NODE_LINE" ] && echo "$NODE_LINE" | grep -q '\^'; then
46 | local NODE_VERSION
47 | NODE_VERSION="$(echo "$NODE_LINE" | grep -oP '\^[0-9]+' | sed 's|\^||' | head -n 1)"
48 | if [ -n "$NODE_VERSION" ] && [ "$NODE_VERSION" -gt 18 ]; then
49 | if [ "$NODE_VERSION" -gt 20 ]; then
50 | # TODO: NODE_VERSION test should check for 20 and not 22 but checking for 22 temporarily so that script is able to proceed
51 | if [ "$NODE_VERSION" -gt 22 ]; then
52 | echo "The node version of $APPID is too new. Need to update the container."
53 | exit 1
54 | fi
55 | set +x
56 | nvm use lts/jod
57 | else
58 | set +x
59 | nvm use lts/iron
60 | fi
61 | else
62 | set +x
63 | nvm use lts/hydrogen
64 | fi
65 | else
66 | set +x
67 | nvm use lts/hydrogen
68 | fi
69 | }
70 |
71 | # Handle npm versions
72 | handle_npm_version() {
73 | set -x
74 | if [ -f package.json ]; then
75 | local NPM_LINE
76 | NPM_LINE=$(grep '"npm":' package.json | head -1)
77 | fi
78 | if [ -n "$NPM_LINE" ] && echo "$NPM_LINE" | grep -q '\^'; then
79 | local NPM_VERSION
80 | NPM_VERSION="$(echo "$NPM_LINE" | grep -oP '\^[0-9]+' | sed 's|\^||' | head -n 1)"
81 | if [ -n "$NPM_VERSION" ] && [ "$NPM_VERSION" -eq 7 ]; then
82 | set +x
83 | npm i -g npm@latest-7
84 | return
85 | fi
86 | fi
87 |
88 | set +x
89 | nvm install-latest-npm
90 | }
91 |
92 | install_nextcloud_vue() {
93 | if [ -n "$NEXTCLOUDVUE_BRANCH" ] && [ ! -f "/var/www/nextcloud-vue-completed" ]; then
94 | # Handle case that branch is present in nextcloud repo
95 | if ! echo "$NEXTCLOUDVUE_BRANCH" | grep -q ':'; then
96 | NEXTCLOUDVUE_BRANCH="nextcloud:$NEXTCLOUDVUE_BRANCH"
97 | fi
98 | set -x
99 | local VUE_OWNER="${NEXTCLOUDVUE_BRANCH%%:*}"
100 | local VUE_BRANCH="${NEXTCLOUDVUE_BRANCH#*:}"
101 | local VUE_REPO=nextcloud-vue
102 | if echo "$VUE_BRANCH" | grep -q '@'; then
103 | VUE_REPO="${VUE_BRANCH#*@}"
104 | VUE_BRANCH="${VUE_BRANCH%%@*}"
105 | fi
106 | set +x
107 | mkdir /var/www/nextcloud-vue
108 | cd /var/www/nextcloud-vue || exit
109 | if ! git clone https://github.com/"$VUE_OWNER"/"$VUE_REPO".git --branch "$VUE_BRANCH" --single-branch --depth 1 .; then
110 | echo "Could not clone the requested nextcloud vue branch '$VUE_BRANCH' of '$VUE_OWNER/$VUE_REPO'. Does it exist?"
111 | exit 1
112 | fi
113 |
114 | if [ -z "$FULL_INSTANCE_BRANCH" ]; then
115 | # Handle node version
116 | handle_node_version
117 |
118 | # Handle npm version
119 | handle_npm_version
120 |
121 | echo "Compiling Nextcloud vue..."
122 | if ! npm ci --no-audit || ! npm run dev --if-present; then
123 | echo "Could not compile Nextcloud vue"
124 | exit 1
125 | fi
126 |
127 | npm link
128 | fi
129 |
130 | touch "/var/www/nextcloud-vue-completed"
131 | fi
132 | }
133 |
134 | link_nextcloud_vue() {
135 | if [ -n "$NEXTCLOUDVUE_BRANCH" ]; then
136 | if grep -q '@nextcloud/vue' package.json; then
137 | if ! npm link @nextcloud/vue; then
138 | echo "Could not link nextcloud vue in $1."
139 | exit 1
140 | fi
141 | fi
142 | fi
143 | }
144 |
145 | # Handle empty server branch variable
146 | if [ -z "$SERVER_BRANCH" ]; then
147 | export SERVER_BRANCH="nextcloud:master"
148 | fi
149 |
150 | # Handle case that branch is present in nextcloud repo
151 | if ! echo "$SERVER_BRANCH" | grep -q ':'; then
152 | export SERVER_BRANCH="nextcloud:$SERVER_BRANCH"
153 | fi
154 |
155 | if [ -n "$FULL_INSTANCE_BRANCH" ]; then
156 | export SERVER_BRANCH="nextcloud:$FULL_INSTANCE_BRANCH"
157 | export ACTIVITY_BRANCH="$FULL_INSTANCE_BRANCH"
158 | export BRUTEFORCESETTINGS_BRANCH="$FULL_INSTANCE_BRANCH"
159 | export CIRCLES_BRANCH="$FULL_INSTANCE_BRANCH"
160 | export PDFVIEWER_BRANCH="$FULL_INSTANCE_BRANCH"
161 | export FIRSTRUNWIZARD_BRANCH="$FULL_INSTANCE_BRANCH"
162 | export LOGREADER_BRANCH="$FULL_INSTANCE_BRANCH"
163 | export ANNOUNCEMENTS_BRANCH="$FULL_INSTANCE_BRANCH"
164 | export NOTIFICATIONS_BRANCH="$FULL_INSTANCE_BRANCH"
165 | export PASSWORDPOLICY_BRANCH="$FULL_INSTANCE_BRANCH"
166 | export PHOTOS_BRANCH="$FULL_INSTANCE_BRANCH"
167 | export PRIVACY_BRANCH="$FULL_INSTANCE_BRANCH"
168 | export RECOMMENDATIONS_BRANCH="$FULL_INSTANCE_BRANCH"
169 | export RELATEDRESOURCES_BRANCH="$FULL_INSTANCE_BRANCH"
170 | export SERVERINFO_BRANCH="$FULL_INSTANCE_BRANCH"
171 | export SURVEYCLIENT_BRANCH="$FULL_INSTANCE_BRANCH"
172 | export TEXT_BRANCH="$FULL_INSTANCE_BRANCH"
173 | export TWOFACTORTOTP_BRANCH="$FULL_INSTANCE_BRANCH"
174 | export VIEWER_BRANCH="$FULL_INSTANCE_BRANCH"
175 | fi
176 |
177 | # Get NVM code
178 | export NVM_DIR="/var/www/.nvm"
179 | # shellcheck disable=SC1091
180 | . "$NVM_DIR/nvm.sh"
181 |
182 | # Get latest changes
183 | if ! [ -f /var/www/server-completed ]; then
184 | set -x
185 | FORK_OWNER="${SERVER_BRANCH%%:*}"
186 | FORK_BRANCH="${SERVER_BRANCH#*:}"
187 | FORK_REPO=server
188 | if echo "$FORK_BRANCH" | grep -q '@'; then
189 | FORK_REPO="${FORK_BRANCH#*@}"
190 | FORK_BRANCH="${FORK_BRANCH%%@*}"
191 | fi
192 | set +x
193 | cd /var/www/nextcloud || exit
194 | if ! git clone https://github.com/"$FORK_OWNER"/"$FORK_REPO".git --branch "$FORK_BRANCH" --single-branch --depth 1 .; then
195 | echo "Could not clone the requested server branch '$FORK_BRANCH' of '$FORK_OWNER/$FORK_REPO'. Does it exist?"
196 | exit 1
197 | fi
198 |
199 | # Initiate submodules
200 | git submodule update --init
201 |
202 | # Allow to compile the server javascript
203 | if [ -z "$FULL_INSTANCE_BRANCH" ] && [ -n "$COMPILE_SERVER" ]; then
204 | set -x
205 | # shellcheck disable=SC2016
206 | installed_version="$(php -r 'require "/var/www/nextcloud/version.php"; echo implode(".", $OC_Version);')"
207 | if version_greater "$installed_version" "24.0.0.0"; then
208 | # Install Nextcloud vue
209 | install_nextcloud_vue
210 | cd /var/www/nextcloud || exit
211 |
212 | # Handle node version
213 | handle_node_version
214 |
215 | # Handle npm version
216 | handle_npm_version
217 |
218 | echo "Compiling server..."
219 | if ! npm ci --no-audit || ! link_nextcloud_vue server || ! npm run dev --if-present || ! npm run sass --if-present || ! npm run icon --if-present; then
220 | echo "Could not compile server."
221 | exit 1
222 | fi
223 | else
224 | echo "Could not compile server because the version is not higher than 24.0.0"
225 | exit 1
226 | fi
227 | set +x
228 | fi
229 |
230 | # Manual install
231 | manual_install
232 |
233 | # Install Nextcloud
234 | if ! php -f occ \
235 | maintenance:install \
236 | --database=sqlite \
237 | --admin-user=admin \
238 | --admin-pass=nextcloud; then
239 | echo "Failed to create the instance."
240 | exit 1
241 | fi
242 |
243 | php -f occ config:system:set log_type --value "errorlog"
244 |
245 | # Set trusted domain if needed
246 | if [ -n "$TRUSTED_DOMAIN" ]; then
247 | if ! php -f occ config:system:set trusted_domains 1 --value="$TRUSTED_DOMAIN"; then
248 | echo "Could not set the trusted domain '$TRUSTED_DOMAIN'"
249 | exit 1
250 | fi
251 | fi
252 | touch /var/www/server-completed
253 | fi
254 |
255 | # Manual install
256 | manual_install
257 |
258 | # Handle skeleton archive url
259 | if [ -n "$SKELETON_ARCHIVE_URL" ] && ! [ -f "/var/www/skeleton-completed" ]; then
260 | set -x
261 | if ! curl -fsSL "$SKELETON_ARCHIVE_URL" -o /var/www/nextcloud/data/skeletondir.tar.gz; then
262 | echo "Could not get the sekeleton archive url"
263 | exit 1
264 | fi
265 | mkdir -p "/var/www/nextcloud/data/skeletondir"
266 | if ! tar -xf "/var/www/nextcloud/data/skeletondir.tar.gz" -C "/var/www/nextcloud/data/skeletondir"; then
267 | echo "Could not untar the archive. Is it a tar.gz archive?"
268 | exit 1
269 | fi
270 | if ! php -f occ config:system:set skeletondirectory --value="/var/www/nextcloud/data/skeletondir"; then
271 | echo "Could not set the skeletondir"
272 | exit 1
273 | fi
274 | if ! rm -r /var/www/nextcloud/data/admin/files/*; then
275 | echo "Could not remove the default admin files"
276 | exit 1
277 | fi
278 | if ! cp -R /var/www/nextcloud/data/skeletondir/* /var/www/nextcloud/data/admin/files/; then
279 | echo "Could not copy the files to the admin user"
280 | exit 1
281 | fi
282 | if ! php -f occ files:scan admin; then
283 | echo "Could not scan the new files for the admin user."
284 | exit 1
285 | fi
286 | set +x
287 | touch /var/www/skeleton-completed
288 | fi
289 |
290 | # Install and enable apps
291 | install_enable_app() {
292 |
293 | # Variables
294 | local BRANCH="$1"
295 | local APPID="$2"
296 |
297 | # Logic
298 | if [ -n "$BRANCH" ] && ! [ -f "/var/www/$APPID-completed" ]; then
299 |
300 | # Go into apps directory
301 | cd /var/www/nextcloud/apps || exit
302 |
303 | # Remove app directory
304 | if [ -d ./"$APPID" ]; then
305 | php -f ../occ app:disable "$APPID"
306 | rm -r ./"$APPID"
307 | fi
308 |
309 | # Handle case that branch is present in nextcloud repo
310 | if ! echo "$BRANCH" | grep -q ':'; then
311 | BRANCH="nextcloud:$BRANCH"
312 | fi
313 |
314 | # Clone repo
315 | set -x
316 | local APP_OWNER="${BRANCH%%:*}"
317 | local APP_BRANCH="${BRANCH#*:}"
318 | local APP_REPO="$APPID"
319 | if echo "$APP_BRANCH" | grep -q '@'; then
320 | APP_REPO="${APP_BRANCH#*@}"
321 | APP_BRANCH="${APP_BRANCH%%@*}"
322 | fi
323 | set +x
324 | if ! git clone https://github.com/"$APP_OWNER"/"$APP_REPO".git --branch "$APP_BRANCH" --single-branch --depth 1 "$APPID"; then
325 | echo "Could not clone the requested branch '$APP_BRANCH' of the $APPID app of '$APP_OWNER/$APP_REPO'. Does it exist?"
326 | exit 1
327 | fi
328 |
329 | # Install Nextcloud vue
330 | install_nextcloud_vue
331 | cd /var/www/nextcloud/apps/ || exit
332 |
333 | # Go into app directory
334 | cd ./"$APPID" || exit
335 |
336 | # if [ "$APPID" = mail ]; then
337 | # wget https://getcomposer.org/download/1.10.22/composer.phar
338 | # chmod +x ./composer.phar
339 | # if ! ./composer.phar install --no-dev; then
340 | # echo "Could not install composer dependencies of the mail app."
341 | # exit 1
342 | # fi
343 |
344 | # Install composer dependencies
345 | if [ -f composer.json ]; then
346 | if ! composer install --no-dev; then
347 | echo "Could not install composer dependencies of the $APPID app."
348 | exit 1
349 | fi
350 | fi
351 |
352 | if [ -z "$FULL_INSTANCE_BRANCH" ]; then
353 | # Handle node version
354 | handle_node_version
355 |
356 | # Handel npm version
357 | handle_npm_version
358 |
359 | # Compile apps
360 | if [ -f package.json ]; then
361 | # Link nextcloud vue
362 | link_nextcloud_vue "$APPID"
363 | if ! npm ci --no-audit || ! link_nextcloud_vue "$APPID" || ! npm run dev --if-present; then
364 | echo "Could not compile the $APPID app."
365 | exit 1
366 | fi
367 | fi
368 | fi
369 |
370 | # Go into occ directory
371 | cd /var/www/nextcloud || exit
372 |
373 | # Enable app
374 | if ! php -f occ app:enable "$APPID"; then
375 | echo "Could not enable the $APPID app."
376 | exit 1
377 | fi
378 |
379 | # The app was enabled
380 | touch "/var/www/$APPID-completed"
381 | fi
382 | }
383 |
384 | # Compatible apps
385 | install_enable_app "$ACTIVITY_BRANCH" activity
386 | install_enable_app "$ANNOUNCEMENTS_BRANCH" nextcloud_announcements
387 | install_enable_app "$APPROVAL_BRANCH" approval
388 | install_enable_app "$BOOKMARKS_BRANCH" bookmarks
389 | install_enable_app "$BRUTEFORCESETTINGS_BRANCH" bruteforcesettings
390 | install_enable_app "$CALENDAR_BRANCH" calendar
391 | install_enable_app "$CIRCLES_BRANCH" circles
392 | install_enable_app "$CONTACTS_BRANCH" contacts
393 | install_enable_app "$DECK_BRANCH" deck
394 | install_enable_app "$DOWNLOADLIMIT_BRANCH" files_downloadlimit
395 | install_enable_app "$E2EE_BRANCH" end_to_end_encryption
396 | install_enable_app "$FILES_LOCK_BRANCH" files_lock
397 | install_enable_app "$FIRSTRUNWIZARD_BRANCH" firstrunwizard
398 | # shellcheck disable=SC2153
399 | install_enable_app "$FORMS_BRANCH" forms
400 | install_enable_app "$GROUPFOLDERS_BRANCH" groupfolders
401 | install_enable_app "$GUESTS_BRANCH" guests
402 | install_enable_app "$IMPERSONATE_BRANCH" impersonate
403 | install_enable_app "$INTEGRATIONGITHUB_BRANCH" integration_github
404 | install_enable_app "$ISSUTEMPLATE_BRANCH" issuetemplate
405 | install_enable_app "$LOGREADER_BRANCH" logreader
406 | install_enable_app "$MAIL_BRANCH" mail
407 | # shellcheck disable=SC2153
408 | install_enable_app "$MAPS_BRANCH" maps
409 | install_enable_app "$NEWS_BRANCH" news
410 | install_enable_app "$NOTES_BRANCH" notes
411 | install_enable_app "$NOTIFICATIONS_BRANCH" notifications
412 | install_enable_app "$OCS_API_VIEWER_BRANCH" ocs_api_viewer
413 | install_enable_app "$PASSWORDPOLICY_BRANCH" password_policy
414 | install_enable_app "$PDFVIEWER_BRANCH" files_pdfviewer
415 | install_enable_app "$PHOTOS_BRANCH" photos
416 | install_enable_app "$POLLS_BRANCH" polls
417 | install_enable_app "$PRIVACY_BRANCH" privacy
418 | install_enable_app "$RECOMMENDATIONS_BRANCH" recommendations
419 | install_enable_app "$RELATEDRESOURCES_BRANCH" related_resources
420 | install_enable_app "$RIGHTCLICK_BRANCH" files_rightclick
421 | install_enable_app "$SERVERINFO_BRANCH" serverinfo
422 | install_enable_app "$SURVEYCLIENT_BRANCH" survey_client
423 | install_enable_app "$SUSPICIOUSLOGIN_BRANCH" suspicious_login
424 | install_enable_app "$TALK_BRANCH" spreed
425 | install_enable_app "$TASKS_BRANCH" tasks
426 | install_enable_app "$TEXT_BRANCH" text
427 | install_enable_app "$TWOFACTORWEBAUTHN_BRANCH" twofactor_webauthn
428 | install_enable_app "$TWOFACTORTOTP_BRANCH" twofactor_totp
429 | install_enable_app "$VIEWER_BRANCH" viewer
430 | install_enable_app "$ZIPPER_BRANCH" files_zip
431 |
432 | # Clear cache
433 | cd /var/www/nextcloud || exit
434 | if ! php -f occ maintenance:repair; then
435 | echo "Could not clear the cache"
436 | exit 1
437 | fi
438 |
439 | # Set Xdebug options
440 | if [ -n "$XDEBUG_MODE" ]; then
441 | sed -i 's/^xdebug.mode\s*=\s*.*/xdebug.mode='"$XDEBUG_MODE"'/g' /usr/local/etc/php/conf.d/xdebug.ini
442 | fi
443 |
444 | # Set loglevel
445 | if [ -n "$NEXTCLOUD_LOGLEVEL" ]; then
446 | php -f occ config:system:set loglevel --value "$NEXTCLOUD_LOGLEVEL" --type int
447 | if [ "$NEXTCLOUD_LOGLEVEL" = 0 ]; then
448 | php -f occ config:system:set debug --value true --type bool
449 | fi
450 | fi
451 |
452 | # Show how to reach the server
453 | show_startup_info
454 | print_green "You can log in with the user 'admin' and its password 'nextcloud'"
455 |
--------------------------------------------------------------------------------
/start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Remove local remote script if already present
4 | rm -f remote.sh
5 |
6 | # Download remote script
7 | if ! wget https://raw.githubusercontent.com/szaimen/nextcloud-easy-test/main/remote.sh; then
8 | echo "Failed to download the remote script."
9 | exit 1
10 | fi
11 |
12 | # Execute it
13 | if ! bash remote.sh; then
14 | exit 1
15 | fi
16 |
17 | # Start system cron
18 | exec bash /cron.sh &
19 |
20 | # Run the default CMD script
21 | exec "$@"
22 |
--------------------------------------------------------------------------------