d2c.sh icon indicating copy to clipboard operation
d2c.sh copied to clipboard

Error: open /etc/d2c/d2c.toml: permission denied

Open alfirus opened this issue 1 year ago • 2 comments

I installed, create /etc.d2c/d2c.toml accordingly. However when I run

"d2c.sh" or "sudo "d2c.sh", I'm facing this problem

Error: open /etc/d2c/d2c.toml: permission denied

alfirus avatar May 20 '24 04:05 alfirus

Hi,

I understand you followed "Method 1" in the README?

  1. Install with install.sh (Copies d2c.sh into /usr/local/bin)
  2. Create etc/d2c/d2c.toml and fill your own configuration
  3. Run d2c.sh

I just tried the process and worked fine:

root@DRIES:~/temp/d2c.sh# ./install
Successfully installed d2c.sh into /usr/local/bin.
Please, run d2c.sh from command-line before scheduling any cronjob.
Help: `d2c.sh --help` or `d2c.sh -h` or `d2c.sh help`.

root@DRIES:~/temp/d2c.sh# d2c.sh
Error: 'yq' required and not found.
Please install: https://github.com/mikefarah/yq.

( ... install yq ... )

root@DRIES:~/temp/d2c.sh# d2c.sh
Directory: /etc/d2c/ does not exist.
Creating...
Created /etc/d2c/. Please, fill /etc/d2c/d2c.toml.

ddries avatar May 20 '24 08:05 ddries

I tried. Maybe because of d2c.toml permission attribute?

-rw-r--r-- 1 root root 243 May 20 17:57 /etc/d2c/d2c.toml

alfirus avatar May 20 '24 17:05 alfirus

What is your file permission attribute?

alfirus avatar May 24 '24 03:05 alfirus

Hi! Sorry for the delay. First of all, I would like to thank you for giving a try to d2c.sh. Let's try to make it work for you!

My file permissions are the same as you:

root@DRIES:/etc/d2c# ls -la
total 12
drwxr-xr-x  2 root root 4096 May 20 08:24 .
drwxr-xr-x 81 root root 4096 May 20 08:24 ..
-rw-r--r--  1 root root  148 May 20 08:24 d2c.toml

Are you able to edit d2c.toml using a text editor? Maybe sudo nano /etc/d2c/d2c.toml. Plus, could you check file permissions for the actual executable?

Mine:

root@DRIES:/usr/local/bin# ls -la d2c.sh
-rwxr-xr-x 1 root root 3469 May 20 08:23 d2c.sh

Let me try in a different host to check I get the same error as you do.

ddries avatar May 24 '24 11:05 ddries

Are you able to edit d2c.toml Yes

check file permissions for the actual executable? Same as yours.

I'll try to install and setup as root and give you feedback

alfirus avatar May 25 '24 01:05 alfirus

Same even i install as su - root

alfirus avatar May 25 '24 01:05 alfirus

However i edit d2c.sh

from config_file_dir="/etc/d2c/" to config_file_dir=""

and put the dc2.toml in the same directory, it work.

alfirus avatar May 25 '24 02:05 alfirus

Mmmm, that is very strange. I guess that for some reason that I don't understand, d2c.sh can't read the /etc/ directory. You can put d2c.toml wherever you want and it will work, I guess you can try the home directory for better organization, maybe

config_file_dir="$HOME/.d2c/"

Whatever you prefer!

ddries avatar May 26 '24 08:05 ddries

For info, i'm using

  • Ubuntu 22.04
  • Install and config always using sudo

Suggestion, maybe you can add cronjob script run every 10 minutes in d2c.sh. It will help safe time.

alfirus avatar May 26 '24 11:05 alfirus