LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Programs Cannot Make Directories or Files (https://www.linuxquestions.org/questions/linux-newbie-8/programs-cannot-make-directories-or-files-4175545985/)

akashi 06-21-2015 02:45 AM

Programs Cannot Make Directories or Files
 
I'm using Raspbian on a Raspberry Pi which is based on Debian and have encountered a strange problem.

I compiled a program called aria2 from source and installed it with make install.

On the config file
Code:

/etc/aria2.conf
I asked it to save it's session file to
Code:

/home/pi/.aria2/session.dat
However, when I run the start-up script
Code:

/etc/init.d/aria2.sh start
It does not run.

If I first make the directory and create an empty file called session.dat, it starts perfectly.

This is not the only program I have noticed has this behaviour.

When you create a mount point in fstab file, it fails to mount unless the directory mentioned already exists.

I am running everything as root so permission cannot be a problem.

Please help me understand if this is normal Linux behaviour or I am missing something.

Thanks in advance.

ButterflyMelissa 06-21-2015 02:59 AM

editted out I negleted to read some crucial info..

veerain 06-21-2015 04:23 AM

Quote:

When you create a mount point in fstab file, it fails to mount unless the directory mentioned already exists.
You definitely need a directory so some filesystem can mount over it.

What is in your aria2.sh init file? Have you inspected it for possible reasons?

brianL 06-21-2015 07:21 AM

Did you have some reason for compiling aria2 yourself, and not getting the ready made package?
https://packages.debian.org/wheezy/aria2

akashi 06-21-2015 12:22 PM

Quote:

Originally Posted by veerain (Post 5380582)
You definitely need a directory so some filesystem can mount over it.

What is in your aria2.sh init file? Have you inspected it for possible reasons?

Thanks, here is the start-up script:

Code:

#!/bin/sh
### BEGIN INIT INFO
# Provides: aria2
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: aria2c init script.
# Description: Starts and stops aria2 daemon.
### END INIT INFO

USER="root"
DAEMON=/usr/local/bin/aria2c
CONF=/etc/aria2.conf

start() {
if [ -f $CONF ]; then
echo "Starting aria2 daemon"
start-stop-daemon -S -c $USER -x $DAEMON -- -D --enable-rpc --conf-path=$CONF
else
echo "Couldn't start aria2 daemon for $USER (no $CONF found)"
fi
}

stop() {
start-stop-daemon -o -c $USER -K -u $USER -x $DAEMON
}
status() {
dbpid=`pgrep -fu $USER $DAEMON`
if [ -z "$dbpid" ]; then
echo "aria2c daemon for USER $btsuser: not running."
else
echo "aria2c daemon for USER $btsuser: running (pid $dbpid)"
fi
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload|force-reload)
stop
start
;;
status)
status
;;
*)
echo "Usage: /etc/init.d/aria2 {start|stop|reload|force-reload|restart|status}"
exit 1
esac

exit 0


akashi 06-21-2015 12:24 PM

Quote:

Originally Posted by brianL (Post 5380632)
Did you have some reason for compiling aria2 yourself, and not getting the ready made package?
https://packages.debian.org/wheezy/aria2

I compiled the program from source to get the latest version as well as learn compiling.

berndbausch 06-21-2015 09:27 PM

Quote:

Originally Posted by akashi (Post 5380545)
I am running everything as root so permission cannot be a problem.

This is not a correct assumption. The program in question (/usr/local/bin/aria2c) may become an unprivileged user after doing some initial setup. This is good practice to avoid security problems.

Also, the program may simply not create the directory. It could be a bug, or a deliberate measure.

To understand the situation better, there are number of options: Check if aria2c creates a log file with error messages. Or if it can be run with a verbose or debug flag to provide more information. Check under which user ID it runs. Using the source code or a system call trace (strace command), find whether it issues a mkdir system call, and if yes, how it fails.

And then if all else fails you might even consider reading the documentation :D

akashi 06-25-2015 09:36 PM

berndbausch, thank you for this information.

I read the manual for aria2 and found I made a mistake on the configuration file.

The reason this directory and file was not being created was because it was an actual input file for aria2 to load urls from.

Thanks to everyone who helped.


All times are GMT -5. The time now is 08:17 PM.