Automatic Start of a java command or script in jail

Status
Not open for further replies.

Powerduck

Cadet
Joined
Jan 31, 2014
Messages
6
Hello All,

I am a Newbie reg. FreeNas/ FreeBSD (only good Win-Knowledge), but managed to build a NAS based on FreeNas. Everything working except an automatic backup to 1und1 (German provider).

What was done already:
FreeNas 9.2 Jail created, OpenJDK 7 installed. Backup shall be done via Java script in file "Backup1und1.sh" (see attached as "...txt").
I need to run at start (or directly after start) :
"java -jar /1und1/webdav-sync.jar -server https://sd2dav.1und1.de -local /1und1/ -remote /Dokumente -r 10 -log upload.log -maxsize 500"
(Password/Login are stored separatly)

Setup was done as followed:
1) path
/mnt/NASPool/jails/WebDav-Backup/etc/rc.d
I stored there "Backup1und1.sh", rights 0755/ rwx (via chmod and via WinSCP)
2) path
/mnt/NASPool/jails/WebDav-Backup/etc/
in "rc.conf" added "Backup1und1_enable="YES".

I copied the Backup1und1.sh also to usr/local/etc but without success.

User "root" is member of group wheel.

If I call the script manually (root@webDAV-Backup), everything is working
change to "etc/rc.d"
sh Backup1und1.sh

and the Backup starts :) .

I tried also now to run it at postinit command:, not from the jail, but from the FreeNas:

jexec 1 java -jar webdav-sync.jar -server https://sd2dav.1und1.de -local /1und1/ -remote /Sicherungen -r 10 -log upload.log -maxsize 500

Also not working

Thanks for lighting my dark..
Rgds Jens
 

Attachments

  • Backup1und1.txt
    208 bytes · Views: 286

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Hello All,

I am a Newbie reg. FreeNas/ FreeBSD (only good Win-Knowledge), but managed to build a NAS based on FreeNas. Everything working except an automatic backup to 1und1 (German provider).

What was done already:
FreeNas 9.2 Jail created, OpenJDK 7 installed. Backup shall be done via Java script in file "Backup1und1.sh" (see attached as "...txt").
I need to run at start (or directly after start) :
"java -jar /1und1/webdav-sync.jar -server https://sd2dav.1und1.de -local /1und1/ -remote /Dokumente -r 10 -log upload.log -maxsize 500"
(Password/Login are stored separatly)

Setup was done as followed:
1) path
/mnt/NASPool/jails/WebDav-Backup/etc/rc.d
I stored there "Backup1und1.sh", rights 0755/ rwx (via chmod and via WinSCP)
2) path
/mnt/NASPool/jails/WebDav-Backup/etc/
in "rc.conf" added "Backup1und1_enable="YES".

I copied the Backup1und1.sh also to usr/local/etc but without success.

User "root" is member of group wheel.

If I call the script manually (root@webDAV-Backup), everything is working
change to "etc/rc.d"
sh Backup1und1.sh

and the Backup starts :) .

I tried also now to run it at postinit command:, not from the jail, but from the FreeNas:

jexec 1 java -jar webdav-sync.jar -server https://sd2dav.1und1.de -local /1und1/ -remote /Sicherungen -r 10 -log upload.log -maxsize 500

Also not working

Thanks for lighting my dark..
Rgds Jens

Don't call /bin/bash, it doesn't exist.
I recommend creating a proper FreeBSD rc.d script, http://www.freebsd.org/doc/en/articles/rc-scripting/

Here's an example of a java program you can just quickly modify. https://github.com/josh4trunks/Free...r/ports/multimedia/subsonic/files/subsonic.in
The below variables would be automatically replaced when I actually make the port, but you should replace these yourself.
%%PORTNAME%%=subsonic
%%USER%%=media
%%GROUP%%=media
%%PREFIX%%=/usr/local
%%JAVA_CMD%%=/usr/local/openjdk7/bin/java

If you fit your prorgram into a proper rc.d script then the FreeBSD init system will properly start and stop it for you. You could also call 'service program start/stop/status'.
 

Powerduck

Cadet
Joined
Jan 31, 2014
Messages
6
Thanks for the link. Will go through and check if I missed some important steps.

Rgds Jens
 
Status
Not open for further replies.
Top