AlpineLinux 3.7: Install davfs2 for WebDAV client

This article will describe installing davfs2 for WebDAV client.

1 Install davfs2

Install davfs2 package.

$ sudo sed -e 's;^#http\(.*\)/v3.7/community;http\1/v3.7/community;g' \
       -i /etc/apk/repositories
$ sudo apk update
$ sudo apk add davfs2

2 Get SSL certification

You need to get SSL certification for https.

$ sudo apk add openssl
$ openssl s_client -showcerts -connect "${WEBDAV_SERVER_FQDN}":443 \
          < /dev/null 2> /dev/null | \
    openssl x509 -outform PEM | \
    sudo tee /etc/davfs2/certs/"${WEBDAV_SERVER_FQDN}".pem
$ echo "trust_server_cert ${WEBDAV_SERVER_FQDN}.pem" | \
    sudo tee -a /etc/davfs2/davfs2.conf

3 Mount WebDAV with davfs2

Mount WebDAV with davfs2 to /mnt directory. Input username and password, and respond to caution of SSL certification.

$ sudo mount -t davfs ${WEBDAV_SERVER_URL} /mnt
Please enter the username to authenticate with server or hit enter for none.
  Username: Please enter the password to authenticate user admin with server or hit enter for none.

4 Omit username and password

Writing username and password to /etc/davfs2/secrets will omit inputing username and password.

/etc/davfs2/secrets is the following format.

<URL> <username> <password>

Add URL, username and password to /etc/davfs2/secrets and change permission to 600.

sudo tee -a /etc/davfs2/secrets
$ sudo chmod 600 /etc/davfs2/secrets

5 Mount WebDAV on boot

Add mount entry to /etc/fstab. For avoiding mounting WebDAV before network initialization, you need to add _netdev option.

$ sudo rc-update add netmount
$ echo "${WEBDAV_SERVER_URL} /mnt davfs _netdev 0 0" | \
    sudo tee -a /etc/fstab