From 2ffc81b26ccc2086b489f3c65551e86df11e25f8 Mon Sep 17 00:00:00 2001 From: ahab94 Date: Tue, 1 May 2018 11:42:43 +0500 Subject: [PATCH 1/8] init crontab logic --- installer/iccr-scripts/src/main/scripts/iccr-ctl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/installer/iccr-scripts/src/main/scripts/iccr-ctl b/installer/iccr-scripts/src/main/scripts/iccr-ctl index 33a8ec0..1bf270f 100755 --- a/installer/iccr-scripts/src/main/scripts/iccr-ctl +++ b/installer/iccr-scripts/src/main/scripts/iccr-ctl @@ -26,6 +26,9 @@ cd $ICCR_DIR loglevel= nossl= preferIPv4Flag= +src_path="$( cd "$(dirname "$0")" ; pwd -P )" +cron="$src_path/bin/iccr-ctl $@" + for arg in "$@"; do if [ "${arg}" = "debug" ]; then loglevel=debug @@ -39,6 +42,10 @@ for arg in "$@"; do if [ "${arg}" = "ipv4" ]; then preferIPv4Flag="-Djava.net.preferIPv4Stack=true" fi + if [ "${arg}" = "boot" ]; then + echo "Creating cron job" + crontab -l > "@reboot $cron" + fi done From 105696fa8f054734853b01bc17f3f83fe436d2bc Mon Sep 17 00:00:00 2001 From: ahab94 Date: Tue, 1 May 2018 12:02:33 +0500 Subject: [PATCH 2/8] add crontab for iccr ctl --- installer/iccr-scripts/src/main/scripts/iccr-ctl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/installer/iccr-scripts/src/main/scripts/iccr-ctl b/installer/iccr-scripts/src/main/scripts/iccr-ctl index 1bf270f..ae2a6d6 100755 --- a/installer/iccr-scripts/src/main/scripts/iccr-ctl +++ b/installer/iccr-scripts/src/main/scripts/iccr-ctl @@ -27,7 +27,7 @@ loglevel= nossl= preferIPv4Flag= src_path="$( cd "$(dirname "$0")" ; pwd -P )" -cron="$src_path/bin/iccr-ctl $@" +cron="@reboot $src_path/bin/iccr-ctl $@ 2>&1" for arg in "$@"; do if [ "${arg}" = "debug" ]; then @@ -44,7 +44,11 @@ for arg in "$@"; do fi if [ "${arg}" = "boot" ]; then echo "Creating cron job" - crontab -l > "@reboot $cron" + if crontab -l | grep -q "$cron"; then + echo "crontab already exists... Ignoring" + else + crontab -l | { cat; echo "$cron"; } | crontab - + fi fi done From 6f10c6f4c3a8a923d931f1c0be6e1e175bb29039 Mon Sep 17 00:00:00 2001 From: ahab94 Date: Tue, 1 May 2018 12:50:55 +0500 Subject: [PATCH 3/8] add crontab for iota process execution --- installer/iccr-scripts/src/main/scripts/startiota.bash | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/installer/iccr-scripts/src/main/scripts/startiota.bash b/installer/iccr-scripts/src/main/scripts/startiota.bash index 3bcd430..edb19ba 100755 --- a/installer/iccr-scripts/src/main/scripts/startiota.bash +++ b/installer/iccr-scripts/src/main/scripts/startiota.bash @@ -11,9 +11,17 @@ iotaPortNumber=`grep iotaPortNumber $iccrDir/conf/iccr.properties | sed -e 's/io iotaPidFile=$iotaDir/iota.pid cd $iotaDir - startCmd="nohup ${iotaStartCmd} ${iotaPortNumber} > console.log 2>&1 &" + +echo "Creating cron job" +if crontab -l | grep -q "$startCmd"; then + echo "crontab already exists... Ignoring" +else + crontab -l | { cat; echo "@reboot $startCmd"; } | crontab - +fi + echo "${startCmd}" + nohup ${iotaStartCmd} ${iotaPortNumber} > console.log 2>&1 & statusCode=$? From a9ce007fb67ce851a0c27ba5c991d85c1daf8924 Mon Sep 17 00:00:00 2001 From: ahab94 Date: Tue, 1 May 2018 13:08:52 +0500 Subject: [PATCH 4/8] add variable support for cron jobs --- .../iccr-scripts/src/main/scripts/iccr-ctl | 18 +++++++++--------- .../src/main/scripts/startiota.bash | 13 ++++++++----- .../src/main/resources/iccr.properties | 6 ++++++ 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/installer/iccr-scripts/src/main/scripts/iccr-ctl b/installer/iccr-scripts/src/main/scripts/iccr-ctl index ae2a6d6..76bd5e4 100755 --- a/installer/iccr-scripts/src/main/scripts/iccr-ctl +++ b/installer/iccr-scripts/src/main/scripts/iccr-ctl @@ -42,15 +42,6 @@ for arg in "$@"; do if [ "${arg}" = "ipv4" ]; then preferIPv4Flag="-Djava.net.preferIPv4Stack=true" fi - if [ "${arg}" = "boot" ]; then - echo "Creating cron job" - if crontab -l | grep -q "$cron"; then - echo "crontab already exists... Ignoring" - else - crontab -l | { cat; echo "$cron"; } | crontab - - fi - fi - done stop() { @@ -81,6 +72,15 @@ stop() { } start() { + iccrOnBoot=`grep startICCROnBoot ${ICCR_DIR}/conf/iccr.properties | sed -e 's/startICCROnBoot=//g'` + if [ "$iccrOnBoot" = true ] ; then + echo "Creating cron job" + if crontab -l | grep -q "$cron"; then + echo "crontab already exists... Ignoring" + else + crontab -l | { cat; echo "$cron"; } | 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 edb19ba..8b0e587 100755 --- a/installer/iccr-scripts/src/main/scripts/startiota.bash +++ b/installer/iccr-scripts/src/main/scripts/startiota.bash @@ -9,15 +9,18 @@ iotaDir=`grep iotaDir $iccrDir/conf/iccr.properties | sed -e 's/iotaDir=//g'` iotaStartCmd=`grep iotaStartCmd $iccrDir/conf/iccr.properties | sed -e 's/iotaStartCmd=//g'` iotaPortNumber=`grep iotaPortNumber $iccrDir/conf/iccr.properties | sed -e 's/iotaPortNumber=//g'` iotaPidFile=$iotaDir/iota.pid +iotaOnBoot=`grep startIotaOnBoot $iccrDir/conf/iccr.properties | sed -e 's/startIotaOnBoot=//g'` cd $iotaDir startCmd="nohup ${iotaStartCmd} ${iotaPortNumber} > console.log 2>&1 &" -echo "Creating cron job" -if crontab -l | grep -q "$startCmd"; then - echo "crontab already exists... Ignoring" -else - crontab -l | { cat; echo "@reboot $startCmd"; } | crontab - +if [ "$iotaOnBoot" = true ] ; then + echo "Creating cron job" + if crontab -l | grep -q "$startCmd"; then + echo "crontab already exists... Ignoring" + else + crontab -l | { cat; echo "@reboot $startCmd"; } | crontab - + fi fi echo "${startCmd}" 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 From b119572de21b16e39089c14b8dd4365adbf3295d Mon Sep 17 00:00:00 2001 From: ahab94 Date: Wed, 2 May 2018 17:09:22 +0500 Subject: [PATCH 5/8] fix cronjobs issues --- install-iccr.bash | 4 +++- installer/iccr-scripts/src/main/scripts/iccr-ctl | 3 +-- installer/iccr-scripts/src/main/scripts/startiota.bash | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/install-iccr.bash b/install-iccr.bash index 34520bc..1c7ecf9 100755 --- a/install-iccr.bash +++ b/install-iccr.bash @@ -163,6 +163,9 @@ 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 echo "sudo apt-get -y update" sudo apt-get -y update echo @@ -296,7 +299,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 76bd5e4..70ffe50 100755 --- a/installer/iccr-scripts/src/main/scripts/iccr-ctl +++ b/installer/iccr-scripts/src/main/scripts/iccr-ctl @@ -26,8 +26,7 @@ cd $ICCR_DIR loglevel= nossl= preferIPv4Flag= -src_path="$( cd "$(dirname "$0")" ; pwd -P )" -cron="@reboot $src_path/bin/iccr-ctl $@ 2>&1" +cron="@reboot $ICCR_BIN_DIR/iccr-ctl $@ 2>&1" for arg in "$@"; do if [ "${arg}" = "debug" ]; then diff --git a/installer/iccr-scripts/src/main/scripts/startiota.bash b/installer/iccr-scripts/src/main/scripts/startiota.bash index 8b0e587..8e4a2e0 100755 --- a/installer/iccr-scripts/src/main/scripts/startiota.bash +++ b/installer/iccr-scripts/src/main/scripts/startiota.bash @@ -12,18 +12,18 @@ iotaPidFile=$iotaDir/iota.pid iotaOnBoot=`grep startIotaOnBoot $iccrDir/conf/iccr.properties | sed -e 's/startIotaOnBoot=//g'` cd $iotaDir -startCmd="nohup ${iotaStartCmd} ${iotaPortNumber} > console.log 2>&1 &" + if [ "$iotaOnBoot" = true ] ; then + cronJob=" nohup (cd $iotaDir && ${iotaStartCmd} ${iotaPortNumber} > console.log 2>&1 )" echo "Creating cron job" - if crontab -l | grep -q "$startCmd"; then + if crontab -l | grep -q "$cronJob"; then echo "crontab already exists... Ignoring" else - crontab -l | { cat; echo "@reboot $startCmd"; } | crontab - + crontab -l | { cat; echo "@reboot $cronJob"; } | crontab - fi fi -echo "${startCmd}" nohup ${iotaStartCmd} ${iotaPortNumber} > console.log 2>&1 & From 92f2642d175d82211528d021ad719066af4d1ee4 Mon Sep 17 00:00:00 2001 From: ahab94 Date: Wed, 2 May 2018 22:13:46 +0500 Subject: [PATCH 6/8] fix crontabs issues --- install-iccr.bash | 1 + installer/iccr-scripts/src/main/scripts/startiota.bash | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/install-iccr.bash b/install-iccr.bash index 1c7ecf9..4f834d9 100755 --- a/install-iccr.bash +++ b/install-iccr.bash @@ -166,6 +166,7 @@ if [ "${hasJava}" = "0" -o "${hasRightJava}" = "0" ]; 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 diff --git a/installer/iccr-scripts/src/main/scripts/startiota.bash b/installer/iccr-scripts/src/main/scripts/startiota.bash index 8e4a2e0..3eb7000 100755 --- a/installer/iccr-scripts/src/main/scripts/startiota.bash +++ b/installer/iccr-scripts/src/main/scripts/startiota.bash @@ -15,7 +15,7 @@ cd $iotaDir if [ "$iotaOnBoot" = true ] ; then - cronJob=" nohup (cd $iotaDir && ${iotaStartCmd} ${iotaPortNumber} > console.log 2>&1 )" + cronJob="cd $iotaDir && nohup ${iotaStartCmd} ${iotaPortNumber} > console.log 2>&1" echo "Creating cron job" if crontab -l | grep -q "$cronJob"; then echo "crontab already exists... Ignoring" From 8981866ae99b2e34930c2aacf866670f7560e025 Mon Sep 17 00:00:00 2001 From: ahab94 Date: Sun, 6 May 2018 22:53:27 +0500 Subject: [PATCH 7/8] enhance script crons --- .../iccr-scripts/src/main/scripts/iccr-ctl | 22 ++++++++++++++----- .../src/main/scripts/startiota.bash | 13 ----------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/installer/iccr-scripts/src/main/scripts/iccr-ctl b/installer/iccr-scripts/src/main/scripts/iccr-ctl index 70ffe50..8cd6c16 100755 --- a/installer/iccr-scripts/src/main/scripts/iccr-ctl +++ b/installer/iccr-scripts/src/main/scripts/iccr-ctl @@ -26,8 +26,8 @@ cd $ICCR_DIR loglevel= nossl= preferIPv4Flag= -cron="@reboot $ICCR_BIN_DIR/iccr-ctl $@ 2>&1" - +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 @@ -72,14 +72,26 @@ 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" - if crontab -l | grep -q "$cron"; then + echo "Creating cron job iccr" + if crontab -l | grep -q "$cronICCR"; then echo "crontab already exists... Ignoring" else - crontab -l | { cat; echo "$cron"; } | crontab - + 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 3eb7000..b304698 100755 --- a/installer/iccr-scripts/src/main/scripts/startiota.bash +++ b/installer/iccr-scripts/src/main/scripts/startiota.bash @@ -9,22 +9,9 @@ iotaDir=`grep iotaDir $iccrDir/conf/iccr.properties | sed -e 's/iotaDir=//g'` iotaStartCmd=`grep iotaStartCmd $iccrDir/conf/iccr.properties | sed -e 's/iotaStartCmd=//g'` iotaPortNumber=`grep iotaPortNumber $iccrDir/conf/iccr.properties | sed -e 's/iotaPortNumber=//g'` iotaPidFile=$iotaDir/iota.pid -iotaOnBoot=`grep startIotaOnBoot $iccrDir/conf/iccr.properties | sed -e 's/startIotaOnBoot=//g'` cd $iotaDir - -if [ "$iotaOnBoot" = true ] ; then - cronJob="cd $iotaDir && nohup ${iotaStartCmd} ${iotaPortNumber} > console.log 2>&1" - echo "Creating cron job" - if crontab -l | grep -q "$cronJob"; then - echo "crontab already exists... Ignoring" - else - crontab -l | { cat; echo "@reboot $cronJob"; } | crontab - - fi -fi - - nohup ${iotaStartCmd} ${iotaPortNumber} > console.log 2>&1 & statusCode=$? From d20e7420d282dfea2313ce7b3ab4061bc2121efb Mon Sep 17 00:00:00 2001 From: ahab94 Date: Thu, 10 May 2018 23:12:35 +0500 Subject: [PATCH 8/8] add refresh on get call --- .../org/iotacontrolcenter/rest/resource/IccrServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) 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); }