#StackBounty: #shutdown #systemd #dropbox Could not resolve host: content.dropboxapi.com when to upload file at shutdown

Bounty: 150

I want to upload file into my dropbox when my pc is shutdowning.

sudo vim  /etc/systemd/system/upload.service
[Unit]
Description=upload files into dropbox
Before=network.target shutdown.target  reboot.target
Requires=network-online.target

[Service]
ExecStop=/bin/true
ExecStart=/bin/bash  /home/upload.sh 
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target

And the upload.sh script.

cd  /home
curl -X POST https://content.dropboxapi.com/2/files/upload 
            --header "Authorization: Bearer xxxx" 
            --header "Dropbox-API-Arg:  {"path":"/test.txt","mode":{".tag":"overwrite"}}" 
            --header "Content-Type: application/octet-stream" 
            --data-binary @"test.txt"

bash upload.sh can executed successfully,and test.txt file uploaded into my dropbox.

sudo systemctl enable upload service  

To reboot my pc.

sudo journalctl -u upload 

Apr 13 23:58:52 localhost systemd[1]: Started upload files into dropbox.
Apr 13 23:58:52 localhost systemd[1]: Starting upload files into dropbox...
Apr 13 23:58:52 localhost bash[117]: % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Apr 13 23:58:52 localhost bash[117]: Dload  Upload   Total   Spent    Left  Speed
Apr 13 23:58:52 localhost bash[117]: 0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: content.dropboxapi.com; Un
Apr 13 23:58:52 localhost systemd[1]: upload.service: main process exited, code=exited, status=6/NOTCONFIGURED
Apr 13 23:58:52 localhost systemd[1]: Unit upload.service entered failed state.
Apr 13 23:58:52 localhost systemd[1]: upload.service failed.

Some DNS error Could not resolve host: content.dropboxapi.com result in upload.service failed.

I have added Requires=network-online.target in upload.service,how to make DNS parser resolve the host at my pc’s shutdowning time?


Get this bounty!!!

Leave a Reply