NzbDrone and FreeBSD/Freenas

Status
Not open for further replies.

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
NzbDrone is a great alternative to Sickbeard and adds many good features and is able to retrieve shows that Sickbeard cannot. This is why I am really interested in getting it to run on my Freenas server. Currently I am using Sickbeard but I find that some shows due to the naming of the episodes do not download or the wrong episode is retrieved.

My goal is to get NzbDrone working in a Freenas jail and communicating with Sabnzbd. Currently it will only work with mono, because there is no true port to FreeBSD. I have already posted on the NZBDrone forums about adding a FreeBSD port.

I have myself tried creating a standard jail and installing mono and sqlite, which are needed for NZBDrone to work. But I was unsuccessful, NzbDrone refused to start. I am not well versed in FreeBSD and I am requesting some assistance in getting this application working in a jail.

When testing I created a standard jail with only VIMAGE checked. This is where I may need help, there may be a specific way to setup the jail for NzbDrone to work properly.

I used pkg install to install mono and sqlite in the jail. Then copied the windows version of NzbDrone to the jail, gave it the proper permissions and used mono NzbDrone.exe to start the program.

I am looking to the community here for guidance on something I may have missed or additional ideas to try.

Below is the error that is received (I have sent this error to the developer)

Code:
root@NzbDrone:/usr/NzbDrone # mono NzbDrone.exe
[Info] Bootstrap: Starting NzbDrone Console. Version 2.0.0.855
[Info] MigrationLogger: *** Migrating data source=/root/.config/NzbDrone/nzbdrone.db;cache size=-10485760;datetimekind=Utc;journal mode=Wal ***
[Info] MigrationLogger: *** VersionMigration migrating ***
[Info] MigrationLogger: *** VersionUniqueMigration migrating ***
[Info] MigrationLogger: *** 1: InitialSetup migrating ***
[Info] MigrationLogger: *** 2: remove_tvrage_imdb_unique_constraint migrating ***
[Info] MigrationLogger: *** 3: remove_renamed_scene_mapping_columns migrating ***
[Info] MigrationLogger: *** 4: updated_history migrating ***
[Info] MigrationLogger: *** 5: added_eventtype_to_history migrating ***
[Info] MigrationLogger: *** 6: add_index_to_log_time migrating ***
[Info] MigrationLogger: *** 7: add_renameEpisodes_to_naming migrating ***
[Info] MigrationLogger: *** 8: remove_backlog migrating ***
[Info] MigrationLogger: *** 9: fix_rename_episodes migrating ***
[Info] MigrationLogger: *** 10: add_monitored migrating ***
[Info] MigrationLogger: *** 11: remove_ignored migrating ***
[Info] MigrationLogger: *** 12: remove_custom_start_date migrating ***
[Info] MigrationLogger: *** 13: add_air_date_utc migrating ***
[Info] MigrationLogger: *** 14: drop_air_date migrating ***
[Info] MigrationLogger: *** 15: add_air_date_as_string migrating ***
[Info] MigrationLogger: *** 16: updated_imported_history_item migrating ***
[Info] MigrationLogger: *** 17: reset_scene_names migrating ***
[Info] MigrationLogger: *** 18: remove_duplicates migrating ***
[Info] MigrationLogger: *** 19: restore_unique_constraints migrating ***
[Info] MigrationLogger: *** 20: add_year_and_seasons_to_series migrating ***
[Info] MigrationLogger: *** 21: drop_seasons_table migrating ***
[Info] MigrationLogger: *** 22: move_indexer_to_generic_provider migrating ***
[Info] MigrationLogger: *** 23: add_config_contract_to_indexers migrating ***
[Info] MigrationLogger: *** 24: drop_tvdb_episodeid migrating ***
[Info] MigrationLogger: *** 25: move_notification_to_generic_provider migrating ***
[Info] MigrationLogger: *** 26: add_config_contract_to_notifications migrating ***
[Info] MigrationLogger: *** 27: fix_omgwtfnzbs migrating ***
[Info] MigrationLogger: *** 28: add_blacklist_table migrating ***
[Info] MigrationLogger: *** Migrating data source=/root/.config/NzbDrone/logs.db;cache size=-10485760;datetimekind=Utc;journal mode=Wal ***
[Info] MigrationLogger: *** VersionMigration migrating ***
[Info] MigrationLogger: *** VersionUniqueMigration migrating ***
[Info] MigrationLogger: *** 1: InitialSetup migrating ***
[Info] MigrationLogger: *** 2: remove_tvrage_imdb_unique_constraint migrating ***
[Info] MigrationLogger: *** 3: remove_renamed_scene_mapping_columns migrating ***
[Info] MigrationLogger: *** 4: updated_history migrating ***
[Info] MigrationLogger: *** 5: added_eventtype_to_history migrating ***
[Info] MigrationLogger: *** 6: add_index_to_log_time migrating ***
[Info] MigrationLogger: *** 7: add_renameEpisodes_to_naming migrating ***
[Info] MigrationLogger: *** 8: remove_backlog migrating ***
[Info] MigrationLogger: *** 9: fix_rename_episodes migrating ***
[Info] MigrationLogger: *** 10: add_monitored migrating ***
[Info] MigrationLogger: *** 11: remove_ignored migrating ***
[Info] MigrationLogger: *** 12: remove_custom_start_date migrating ***
[Info] MigrationLogger: *** 13: add_air_date_utc migrating ***
[Info] MigrationLogger: *** 14: drop_air_date migrating ***
[Info] MigrationLogger: *** 15: add_air_date_as_string migrating ***
[Info] MigrationLogger: *** 16: updated_imported_history_item migrating ***
[Info] MigrationLogger: *** 17: reset_scene_names migrating ***
[Info] MigrationLogger: *** 18: remove_duplicates migrating ***
[Info] MigrationLogger: *** 19: restore_unique_constraints migrating ***
[Info] MigrationLogger: *** 20: add_year_and_seasons_to_series migrating ***
[Info] MigrationLogger: *** 21: drop_seasons_table migrating ***
[Info] MigrationLogger: *** 22: move_indexer_to_generic_provider migrating ***
[Info] MigrationLogger: *** 23: add_config_contract_to_indexers migrating ***
[Info] MigrationLogger: *** 24: drop_tvdb_episodeid migrating ***
[Info] MigrationLogger: *** 25: move_notification_to_generic_provider migrating ***
[Info] MigrationLogger: *** 26: add_config_contract_to_notifications migrating ***
[Info] MigrationLogger: *** 27: fix_omgwtfnzbs migrating ***
[Info] MigrationLogger: *** 28: add_blacklist_table migrating ***
[Info] Router: Application mode: Interactive
[Info] OwinHostController: starting server on http://*:8989/
[Info] NancyBootstrapper: Starting NzbDrone API
[Info] QualityProfileService: Setting up default quality profiles
[Info] SceneMappingService: Updating Scene mapping
[Info] HousekeepingService: Running housecleaning tasks
[Fatal] WindowsApp: EPIC FAIL: Unable to resolve type: NzbDrone.SysTray.SystemTrayApp
 
TinyIoC.TinyIoCResolutionException: Unable to resolve type: NzbDrone.SysTray.SystemTrayApp ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.WindowsFormsSynchronizationContext ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.ThemeEngine ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.ThemeWin32Classic ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.KnownColors ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.DllNotFoundException: /usr/local/lib/libgdiplus.so
  at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
  at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Drawing.KnownColors..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Drawing.Color.get_Black () [0x00000] in <filename unknown>:0
  at System.Windows.Forms.ThemeWin32Classic..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Windows.Forms.ThemeEngine..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x00000] in <filename unknown>:0
  at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
  at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
at System.Windows.Forms.Control..ctor () <0x0005e>
at System.Windows.Forms.ScrollableControl..ctor () <0x00017>
at System.Windows.Forms.ContainerControl..ctor () <0x0002d>
at System.Windows.Forms.Form..ctor () <0x00065>
at System.Windows.Forms.NotifyIcon/NotifyIconWindow..ctor (System.Windows.Forms.NotifyIcon) <0x0002e>
at (wrapper remoting-invoke-with-check) System.Windows.Forms.NotifyIcon/NotifyIconWindow..ctor (System.Windows.Forms.NotifyIcon) <0x0004f>
at System.Windows.Forms.NotifyIcon..ctor () <0x00049>
at (wrapper remoting-invoke-with-check) System.Windows.Forms.NotifyIcon..ctor () <0x00041>
at NzbDrone.SysTray.SystemTrayApp..ctor (NzbDrone.Common.Processes.IProcessProvider,NzbDrone.Host.Owin.IHostController) <0x00043>
at (wrapper remoting-invoke-with-check) NzbDrone.SysTray.SystemTrayApp..ctor (NzbDrone.Common.Processes.IProcessProvider,NzbDrone.Host.Owin.IHostController) <0x0005e>
at (wrapper dynamic-method) object.lambda_method (System.Runtime.CompilerServices.Closure,object[]) <0x001ab>
at TinyIoC.TinyIoCContainer.ConstructType (System.Type,System.Type,System.Reflection.ConstructorInfo,TinyIoC.NamedParameterOverloads,TinyIoC.ResolveOptions) <0x00530>
 
  --- End of inner exception stack trace ---
  at TinyIoC.TinyIoCContainer.ConstructType (System.Type requestedType, System.Type implementationType, System.Reflection.ConstructorInfo constructor, TinyIoC.NamedParameterOverloads parameters, TinyIoC.ResolveOptions options) [0x00000] in <filename unknown>:0
  at TinyIoC.TinyIoCContainer.ConstructType (System.Type requestedType, System.Type implementationType, System.Reflection.ConstructorInfo constructor, TinyIoC.ResolveOptions options) [0x00000] in <filename unknown>:0
  at TinyIoC.TinyIoCContainer+SingletonFactory.GetObject (System.Type requestedType, TinyIoC.TinyIoCContainer container, TinyIoC.NamedParameterOverloads parameters, TinyIoC.ResolveOptions options) [0x00000] in <filename unknown>:0
  at TinyIoC.TinyIoCContainer.ResolveInternal (TinyIoC.TypeRegistration registration, TinyIoC.NamedParameterOverloads parameters, TinyIoC.ResolveOptions options) [0x00000] in <filename unknown>:0
 
EPIC FAIL: System.NullReferenceException: Object reference not set to an instance of an object
  at System.Windows.Forms.Form.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0
  at System.ComponentModel.Component.Finalize () [0x00000] in <filename unknown>:0
EPIC FAIL: System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.ThemeEngine ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.ThemeWin32Classic ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.KnownColors ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.DllNotFoundException: /usr/local/lib/libgdiplus.so
  at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
  at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Drawing.KnownColors..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Drawing.Color.get_Black () [0x00000] in <filename unknown>:0
  at System.Windows.Forms.ThemeWin32Classic..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Windows.Forms.ThemeEngine..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x00000] in <filename unknown>:0
  at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
  at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000] in <filename unknown>:0
[Fatal] GlobalExceptionHandlers: EPIC FAIL: Object reference not set to an instance of an object
 
System.NullReferenceException: Object reference not set to an instance of an object
  at System.Windows.Forms.Form.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0
  at System.ComponentModel.Component.Finalize () [0x00000] in <filename unknown>:0
 
EPIC FAIL: System.NullReferenceException: Object reference not set to an instance of an object
  at System.Windows.Forms.Form.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0
  at NzbDrone.SysTray.SystemTrayApp.Dispose (Boolean isDisposing) [0x00000] in <filename unknown>:0
  at System.ComponentModel.Component.Finalize () [0x00000] in <filename unknown>:0
[Fatal] GlobalExceptionHandlers: EPIC FAIL: An exception was thrown by the type initializer for System.Windows.Forms.ThemeEngine
 
System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.ThemeEngine ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.ThemeWin32Classic ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.KnownColors ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.DllNotFoundException: /usr/local/lib/libgdiplus.so
  at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
  at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Drawing.KnownColors..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Drawing.Color.get_Black () [0x00000] in <filename unknown>:0
  at System.Windows.Forms.ThemeWin32Classic..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Windows.Forms.ThemeEngine..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x00000] in <filename unknown>:0
  at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
  at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000] in <filename unknown>:0
 
[Fatal] GlobalExceptionHandlers: EPIC FAIL: Object reference not set to an instance of an object
 
System.NullReferenceException: Object reference not set to an instance of an object
  at System.Windows.Forms.Form.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.ThemeEngine ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.ThemeWin32Classic ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.KnownColors ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.DllNotFoundException: /usr/local/lib/libgdiplus.so
  at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
  at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Drawing.KnownColors..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Drawing.Color.get_Black () [0x00000] in <filename unknown>:0
  at System.Windows.Forms.ThemeWin32Classic..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Windows.Forms.ThemeEngine..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x00000] in <filename unknown>:0
  at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
  at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000] in <filename unknown>:0
  at NzbDrone.SysTray.SystemTrayApp.Dispose (Boolean isDisposing) [0x00000] in <filename unknown>:0
  at System.ComponentModel.Component.Finalize () [0x00000] in <filename unknown>:0
 
Stacktrace:
 
  at <unknown> <0xffffffff>
root@NzbDrone:/usr/NzbDrone #
 

toddos

Contributor
Joined
Aug 18, 2012
Messages
178
This here is the root of your problem:


An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.DllNotFoundException: /usr/local/lib/libgdiplus.so

As for how to fix it, I'm not really sure. The FreeBSD port of mono should have libgdiplus, but maybe it's an option during the port installation that you didn't check? If installing mono didn't pull in a bunch of other stuff like X11, GTK, etc, then it probably didn't include libgdiplus.
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
This here is the root of your problem:




As for how to fix it, I'm not really sure. The FreeBSD port of mono should have libgdiplus, but maybe it's an option during the port installation that you didn't check? If installing mono didn't pull in a bunch of other stuff like X11, GTK, etc, then it probably didn't include libgdiplus.

When installing mono it did install the needed dependencies, I will have to check again if it is installing libgdipplus though.
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
I found that running mono NzbDrone.Console.exe worked
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
Now the problem I have is if I run it from console the console windows needs to stay open or the program will close. How would I start NzbDrone without needed to keep the console open?
 

toddos

Contributor
Joined
Aug 18, 2012
Messages
178
If the exe doesn't implement some sort of daemon mode (which I would expect it doesn't, since that's not something Windows apps do), you could run it under screen or tmux and then detach the session (or start the session detached).
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
If the exe doesn't implement some sort of daemon mode (which I would expect it doesn't, since that's not something Windows apps do), you could run it under screen or tmux and then detach the session (or start the session detached).

Thanks, that will work.

Now is there a way I can create a start-up script to automate this process every time the jail starts? Also I need to find a way to update the application easier, because as it stands I need to shutdown NzbDrone and then overwrite the files in order to do an update. I would like to have a script run that will download the files, shutdown the service and then overwrite the files if possible, and then even go one step further maybe and set it up as a cron job.
 

toddos

Contributor
Joined
Aug 18, 2012
Messages
178
Read up on RC scripting, write yourself a script that you can hook into the rc process. For updates, you can write a script that does "service nzbrdone stop", update, "service nzbdrone start", where the assumption is that "nzbdrone" is the name of the service you create with your rc script.
 

tofagerl

Contributor
Joined
Aug 26, 2013
Messages
118
Has anyone made such an RC script? Cause I've been trying for three hours, and my head is spinning.
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
Has anyone made such an RC script? Cause I've been trying for three hours, and my head is spinning.


Its not as cut and dry because of mono. For now I just use Screen and detach the session after I have launched NZBDRONE. My server is always online and rarely re-booted, so its not a big issue to just start the service.
 

tofagerl

Contributor
Joined
Aug 26, 2013
Messages
118
Well, I decided to try. This is my result, and although it now does start, it starts as root, but should start as a configurable user. (In my case "tom")
Can anyone give me a hint as to how I do that? Also, logging would be great. Now it just floods the tty where I run the service command with output, which is less helpful.

Code:
#!/bin/sh
 
# PROVIDE: nzbdrone
# REQUIRE: LOGIN
# KEYWORD: shutdown
 
 
. /etc/rc.subr
 
name="nzbdrone"
rcvar="nzbdrone_enable"
: ${nzbdrone_user:="tom"}
stop_cmd="${name}_stop"
start_cmd="${name}_start"
start_precmd="${name}_prestart"
start_postcmd="${name}_poststart"
stop_postcmd="${name}_poststop"
command="/usr/local/bin/mono"
apps="/opt/NzbDrone/NzbDrone.exe"
pidfile="/var/run/${name}.pid"
 
nzbdrone_prestart()
{
        if [ -f $pidfile ]; then
                echo "nzbdrone is already running."
                exit 0
        fi
}
 
nzbdrone_start()
{
        echo "Starting nzbdrone."
        ${command} ${apps} &
}
 
 
nzbdrone_poststart()
{
        MONOSERVER_PID=$(ps ax | grep "/usr/local/bin/mono /opt/NzbDrone/NzbDrone.exe (mono-sgen)" | grep -v grep | awk '{print $1}')
        if [ -f $pidfile ]; then
                rm $pidfile
        fi
        if [ -n $MONOSERVER_PID ]; then
                echo $MONOSERVER_PID > $pidfile
        fi
}
 
nzbdrone_stop()
{
        if [ -f $pidfile ]; then
                echo "Stopping nzbdrone."
                kill $(cat $pidfile)
                echo "Stopped nzbdrone."
        else
                echo "nzbdrone is not running."
                exit 0
        fi
}
 
nzbdrone_poststop()
{
        rm $pidfile
}
 
 
load_rc_config $name
run_rc_command "$1"
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Well, I decided to try. This is my result, and although it now does start, it starts as root, but should start as a configurable user. (In my case "tom")
Can anyone give me a hint as to how I do that? Also, logging would be great. Now it just floods the tty where I run the service command with output, which is less helpful.

Code:
#!/bin/sh
 
# PROVIDE: nzbdrone
# REQUIRE: LOGIN
# KEYWORD: shutdown
 
 
. /etc/rc.subr
 
name="nzbdrone"
rcvar="nzbdrone_enable"
: ${nzbdrone_user:="tom"}
stop_cmd="${name}_stop"
start_cmd="${name}_start"
start_precmd="${name}_prestart"
start_postcmd="${name}_poststart"
stop_postcmd="${name}_poststop"
command="/usr/local/bin/mono"
apps="/opt/NzbDrone/NzbDrone.exe"
pidfile="/var/run/${name}.pid"
 
nzbdrone_prestart()
{
        if [ -f $pidfile ]; then
                echo "nzbdrone is already running."
                exit 0
        fi
}
 
nzbdrone_start()
{
        echo "Starting nzbdrone."
        ${command} ${apps} &
}
 
 
nzbdrone_poststart()
{
        MONOSERVER_PID=$(ps ax | grep "/usr/local/bin/mono /opt/NzbDrone/NzbDrone.exe (mono-sgen)" | grep -v grep | awk '{print $1}')
        if [ -f $pidfile ]; then
                rm $pidfile
        fi
        if [ -n $MONOSERVER_PID ]; then
                echo $MONOSERVER_PID > $pidfile
        fi
}
 
nzbdrone_stop()
{
        if [ -f $pidfile ]; then
                echo "Stopping nzbdrone."
                kill $(cat $pidfile)
                echo "Stopped nzbdrone."
        else
                echo "nzbdrone is not running."
                exit 0
        fi
}
 
nzbdrone_poststop()
{
        rm $pidfile
}
 
 
load_rc_config $name
run_rc_command "$1"
everything you need to know is in the freebsd handbook rc scripting section. I spent a long time in there and ended up with an init that was less lines with more error checking (because the init system has all the built in functions you should need).
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
everything you need to know is in the freebsd handbook rc scripting section. I spent a long time in there and ended up with an init that was less lines with more error checking (because the init system has all the built in functions you should need).

Maybe an example of script that you have would help out.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Maybe an example of script that you have would help out.
check my repo on github user=josh4trunks

my subsonic init file redirects output to a log file.
 

tofagerl

Contributor
Joined
Aug 26, 2013
Messages
118
I've been using the freebsd handbook, but I can't find anything about running a daemon as a specified user there. I do see other scripts using the :${${name}_user} variable from rc.conf, but I tried setting it, and it's not taking effect.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Meh, I just added /usr/local/bin/sudo -u tom to the command.
the user setting works for me. maybe it's not working because you wrote a custom start function instead of just specifying the command. check my examples
 

tofagerl

Contributor
Joined
Aug 26, 2013
Messages
118
Well, I have to use a custom start function, since it's a mono application.
 

Joshua Parker Ruehlig

Hall of Famer
Joined
Dec 5, 2011
Messages
5,949
Well, I have to use a custom start function, since it's a mono application.
disagreed, if you look at my subsonic init it's basically the same thing (except it uses java).
 

tofagerl

Contributor
Joined
Aug 26, 2013
Messages
118
This?
I have no idea how to read it, it's clearly meant to be parsed and filled in before use. I don't know how to interpret %%JAVA_CMD%% for instance.
 
Status
Not open for further replies.
Top