I have configured Ubuntu Server 14.04.1 LTS with a git client named gitblit: http://gitblit.com/
To start the gitblit client i need to start the terminal and type the next command: java -jar gitblit.jar every time i start up the ubuntu server.
Is there a way to autostart this line "java -jar gitblit.jar" with a script or something. I know there was chkconfig but its not supported by ubuntu server 14.
I have tried several codes like: https://askubuntu.com/questions/99232/how-to-make-a-jar-file-run-on-startup-and-when-you-log-out
@Magnus Back: When i run this line: "bash -x /etc/init.d/gitblit start" in the terminal it says te following:
start-stop-daemon: user 'admin' not found
+ exit 0
The script looks like:
#!/bin/bash
### BEGIN INIT INFO
# Provides: gitblit
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Gitblit repository server
# Description: Gitblit is a stand-alone service for managing, viewing and serving Git repositories.
### END INIT INFO
. /lib/init/vars.sh
. /lib/lsb/init-functions
PATH=/sbin:/bin:/usr/bin:/usr/sbin
# change theses values (default values)
GITBLIT_PATH=/var/www/gitblit
GITBLIT_BASE_FOLDER=/var/www/gitblit/data
GITBLIT_USER="admin"
source ${GITBLIT_PATH}/java-proxy-config.sh
ARGS="-server -Xmx1024M ${JAVA_PROXY_CONFIG} -Djava.awt.headless=true -jar gitblit.jar --baseFolder $GITBLIT_BASE_FOLDER --dailyLogFile"
RETVAL=0
case "$1" in
start)
if [ -f $GITBLIT_PATH/gitblit.jar ];
then
echo $"Starting gitblit server"
start-stop-daemon --start --quiet --background --oknodo --make-pidfile --pidfile /var/run/gitblit.pid --exec /usr/bin/java --chuid $GITBLIT_USER --chdir $GITBLIT_PATH -- $ARGS
exit $RETVAL
fi
;;
stop)
if [ -f $GITBLIT_PATH/gitblit.jar ];
then
echo $"Stopping gitblit server"
start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/gitblit.pid
exit $RETVAL
fi
;;
force-reload|restart)
$0 stop
sleep 5
$0 start
;;
*)
echo $"Usage: /etc/init.d/gitblit {start|stop|restart|force-reload}"
exit 1
;;
esac
exit $RETVAL
So i think to add a new user but how or which. Also i fond another script for starting Gitblit
But when you download gitblit, in the zip there are files like: instal-service.sh with the following lines
cp gitblit /etc/init.d/
chmod +x /etc/init.d/gitblit
sudo update-rc.d gitblit defaults
Also i have found another script maybe you could help me to makes this script to work
set -e
GITBLIT_PATH=/opt/gitblit
GITBLIT_HTTP_PORT=0
GITBLIT_HTTPS_PORT=8443
JAVA="java -server -Xmx1024M -jar"
. /lib/lsb/init-functions
case "$1" in
start)
log_action_begin_msg "Starting gitblit server"
cd $GITBLIT_PATH
$JAVA $GITBLIT_PATH/gitblit.jar --httpsPort $GITBLIT_HTTPS_PORT --httpPort $GITBLIT_HTTP_PORT > /dev/null &
log_action_end_msg $?
;;
stop)
log_action_begin_msg "Stopping gitblit server"
cd $GITBLIT_PATH
$JAVA $GITBLIT_PATH/gitblit.jar --stop > /dev/null &
log_action_end_msg $?
;;
force-reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: /etc/init.d/gitblit {start|stop|restart|force-reload}"
exit 1
;;
esac
exit 0
I have solved the autostart up for gitblit by following this tutorial:
http://kchard.github.io/gitblit-quickstart/
In this tutorial you will create a gitblit user named gitblit. I used instead the root user, and everytings works find.