apache2 – Create init.d Apache service for multiple instances on debian

I am trying to install a second instance of apache on debian. I used the multiple instance script. during the installation it says:

root@nextcloudpi:/usr/share/doc/apache2/examples# sudo sh setup-instance suitecrm2
Setting up /etc/apache2-suitecrm2 ...
systemd is in use, no init script installed
use the 'apache2@suitecrm2.service' service to control your new instance
sample commands:
systemctl start apache2@suitecrm2.service
systemctl enable apache2@suitecrm2.service
Setting up symlinks: a2enmod-suitecrm2 a2dismod-suitecrm2 a2ensite-suitecrm2 a2dissite-suitecrm2 a2enconf-suitecrm2 a2disconf-suitecrm2 apache2ctl-suitecrm2
Setting up /etc/logrotate.d/apache2-suitecrm2 and /var/log/apache2-suitecrm2 ...
Setting up /etc/default/apache-htcacheclean-suitecrm2
root@nextcloudpi:/usr/share/doc/apache2/examples# sudo systemctl edit apache2.service

So systemd is in use and i don’t get a service file in init.d When i try to start the service as mentioned in the code it says there is no apache2-suitecrm2.service.

How do i create a correct init.d file to start the service, or how do i stop systemd from working so it is not in use and the script to create a second instance is allowed to place the script.

I have looked in the documentation and found that there is a script secondary-init-script, also to be found in /use/share/doc/Apache2/examples. But I don’t understand how this works ( see https://alioth-lists-archive.debian.net/pipermail/pkg-apache-commits/2010-February/000296.html

Thanks

ubuntu 16.04 – Show output init-d script on shell

I’m trying to finish a very basic script to start|stop|restart unbound 1.13.0 using unbound-control (no advanced commands or chroot involved) instead of unbound -c <config-file>

It’s running very well, unbound is starting/stopping/restarting when script is executed:

#!/bin/sh

BIN="/usr/local/sbin"

case "$1" in
    start)
        start-stop-daemon -S -x $BIN/unbound-anchor -v
        start-stop-daemon -S -x $BIN/unbound-control start
        ;;

    stop)
        start-stop-daemon -S -x $BIN/unbound-control stop
        ;;

    restart)
        stop && sleep 3 && start
        ;;

    *)
        echo "Usage: service unbound {start|stop|restart|status}" >&2
        exit 1
        ;;
esac

exit 0

# END

But I’m not getting to output the start-stop-daemon logs to shell

I would like to see the output of unbound-anchor when script calls it, for example, to check if unbound-anchor process created/skipped root.key file, something like this when unbound-anchor -v is run from shell

root@dns# unbound-anchor -v
/usr/local/etc/unbound/root.key has content
success: the anchor is ok
root@:~#

Even with -v option in start-stop-daemon -S -x $BIN/unbound-anchor -v the script run correctly but nothing appears on shell (neither success, neither failure)

The only way to see if service was started successfully is running service unbound status

root@dns:~# service unbound status
● unbound.service
   Loaded: loaded (/etc/init.d/unbound; bad; vendor preset: enabled)
  Drop-In: /run/systemd/generator/unbound.service.d
           └─50-insserv.conf-$named.conf
   Active: active (running) since Sun 2021-01-03 19:11:30 -04; 18min ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/unbound.service
           └─13782 unbound -c /usr/local/etc/unbound/unbound.conf

Jan 03 19:11:30 dns systemd(1): Starting unbound.service...
Jan 03 19:11:30 dns systemd(1): Started unbound.service.
Jan 03 19:11:30 dns unbound(13782): (13782:0) notice: init module 0: validator
Jan 03 19:11:30 dns unbound(13782): (13782:0) notice: init module 1: iterator
Jan 03 19:11:30 dns unbound(13782): (13782:0) info: start of service (unbound 1.13.0).

Any help to improve the very basic script? The Linux is Ubuntu 16.04.7 LTS

shell – Can’t install apk using sh script and init.d app

I’m trying to install apk when the device is booting.
I wrote shell script to install apk:

#!/system/bin/sh
pm install /data/local/tmp/WP8_pro_SSUI_Settings_hebrew2.apk

Unfortunately, when I enters the shell (using ‘adb shell’) and runs the script(using ‘sh my_script.sh’)
I get error:

Exception occurred while executing:
java.lang.IllegalArgumentException: Error: Can't open file: /data/local/tmp/MagiskManager-v7.1.1.apk
        at com.android.server.pm.PackageManagerShellCommand.setParamsSize(PackageManagerShellCommand.java:461)
        at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:1060)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:169)
        at android.os.ShellCommand.exec(ShellCommand.java:111)
        at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:22472)
        at android.os.Binder.shellCommand(Binder.java:881)
        at android.os.Binder.onTransact(Binder.java:765)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4924)
        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4118)
        at android.os.Binder.execTransactInternal(Binder.java:1021)
        at android.os.Binder.execTransact(Binder.java:994)

I already tried to put the apk in /data/local/tmp but it’s not working.
Also init.d app failed to run the script

6.0 marshmallow – Init.d scripts not executed

I use an old Samsumg J120W running Android 6.0.1 that seems not to come with init.d. I want to run Link2SD and therefore have installed init.d using Ruyinferno’s Universal Init.d Support. This claims init.d is working as intended:

enter image description here

Nonetheless, init.d scripts are not getting executed. For instance, Universal Init.d Support has a very simple init.d test script:

root@j1xltecan:/ # cat /system/etc/init.d/00test                               
#!/system/bin/sh
# Init.d test

if ( -e /data/Test.log ); then
rm /data/Test.log
fi

echo  Ryuinferno @ XDA 2012 > /data/Test.log
echo  Init.d is working !!! >> /data/Test.log
echo "excecuted on $(date +"%d-%m-%Y %r" )" >> /data/Test.log

This is clearly not getting run since the log file does not exist at all after rebooting:

root@j1xltecan:/ # cat /data/Test.log 
/system/bin/sh: cat: /data/Test.log: No such file or directory

Does anyone know how to get init.d scripts actually to run on startup? Alternatively, if it is possible to run Link2SD without an init.d script, for instance by modifying some /etc/fstab Android equivalent to mount the second SD partition, that would make me very happy as well.

If this is relevant, I am using Magisk on top of an Android OS that was not modified in any other way.

boot – Run a script automatically without “init.d” and no good ‘xbin’ scripts

My android didn’t have ‘init.d’ but I managed to create it. I think the phone still doesn’t run the script associated with it (/system/etc/init.sec.boot.sh) because it uses strace and I don’t have it in my /bin or /xbin folders.

It also has very limited files in /system/xbin and I’m not sure if any of them run on boot.
Anyway I know this question is pretty popular but none of the topics already creted could help me so far.

bash: Tomcat does not close properly with init.d script when shutting down system; restart prevented

I want to start Apache Tomcat 7 on my Redhat-7 (RHEL7) server automatically on system startup.
To do that, I did the following steps:

  • create the following init.d script and make it executable (works fine)
  • put init.d tomcat script link in rc files

The problem: Tomcat cannot start because the corresponding ports, especially the AJP port, are already in use (only after rebooting the system; a simple use of the init.d script does not cause the problem).
My guess: Either it doesn't shutdown properly or it starts twice and causes the problem that way.

If I reboot the system, Tomcat tries to start. I'm trying to access my website, but only a blank page appears. This is the catalina.out where it starts to fail (example of failure with port 8005, but I have the same problem with 8009 and 8080):

20-Apr-2020 20:24:00.813 INFO (localhost-startStop-1) org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/apache-tomcat-8.0.32/webapps/ROOT has finished in 79 ms
20-Apr-2020 20:24:00.821 INFO (main) org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ("http-nio-127.0.0.1-8080")
20-Apr-2020 20:24:00.831 INFO (main) org.apache.catalina.startup.Catalina.start Server startup in 58427 ms
20-Apr-2020 20:24:00.831 SEVERE (main) org.apache.catalina.core.StandardServer.await StandardServer.await: create(localhost:8005): 
 java.net.BindException: Address already in use
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
    at java.net.ServerSocket.bind(ServerSocket.java:375)
    at java.net.ServerSocket.(ServerSocket.java:237)
    at org.apache.catalina.core.StandardServer.await(StandardServer.java:420)
    at org.apache.catalina.startup.Catalina.await(Catalina.java:717)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:663)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)

20-Apr-2020 20:24:00.832 INFO (main) org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ("http-nio-127.0.0.1-8080")
20-Apr-2020 20:24:00.832 INFO (main) org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ("ajp-nio-8009")
20-Apr-2020 20:24:00.832 INFO (main) org.apache.catalina.core.StandardService.stopInternal Stopping service Catalina
2020-04-20 20:24:00,856 (localhost-startStop-1) DEBUG o.x.shutdown                   - Stopping XWiki... 

After doing a & # 39; pgrep java & # 39; I have to kill the process manually. Then I can start the tomcat without problems.

Of course, I can manually kill the process using pkill -9 java and start it later. Since this process must be automated, I can't just kill it all the time.

I tried automatic startup on my Debian 9 server with Tomcat 8, everything works fine there.

Do you have an idea of ​​how I can solve or at least avoid the error?

Appendix

My server.xml file:


  
  
  
  
  
  
  
  

  
  
    
    
  

  

    
    


    

    

    
    
    
    
    

    
       



    

    
    
      

      
      

      
      
        
        
      

      
      (...)
      
    
  


Logout error (extract):

20-Apr-2020 20:22:26.607 SEVERE (localhost-startStop-2) org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application (xwiki) created a ThreadLocal with key of type (com.xpn.xwiki.store.migration.AbstractDataMigrationManager.ThreadLock) (value (com.xpn.xwiki.store.migration.AbstractDataMigrationManager$ThreadLock@7f9e8cb9)) and a value of type (java.lang.Integer) (value (0)) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
20-Apr-2020 20:22:26.607 SEVERE (localhost-startStop-2) org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application (xwiki) created a ThreadLocal with key of type (org.apache.solr.logging.MDCLoggingContext$1) (value (org.apache.solr.logging.MDCLoggingContext$1@21089b81)) and a value of type (java.lang.Integer) (value (0)) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
20-Apr-2020 20:22:26.623 INFO (Thread-15) org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ("http-nio-127.0.0.1-8080")
20-Apr-2020 20:22:26.714 INFO (Thread-15) org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ("ajp-nio-8009")
20-Apr-2020 20:22:26.767 INFO (Thread-15) org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ("http-nio-127.0.0.1-8080")
20-Apr-2020 20:22:26.768 INFO (Thread-15) org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ("ajp-nio-8009")
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0

boot – pulseaudio uses a dummy font when creating a python script from init.d RPI4

I am using pulse audio to create a Bluetooth A2DP receiver, which works fine until I try to start a python program from startup.

I put this program in the init.d directory:

#! /bin/sh
# /etc/init.d/startFlask
### BEGIN INIT INFO
# Provides:          main.py
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

case "$1" in
  start]
    echo "Starting flask"
    # run application you want to start
    sudo python3 /home/pi/flask/main.py &
    ;;
  stop]
    echo "Stopping flask"
    # kill application you want to stop
    killall python
    ;;
  *]
    echo "Usage: /etc/init.d/startFlask{start|stop}"
    exit 1
    ;;
esac

exit 0

which successfully launches my flask server but breaks PulseAudio.

when running pact list sinks short, I get auto_null

and when you run pactl list sources short, I get auto_null.moitor

Could it be that running my python script prevents pulseaudio from initializing, if so how can I fix this?

init: is it possible to add a new level of execution in initd or systemd?

Can I add a new level of execution to initd / systemd?

Can I customize initd / systemd to reconcile a new level of execution like this:

and change the initd to know this cmd

init 7
then run my "myrunlvl"

init.d – Where should the startup scripts be placed in Amazon Linux 2?

In the release notes of Amazon Linux 2, Amazon reports that initscripts should no longer exist in /etc/init.d

Amazon Linux 2 uses the systemd init system to boot user space and manage system processes. It is available as / sbin / init and replaces the system-style init system V that was available in the previous generation of Amazon Linux. As a result, initscripts should no longer exist in /etc/init.d. systemctl {start | stop | restart} SERVICE_NAME.service should be used instead. In addition, the service SERVICE_NAME {start | stop | restart} is compatible with Amazon Linux AMI and Amazon Linux 2.

Previously, we relied on a startup script to administer Supervisor on Amazon Linux 1. If a startup script is required and systemctl is not appropriate, where should this script be placed to be compatible with the new systemd219 init system?