Apache init.d script - service

I have the following script to start, stop, restart apache2 in my debian 7
#!/bin/sh
### BEGIN INIT INFO
# Provides: apache2
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: apache2
# Description: Start apache2
### END INIT INFO
case "$1" in
start)
echo "Starting Apache ..."
# Change the location to your specific location
/usr/local/apache2/bin/apachectl start
;;
stop)
echo "Stopping Apache ..."
# Change the location to your specific location
/usr/local/apache2/bin/apachectl stop
;;
graceful)
echo "Restarting Apache gracefully..."
# Change the location to your specific location
/usr/local/apache2/bin/apachectl graceful
;;
restart)
echo "Restarting Apache ..."
# Change the location to your specific location
/usr/local/apache2/bin/apachectl restart
;;
*)
echo "Usage: '$0' {start|stop|restart|graceful}"
exit 64
;;
esac
exit 0
When I add the script to update-rc.d I see the following warnings:
root#pomelo:/etc/init.d# update-rc.d apache2 defaults
update-rc.d: using dependency based boot sequencing
insserv: Script jexec is broken: incomplete LSB comment.
insserv: missing `Required-Stop:' entry: please add even if empty.
insserv: missing `Default-Stop:' entry: please add even if empty.
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `jexec'
But I already added Required-Stop and Default-Stop to the script.
Does anybody know how to solve this problem?

The issue is not in your apache2 init script, it is in 'jexec' it says so 'Script jexec is broken'.
That one is missing the Required-Stop and Default-Stop
Had the same issue on my SLES boxen. Don't worry though, even if it shows you these errors, everything still just runs fine!
HTH

Related

Run mini-httpd serveron linux

i just installed mini-httpd on linux mint.
but can'n connect to localhost / 127.0.0.1 on browser
server is working
● mini-httpd.service - LSB: mini-httpd start script
Loaded: loaded (/etc/init.d/mini-httpd; generated)
Active: active (exited) since Sat 2022-02-05 14:33:10 EET; 6min ago
Docs: man:systemd-sysv-generator(8)
Process: 6236 ExecStart=/etc/init.d/mini-httpd start (code=exited, status=0/SUCCESS)
and this is the config file
# Example config for mini_httpd.
# Author: Marvin Stark <marv#der-marv.de>
# Author-Update: 2015 Jose dos Santos Junior <j.s.junior#live.com>
# Description Update: Changed the default document root (data_dir)/var/www/html
# Last-Update: 2015-09-05
# Uncomment this line for turning on ssl support.
#ssl
# On which host mini_httpd should bind?
host=localhost
# On which port mini_httpd should listen?
port=80
# Which user mini_httpd should use?
user=nobody
# Run in chroot mode?
#chroot # yes
nochroot # no
# Working directory of mini_httpd.
#dir=<work_dir>
# We are the web files stored?
# Please change this to your needs.
data_dir=/var/www/html
# CGI path
cgipat=cgi-bin/*
# Which certificate to use?
#certfile=<certfile>
# Which logfile to use?
logfile=/var/log/mini_httpd.log
# Which pidfile to use?
pidfile=/var/run/mini_httpd.pid
# Which charset to use?
charset=iso-8859-1
Use
apk add curl
curl http://localhost
to test the web server.
see this Wiki
Make following changes in config file
# On which host mini_httpd should bind?
# host=localhost
# Which user mini_httpd should use?
# user=nobody
# Run in chroot mode?
chroot # yes
# nochroot # no
In etc/default/mini-httpd make
START=1

ActiveMQ Artemis stopping automatically. localhost is not loading

I have installed ActiveMQ Artemis on my office laptop. I created a broker, and from the broker's bin folder I ran artemis-exe install.
Then after that I ran the start command. It shows it has started but, when I check status it shows stopped. I cannot access localhost:8161. Here is my log file:
2020-09-07 12:30:45,458 DEBUG - Starting WinSW in the CLI mode
2020-09-07 12:30:46,033 INFO - Starting the service with id 'artemis-btBroker-0.0.0.0'
2020-09-07 12:30:46,737 DEBUG - Starting WinSW in the service mode
2020-09-07 12:30:46,837 DEBUG - Completed. Exit code is 0
2020-09-07 12:30:46,881 INFO - Starting %JAVA_HOME%\bin\java.exe -Xbootclasspath/a:C:\Users\613379463\Downloads\apache-artemis-2.15.0-bin\apache-artemis-2.15.0\lib\jboss-logmanager-2.1.10.Final.jar;C:\Users\613379463\Downloads\apache-artemis-2.15.0-bin\apache-artemis-2.15.0\lib\wildfly-common-1.5.2.Final.jar -XX:+UseParallelGC -Xms512M -Xmx1024M -classpath C:\Users\613379463\Downloads\apache-artemis-2.15.0-bin\apache-artemis-2.15.0\lib\artemis-boot.jar -Dartemis.home=C:\Users\613379463\Downloads\apache-artemis-2.15.0-bin\apache-artemis-2.15.0 -Dartemis.instance=C:\Users\613379463\Downloads\apache-artemis-2.15.0-bin\apache-artemis-2.15.0\bin\btBroker -Ddata.dir=C:\Users\613379463\Downloads\apache-artemis-2.15.0-bin\apache-artemis-2.15.0\bin\btBroker\data -Dartemis.instance.etc=C:\Users\613379463\Downloads\apache-artemis-2.15.0-bin\apache-artemis-2.15.0\bin\btBroker\etc -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dlogging.configuration=file:/C:/Users/613379463/Downloads/apache-artemis-2.15.0-bin/apache-artemis-2.15.0/bin/btBroker/etc//logging.properties -Djava.security.auth.login.config=C:\Users\613379463\Downloads\apache-artemis-2.15.0-bin\apache-artemis-2.15.0\bin\btBroker\etc\login.config -Dhawtio.realm=activemq -Dhawtio.offline="true" -Dhawtio.role=amq -Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal -Djolokia.policyLocation=file:/C:/Users/613379463/Downloads/apache-artemis-2.15.0-bin/apache-artemis-2.15.0/bin/btBroker/etc//jolokia-access.xml org.apache.activemq.artemis.boot.Artemis run
2020-09-07 12:30:47,081 DEBUG - Completed. Exit code is 0
The Artemis ActiveMQ service is known to start and immediately stop (without any errors shown on command line) if %JAVA_HOME% is not set, as Apurv Adarsh's comment mentions.
The solution is to set the env var and then run the service as normal, as follows:
(1) Set JAVA_HOME
Verify %JAVA_HOME% system environment variable exists:
echo $Env:JAVA_HOME # from PowerShell
echo %JAVA_HOME% # from cmd
# e.g. 'C:\Program Files\Java\jdk-10.0.2\'
# or blank if not set.
if not, find java.exe (download/install, if necessary):
> where.exe java.exe # from PowerShell
> where java.exe # from cmd
# C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe
# C:\Program Files\Java\jdk-10.0.2\bin\java.exe
Set JAVA_HOME env var, I'll choose the jdk-10.0.2 version. /M will set as system variable, instead of user var. btw, no need to include '/bin/java.exe'
> setx /M JAVA_HOME "C:\Program Files\Java\"
SUCCESS: Specified value was saved.
(Restart the prompt to load the newly set env variable.)
(2) Install & Start Artemis Windows Service
cd into Artemis ActiveMQ root directory. Let my_broker be the name of the broker instance already created.
Ensure service is installed, then start:
> "my_broker/bin/artemis-service" install
...
> "my_broker/bin/artemis-service" start
2021-01-01 12:00:00,000 INFO - Starting the service with id 'artemis-my_broker-0.0.0.0'
(3) Check Running Status:
Verify service status is running:
> "my_broker/bin/artemis-service" status
Started

Why does "Can not locate Debconf / Log.pm in #INC" issue? I just modified /usr/bin/perl into the perl that I installed

The system is Ubuntu. There is a perl in /usr/bin/, and is version is 5.18.2.
In this state, I tried to install many software by "sudo apt-get install **" and it was OK.
But a few days before, I installed a new perl in an other
directory(/share/Software/perl-5.26.0/bin/perl). And I remove the original perl then link the new perl to /use/bin/. The commands are:
sudo mv /usr/bin/perl /usr/bin/old/; (the old/ directory was make before)
sudo ln -s /share/Software/perl-5.26.0/bin/perl /usr/bin/perl
After that, I got the error informations when I install system software by apt-get. The error likes below:
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
debconf: Perl may be unconfigured (Can't locate Debconf/Log.pm in #INC (you may need to install the Debconf::Log module) (#INC contains: /share/Software/perl-5.26.0/lib/site_perl/5.26.0/x86_64-linux /share/Software/perl-5.26.0/lib/site_perl/5.26.0 /share/Software/perl-5.26.0/lib/5.26.0/x86_64-linux /share/Software/perl-5.26.0/lib/5.26.0) at (eval 1) line 4.
BEGIN failed--compilation aborted at (eval 1) line 4.
) -- aborting
Setting up doc-base (0.10.5) ...
Can't locate Debian/DocBase/Common.pm in #INC (you may need to install the Debian::DocBase::Common module) (#INC contains: /share/Software/perl-5.26.0/lib/site_perl/5.26.0/x86_64-linux /share/Software/perl-5.26.0/lib/site_perl/5.26.0 /share/Software/perl-5.26.0/lib/5.26.0/x86_64-linux /share/Software/perl-5.26.0/lib/5.26.0) at /usr/sbin/install-docs line 8.
BEGIN failed--compilation aborted at /usr/sbin/install-docs line 8.
Some software can be installed successfully, but some can not be.
If I put perl back to the previous, it is normal again. (That must be!)
Module "Debconf::Log" is located at /share/Software/perl-5.26.0/lib/perl5, but I can not find Debian/DocBase/Common.pm.
Path of /share/Software/perl-5.26.0/lib/perl5 is inside #INC of perl. Why it can not find it?
I even think that it is the problem when perl installed. I get below error when perl installed: ("make test")
Useless use of single ref constructor in void context at op/gv.t line 1191.
In file included from ../../../../perl.h:5644:0,
from ExtTest.xs:2:
ExtTest.c: In function ‘XS_ExtTest_constant’:
../../../../embed.h:691:40: warning: ‘pv’ may be used uninitialized in this function [-Wmaybe-uninitialized]
#define sv_setpvn(a,b,c) Perl_sv_setpvn(aTHX_ a,b,c)
^
ExtTest.xs:420:14: note: ‘pv’ was declared here
const char *pv;
^
In file included from ../../../../perl.h:5644:0,
from ExtTest.xs:2:
../../../../embed.h:691:40: warning: ‘iv’ may be used uninitialized in this function [-Wmaybe-uninitialized]
#define sv_setpvn(a,b,c) Perl_sv_setpvn(aTHX_ a,b,c)
^
ExtTest.xs:418:6: note: ‘iv’ was declared here
IV iv;
^
In file included from ../../../../perl.h:5644:0,
from ExtTest.xs:2:
ExtTest.c: In function ‘XS_ExtTest_constant’:
../../../../embed.h:691:40: warning: ‘pv’ may be used uninitialized in this function [-Wmaybe-uninitialized]
#define sv_setpvn(a,b,c) Perl_sv_setpvn(aTHX_ a,b,c)
^
ExtTest.xs:194:14: note: ‘pv’ was declared here
const char *pv;
^
In file included from ../../../../perl.h:5644:0,
from ExtTest.xs:2:
ExtTest.c: In function ‘XS_ExtTest_constant’:
../../../../embed.h:675:42: warning: ‘iv’ may be used uninitialized in this function [-Wmaybe-uninitialized]
#define sv_setiv_mg(a,b) Perl_sv_setiv_mg(aTHX_ a,b)
^
ExtTest.xs:166:6: note: ‘iv’ was declared here
IV iv;
^
# Failed test 'cp updated mtime'
# at t/cp.t line 26.
# '38'
# <=
# '1'
# Looks like you failed 1 test of 1.
Request to remove file /share/Software/perl-5.26.0-src/cpan/File-Temp/suffixOEXZVr.dat could not be completed since it is not there!
at t/mktemp.t line 75.
# parser guessed wrong encoding expected 'CP1252' got 'UTF-8'
# Failed test 'File 1 atime set correctly'
# at t/utime.t line 113.
# '37.684463262558'
# <
# '0.1'
# Failed test 'File 1 mtime set correctly'
# at t/utime.t line 114.
# '37.684463262558'
# <
# '0.1'
# Failed test 'File 2 atime set correctly'
# at t/utime.t line 118.
# '37.684463262558'
# <
# '0.1'
# Failed test 'File 2 mtime set correctly'
# at t/utime.t line 119.
# '37.684463262558'
# <
# '0.1'
# Looks like you failed 4 tests of 18.
Can't open copy1-87150: Permission denied at ../lib/File/Copy.t line 326.
# Looks like your test exited with 13 just after 366.
Failed 3 tests out of 2449, 99.88% okay.
### Since not all tests were successful, you may want to run some of
### them individually and examine any diagnostic messages they produce.
### See the INSTALL document's section on "make test".
### You have a good chance to get more information by running
### ./perl harness
### in the 't' directory since most (>=80%) of the tests succeeded.
### You may have to set your dynamic library search path,
### LD_LIBRARY_PATH, to point to the build directory:
### setenv LD_LIBRARY_PATH `pwd`:$LD_LIBRARY_PATH; cd t; ./perl harness
### LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd t; ./perl harness
### export LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH; cd t; ./perl harness
### for csh-style shells, like tcsh; or for traditional/modern
### Bourne-style shells, like bash, ksh, and zsh, respectively.
make: *** [test] Error 1
Each Perl is compiled with a few #INC directories where it will search for modules. The error message explains which directories are searched:
#INC contains:
/share/Software/perl-5.26.0/lib/site_perl/5.26.0/x86_64-linux
/share/Software/perl-5.26.0/lib/site_perl/5.26.0
/share/Software/perl-5.26.0/lib/5.26.0/x86_64-linux
/share/Software/perl-5.26.0/lib/5.26.0
This does not include the directories where APT has installed modules for Perl, e.g. under /usr/lib.
However, adding those directories will not help. Some modules are compiled for a specific Perl versions. You cannot upgrade Perl in-place, but would have to reinstall all modules. Since APT contains pre-built modules you cannot use modules installed via APT with a custom Perl.
Therefore: leave the system Perl because Ubuntu depends on its proper functioning. It is safe to install another Perl alongside, e.g. via perlbrew. It is safe to add a custom Perl to your PATH, e.g. via perlbrew switch. This will also fix a couple of additional environment variables that are required for a second Perl to work.

Creating linked_dirs in Capistrano 3 fails

I am attempting to set up Capistrano with a SilverStripe build and am running into a few troubles setting up the shared directories.
I set the linked_dirs in deploy.rb with the following:
set :linked_dirs, %w{assets vendor}
Since adding this line I get the following error:
[617afa7f] Command: /usr/bin/env mkdir -p /var/www/website/releases/20160215083713 /var/www/website/releases/20160215083713
INFO [617afa7f] Finished in 0.250 seconds with exit status 0 (successful).
DEBUG [88c3de20] Running /usr/bin/env [ -L /var/www/website/releases/20160215083713/assets ] as capistrano#128.199.231.152
DEBUG [88c3de20] Command: [ -L /var/www/website/releases/20160215083713/assets ]
DEBUG [88c3de20] Finished in 0.258 seconds with exit status 1 (failed).
DEBUG [3d61c1c4] Running /usr/bin/env [ -d /var/www/website/releases/20160215083713/assets ] as capistrano#128.199.231.152
DEBUG [3d61c1c4] Command: [ -d /var/www/website/releases/20160215083713/assets ]
DEBUG [3d61c1c4] Finished in 0.254 seconds with exit status 1 (failed).
INFO [3016a8cd] Running /usr/bin/env ln -s /var/www/website/shared/assets /var/www/website/releases/20160215083713/assets as capistrano#128.199.231.152
I am a mega noob when it comes to Capistrano and a semi noob when it comes to server configuration and permissions, so any pointers would be appreciated.
It probably hasn't actually failed. One thing to know about Capistrano is that (success) and (failed) are actually returning the result of the exit status, (success) if 0 and (failed) if non-0.
If we look at the command in question, it says that /usr/bin/env [ -L /var/www/website/releases/20160215083713/assets ] failed. This command is saying "return 0 if /var/www/website/releases/20160215083713/assets exists and is a link (-L). This fails, but that just means it returns non-0, thus the link needs to be created. Note that the next command also fails (-d) with asserting that the path is a directory. And the last line in your output is actually creating the link in question.
You can see the test in the Capistrano codebase here: https://github.com/capistrano/capistrano/blob/master/lib/capistrano/tasks/deploy.rake#L128
You can clean up and simplify the output with https://github.com/mattbrictson/airbrussh. This is developed by one of the primary Capistrano devs.
As a sidenote, similarly all the green text in your terminal is stdout and the red text is stderr. This can also be confusing.

Selenium headless does not run on CentOS 7 with Perl, "no display specified"

I try to run headless Selenium on CentOS7:
# cat /etc/os-release
NAME="Red Hat Enterprise Linux Server"
VERSION="7.2 (Maipo)"
I installed Xvfb and run it as
# /usr/bin/Xvfb :99
I installed firefox:
# firefox -v
Mozilla Firefox 38.5.0
and run it to check if it can be run at all:
# export DISPLAY=:99
# firefox
This is the output:
# firefox
Xlib: extension "RANDR" missing on display ":99".
console.error:
[CustomizableUI]
Custom widget with id loop-button does not return a valid node
console.error:
[CustomizableUI]
Custom widget with id loop-button does not return a valid node
GLib-GIO-Message: Using the 'memory' GSettings backend. Your settings will not be saved or shared with other applications.
Firefox seems to be running after that command:
# ps aux | grep firefox
root 29476 7.3 14.9 852356 152256 pts/3 Sl+ 10:30 0:03 /usr/lib64/firefox/firefox
EDIT
Yes, it's running. Taking screenshot from the Xvfb by
DISPLAY=:99 import -window root -crop 1264x948+0+0 /tmp/screenshot.jpg
I can see
Now the problematic part.
I installed Selenium Remote Driver for perl
# cpanm Selenium::Remote::Driver
Then I ran standalone selenium driver:
# java -jar selenium-server-standalone-2.49.0.jar
Now I run test script:
#!/usr/bin/perl
use strict;
use warnings;
use Selenium::Remote::Driver;
my $driver = Selenium::Remote::Driver->new(browser_name=>'firefox');
$driver->get('http://www.google.com');
print $driver->get_title();
$driver->quit();
After 45 second I get error from the driver:
Could not create new session: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Error: no display specified
at (eval 89) line 510.
Seems like firefox launched by the driver does not see DISPLAY environment variable. I try to add it from the script:
#!/usr/bin/perl
use strict;
use warnings;
use Selenium::Remote::Driver;
$ENV{DISPLAY}=":99";
my $driver = Selenium::Remote::Driver->new(browser_name=>'firefox');
$driver->get('http://www.google.com');
print $driver->get_title();
$driver->quit();
It does not help, the previous error remains.
What do I do?
EDIT2
I tried the current setup with Python. All works.
# pip install selenium
And used the following test script:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.python.org")
f = open('ptn-sel.txt', 'w')
f.write(driver.title)
driver.close()
f.close()
I understand it's problem of Perl driver.... Any suggestions?
Is python using the standalone server or running firefox itself?
If perl is using the server and the server is spawning firefox then you need $DISPLAY set in the server processes environment not the script's environment. (By running export DISPLAY=:99; java -jar selenium-server-standalone-2.49.0.jaror similar.)
If you don't want to use the standalone server at all then Selenium::Firefox looks like it might be interesting.