Monthly Archives: May 2022

Using rclone to synchronize a OneDrive share (headless)

Goals

Synchronize a OneDrive folder, re-share it locally via a web server.

TODO: Run rclone as a service

Prerequisistes

  • Single-Use OneDrive Account with a shared folder
  • Alpine Linux VM

Installation

Enable the community repository in /etc/apk/repositories. Update and install rclone and nginx.

# apk update
# apk upgrade
# apk add rclone nginx

Configuration

The local files will be stored under /var/www/wifishare, thus rclone will synchronize to this location and nginx will use this as root (with autoindex on).

Create folder

# mkdir /var/www/wifishare

Configure rclone

Start the configuration step (ideally via SSH where you can copy paste the token later on):

# rclone config

Make a new remote (n)
Name it (wifishare)
Choose provider (onedrive)
Leave client_id and client_secret empty
region: global (depends on your setup)
No advanced config
No auto config (since we are running headless)

On a machine with a web browser:

$ rclone authorize "onedrive"

and follow the login process in the browser. Then, copy and paste the token as indicated.
config_type onedrive

Initial sync (interactive):

rclone sync -i wifishare:/public /var/www/wifishare

Configure nginx

Set root directory and enable directory listing. In this case, by modifying the default config.

server {
	listen 80 default_server;
	listen [::]:80 default_server;

	root /var/www/wifishare;

	location / {
		autoindex on;
	}
}

Restart and enable service

# rc-service nginx restart
# rc-update add nginx

Nextcloud on all-inkl.com: PHP memory limit

Updating Nextcloud installs a fresh .htaccess file. This can lead to an error message in the Administration/Overview page: “The PHP memory limit is below the recommended value of 512MB.”. To resolve the issue, add the following to the bottom of your .htaccess file:

php_value memory_limit 512M

Don’t forget to update the .htaccess after the next Nextcloud update!

Update: for php >= 8 you need the following in your .user.ini file:

memory_limit=512M