Onedrive

Ahmad Hadidi Ahmad Hadidi

Host

Create CT

pct create \
106 \
/mnt/pve/evo/template/cache/alpine-3.21-default_20241217_amd64.tar.xz \
--hostname onedrive \
--cores 2\
--memory 2048 \
--net0 name=eth0,bridge=vmbr0,firewall=1,gw=192.168.0.1,ip=192.168.0.106/24,hwaddr=DE:AD:DE:AD:01:06,type=veth,ip6=dhcp \
--storage localblock \
--rootfs local-lvm:2 \
--unprivileged 1 \
--ignore-unpack-errors \
--ostype alpine \
--password="123123123" \
--start 0 \
--ssh-public-key=prod-lan-[HO4]

CT Conf

echo "mp0: /mnt/pve/evo/onedrive,mp=/onedrive " >> /etc/pve/lxc/106.conf
echo "lxc.idmap: u 0 100000 1000" >> /etc/pve/lxc/106.conf
echo "lxc.idmap: g 0 100000 1000" >> /etc/pve/lxc/106.conf
echo "lxc.idmap: u 1000 1000 1" >> /etc/pve/lxc/106.conf
echo "lxc.idmap: g 1000 1000 1" >> /etc/pve/lxc/106.conf
echo "lxc.idmap: u 1001 101001 64535" >> /etc/pve/lxc/106.conf
echo "lxc.idmap: g 1001 101001 64535" >> /etc/pve/lxc/106.conf

Enter CT

pct enter 106

In CT

![[Configs & Resources/Linux/Common/Alpine#Enable DHCP Leasing - Alpine|Alpine]]

apk add onedrive --repository="https://dl-cdn.alpinelinux.org/alpine/edge/community"
apk add nano openssl onedrive
rc-update add onedrive  # add to boot
addgroup -g 1000 onedrive

adduser -D onedrive -u 1000 -G onedrive -s /bin/ash
echo "onedrive:123123123" | chpasswd
chmod 770 /onedrive -R
chown onedrive -R /onedrive

su onedrive
cd ~

# Authorize the app by following it's instructions
onedrive

# Prime the config file
echo 'sync_dir = "/onedrive"
skip_dir = ""
skip_file = ""
enable_logging = true' > ~/.config/onedrive/config
echo 'Knowledge/Genesis/*' > ~/.config/onedrive/config
onedrive --display-config # review what will happen
onedrive --sync --resync  --dry-run --verbose --display-config  # I used this after following the guide and I'm genuinely lost...
onedrive --resync --monitor --verbose  # 

Edit the service

nano /etc/init.d/onedrive
#!/sbin/openrc-run

supervisor=supervise-daemon
name=onedrive
description="Onedrive Daemon Service"

command=/usr/bin/onedrive
command_user="onedrive"
command_args="--monitor --enable-logging --resync-auth --resync"
pidfile="/tmp/onedrive.pid"  # safer for containers

output_log="/var/log/onedrive/onedrive.log"
error_log="/var/log/onedrive/onedrive_error.log"

depend() {
    need net
    after firewall
}

start_pre() {
    checkpath --directory --mode 0755 --owner "$command_user:$command_user" /var/log/onedrive
    checkpath --file --mode 0644 --owner "$command_user:$command_user" "$output_log"
    checkpath --file --mode 0644 --owner "$command_user:$command_user" "$error_log"
}
service onedrive start --verbose  # will show a "supervise-daemon: fopen `/run/onedrive.pid': No such file or directory" but that's okay.
tail -f /var/log/onedrive/*  # works just like journalctl -xe
resync always required · abraunegg/onedrive · Discussion #3183 · GitHub

Cheatsheet

  1. sync_list