diff --git a/install-iccr.bash b/install-iccr.bash index 34520bc..4f834d9 100755 --- a/install-iccr.bash +++ b/install-iccr.bash @@ -163,6 +163,10 @@ if [ "${hasJava}" = "0" -o "${hasRightJava}" = "0" ]; then echo if [ "${doesApt}" = "1" ]; then if [ "${doWhat}" = "install" ]; then + echo Setting cronjobs + sudo systemctl enable cron + sudo service cron start + crontab -r echo "sudo apt-get -y update" sudo apt-get -y update echo @@ -296,7 +300,6 @@ if [ "${mac}" = "1" ]; then else sed -i "s/^${iccrApiKeyProp}=.*$/${iccrApiKeyProp}=${pwd}/g" $iccrPropFile fi - echo echo Done echo diff --git a/installer/iccr-scripts/src/main/scripts/iccr-ctl b/installer/iccr-scripts/src/main/scripts/iccr-ctl index 33a8ec0..8cd6c16 100755 --- a/installer/iccr-scripts/src/main/scripts/iccr-ctl +++ b/installer/iccr-scripts/src/main/scripts/iccr-ctl @@ -26,6 +26,8 @@ cd $ICCR_DIR loglevel= nossl= preferIPv4Flag= +cronICCR="@reboot $ICCR_BIN_DIR/iccr-ctl $@ 2>&1" +cronIOTA="@reboot $ICCR_BIN_DIR/startiota.bash" for arg in "$@"; do if [ "${arg}" = "debug" ]; then loglevel=debug @@ -39,7 +41,6 @@ for arg in "$@"; do if [ "${arg}" = "ipv4" ]; then preferIPv4Flag="-Djava.net.preferIPv4Stack=true" fi - done stop() { @@ -70,6 +71,27 @@ stop() { } start() { + iccrOnBoot=`grep startICCROnBoot ${ICCR_DIR}/conf/iccr.properties | sed -e 's/startICCROnBoot=//g'` + iotaOnBoot=`grep startIotaOnBoot ${ICCR_DIR}/conf/iccr.properties | sed -e 's/startIotaOnBoot=//g'` + + if [ "$iotaOnBoot" = true ] ; then + echo "Creating cron job for start iota" + if crontab -l | grep -q "$cronIOTA"; then + echo "crontab already exists... Ignoring" + else + crontab -l | { cat; echo "$cronIOTA"; } | crontab - + fi + fi + + if [ "$iccrOnBoot" = true ] ; then + echo "Creating cron job iccr" + if crontab -l | grep -q "$cronICCR"; then + echo "crontab already exists... Ignoring" + else + crontab -l | { cat; echo "$cronICCR"; } | crontab - + fi + fi + echo Starting $WHAT_APP # Are we already running? if [ -f $ICCR_PID_FILE ]; then diff --git a/installer/iccr-scripts/src/main/scripts/startiota.bash b/installer/iccr-scripts/src/main/scripts/startiota.bash index 3bcd430..b304698 100755 --- a/installer/iccr-scripts/src/main/scripts/startiota.bash +++ b/installer/iccr-scripts/src/main/scripts/startiota.bash @@ -12,8 +12,6 @@ iotaPidFile=$iotaDir/iota.pid cd $iotaDir -startCmd="nohup ${iotaStartCmd} ${iotaPortNumber} > console.log 2>&1 &" -echo "${startCmd}" nohup ${iotaStartCmd} ${iotaPortNumber} > console.log 2>&1 & statusCode=$? diff --git a/installer/property-files/src/main/resources/iccr.properties b/installer/property-files/src/main/resources/iccr.properties index 817cbb2..598436c 100644 --- a/installer/property-files/src/main/resources/iccr.properties +++ b/installer/property-files/src/main/resources/iccr.properties @@ -46,6 +46,12 @@ iotaDir=/opt/iota iotaStartCmd=java -jar IRI.jar --dns-resolution-false -p iotaPortNumber=14265 +#onboot + +startICCROnBoot=true + +startIotaOnBoot=true + # Time in minutes: iotaNeighborRefreshTime=10 iotaActivityGranularity=1 diff --git a/rest/src/main/java/org/iotacontrolcenter/rest/resource/IccrServiceImpl.java b/rest/src/main/java/org/iotacontrolcenter/rest/resource/IccrServiceImpl.java index 8863401..fc356c6 100644 --- a/rest/src/main/java/org/iotacontrolcenter/rest/resource/IccrServiceImpl.java +++ b/rest/src/main/java/org/iotacontrolcenter/rest/resource/IccrServiceImpl.java @@ -279,6 +279,8 @@ public Response getIotaNbrsConfig(HttpServletRequest request) { @Override public Response getIotaNeighbors(HttpServletRequest request, IccrPropertyListDto actionProps) { + delegate.startNeighborRefresh(); + delegate.startActivityRefresh(); return doIotaAction(request, ActionFactory.NEIGHBORS, actionProps); }