cron or bash

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

cron or bash

mavrothal
Administrator
I was thinking that since PPM has an automatic service-pack check (/usrlocal/petget/service_pack.sh) we may call it periodically without user input. Once a week I guess.
I'm wondering if it is better to run crond or just a boot up script and if a boot up script should it run as daemon?
A cron job would make sense but somehow puppy never uses cron
So I made this script instead

#!/bin/sh

check_upgrade() {
 /usr/local/petget/service_pack.sh
 if [ $? -eq 0 -o $? -eq 2 -o $? -eq 3 -o $? -eq 4 -o $? -eq 5 ]; then
  echo YEAR=$(date +"%Y") > /var/local/upgrade_check # 4 digit year
  echo PREVDAY=$(date +"%j") >> /var/local/upgrade_check # day of the year
 fi
}

last_check() {
 if [ -f /var/local/upgrade_check ]; then
  if [ "$YEAR" -lt "$(date +"%Y")" ]; then
   check_upgrade
  else
   DAY=$(expr $PREVDAY + 7)
   [ "$DAY" -lt "$(date +"%j")" ] && check_upgrade
  fi 
 else
  check_upgrade
 fi
}

while $1
do
 [ -f /var/local/upgrade_check ] && . /var/local/upgrade_check
 if [ "$PREVDAY" -eq "$(date +"%j")" ]; then
  sleep 3600
 else 
  last_check &
  sleep 3600
 fi
done

exit 0

Ideas/suggestions?
Cron or script?
If script run as daemon or only once at boot time (not sure how many puppy users really leave their computer on for days...)
Reply | Threaded
Open this post in threaded view
|

Re: cron or bash

scsijon
On 10/29/2014 05:18 AM, mavrothal [via woof-CE] wrote:

>
>
> I was thinking that since PPM has an automatic service-pack check
> (/usrlocal/petget/service_pack.sh) we may call it periodically without user
> input. Once a week I guess.
> I'm wondering if it is better to run crond or just a boot up script and if a
> boot up script should it run as daemon?
> A cron job would make sense but somehow puppy never uses cron
> So I made this script instead
>
>
personally I don't like updates that run automatically, they always seem
to do so just when you have something important to do and need the
bandwidth.

on the otherhand, if the automatic update just opened a window with a
yes / no to go ahead first (if no it pops up and asks again the next
time you start it up)

and maybe having it's own menu item, and, a pickbox that allows
automatic at user set intervals would be better than having to open PPM
to do an update.

>
> Ideas/suggestions?
> Cron or script?
> If script run as daemon or only once at boot time (not sure how many puppy
> users really leave their computer on for days...)
>
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://woof-ce.26403.n7.nabble.com/cron-or-bash-tp710.html
> To start a new topic under woof-CE, email [hidden email]
> To unsubscribe from woof-CE, visit
Reply | Threaded
Open this post in threaded view
|

Re: cron or bash

mavrothal
Administrator
In reply to this post by mavrothal
Mostly for record keeping...
Assuming the above script (or something like it) goes to /etc/init.d/updates_check, the following patch could go to quicksetup so user can activate automatic check for updates.

--- a/woof-code/rootfs-skeleton/usr/sbin/quicksetup	2014-10-26 21:27:33.033366272 +0200
+++ b/woof-code/rootfs-skeleton/usr/sbin/quicksetup	2014-10-30 08:17:42.049978160 +0200
@@ -228,6 +228,10 @@
    HEADING="`gettext 'NTP'`"
    echo "$(gettext "This will synchronise the local time and date to an NTP server on the Internet. You do not need to do this, as computers normally have their date and time set by a battery-backed hardware clock. However, some tiny computers, such as some ARM boards (for example the Raspberry Pi) do not have a hardware clock, so you either have to set the time/date manually at every bootup, or enable NTP. Note, if you enable NTP now, you can change the settings any time in the future -- see the 'Psync' entry in the 'Desktop' menu.")" > /tmp/box_help
    ;;
+  updates)
+   HEADING="`gettext 'Udate Check'`"
+   echo "$(gettext "This wil allow your computer to automatcally check once a week for major software updates with ibiblio.org/puppylinux. These updates come in the form of a service pack and usually constitute a minor version upgrade, i.e. 'puppy-5.9.6' will become 'puppy-5.9.7'. It is recomended to allow automatic check for updates.")" > /tmp/box_help
+   ;; 
   firewall)
    HEADING="`gettext 'Firewall'`"
    echo "$(gettext "It is always recommended that the firewall be enabled when connected to a network, unless it is a local trusted network. Note that you can run the Firewall Wizard any time in the future if you want to change the settings -- see the 'Setup' menu.")" > /tmp/box_help
@@ -294,6 +298,25 @@
     DEFAULT_FIREWALL='false'
     [ "`lsmod | grep '^iptable'`" != "" ] && DEFAULT_FIREWALL='true'
 
+    # Automatic update check checkbox
+    if [ "$(find /etc/init.d/updates_check -perm -u+rwx)" != "" ]; then
+     DEFAULT_UPDATE_CHECK='true'
+    else
+     DEFAULT_UPDATE_CHECK='false'
+    fi
+    UPDATE_XML='
+    <hbox tooltip-text="'$(gettext "Check for software updates automatically")'">
+       <checkbox xalign="0" space-expand="true" space-fill="true">
+         <label>'$(gettext "Check for updates")'</label>
+         <variable>CHECK_UPDATE</variable>
+         <default>'${DEFAULT_UPDATE_CHECK}'</default>
+       </checkbox>
+        <button>
+          '"`/usr/lib/gtkdialog/xml_button-icon info mini`"'
+          <action>help updates</action>
+        </button>
+       </hbox>'
+
     #120625 get time/date off internet...
     CHKBOXNTP=""
     if [ "`cat /root/.packages/woof-installed-packages /root/.packages/user-installed-packages | grep '^[Pp]sync'`" != "" ];then
@@ -349,6 +372,7 @@
             </button>
           </hbox>
           '${CHKBOXNTP}'
+          '${UPDATE_XML}'
         </vbox>
         <text space-expand="true" space-fill="true"><label>""</label></text>
         '"`/usr/lib/gtkdialog/xml_pixmap network_connect.svg icon`"'
@@ -1721,7 +1745,17 @@
    fi
   fi
  fi
-
+ 
+ if [ "$CHECK_UPDATE" != "$DEFAULT_UPDATE_CHECK" ];then
+  if [ "$CHECK_UPDATE" = "true" ];then 
+   chmod 755 /etc/init.d/updates_check
+   FLAG_CHANGED="${FLAG_CHANGED}$(gettext 'Automatic updates check enabled'):yes|"
+  else
+   chmod 644 /etc/init.d/updates_check
+   FLAG_CHANGED="${FLAG_CHANGED}$(gettext 'Automatic updates check disabled'):yes|"
+  fi
+ fi
+ 
  #120625...
  if [ "$CHECK_NTP" != "$DEFAULT_NTP" ];then
   if [ "$CHECK_NTP" = "false" ];then
Reply | Threaded
Open this post in threaded view
|

Re: cron or bash

scsijon
the idea sounds good to me, I still like the idea of a go/stop popup though

on the earlier email, my internet workstaion is shutdown at least daily,
my testing workstations are up and down as needbe, but my development
workstations only when I need too, and data / file storage servers only
when they (or the mains) die. Comes from having a old SuSE / Novell
background.

I would think most people would only start them up when they want to use
them though.

On 10/30/2014 07:45 PM, mavrothal [via woof-CE] wrote:

>
>
> Mostly for record keeping...
> Assuming the above script (or something like it) goes to
> /etc/init.d/updates_check, the following patch could go to quicksetup so
> user can activate automatic check for updates.
>
>
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://woof-ce.26403.n7.nabble.com/cron-or-bash-tp710p712.html
> To start a new topic under woof-CE, email [hidden email]
> To unsubscribe from woof-CE, visit
Reply | Threaded
Open this post in threaded view
|

Re: cron or bash

mavrothal
Administrator
This post was updated on .
scsijon wrote
the idea sounds good to me, I still like the idea of a go/stop popup though
After the mess in the forum I do not think I'll be pursuing this any further.

Just an update to the original check script to include quickpet.
Though quickpet does not have any sound versioning infra so is a bit messy...

#!/bin/sh

check_upgrade() {
 . /etc/DISTRO_SPECS
 /usr/local/petget/service_pack.sh
 if [ $? -eq 0 -o $? -eq 2 -o $? -eq 3 -o $? -eq 4 -o $? -eq 5 ]; then
  echo $(($(date +%s)/86400)) > /var/local/upgrade_check
 fi
 if [ "$DISTRO_NAME" = "tahrpup" ]; then
  # get last update we have. format will be 'dd/mm/yyyy'. 
  # Damn... 'date' does not understand this format
  LAST_LOCAL=$(head -n 1 /usr/local/quickpet_precise/bugfixes.txt | cut -f 1 -d ' ' \
   | awk '{split($1,a,"/");$1=a[3]"/"a[2]"/"a[1]}1'|sed 's/\//\-/g')
  # find latest update in remote. format will be 'yyyy-mmm-dd'. 
  # 'date' does not understand this either '$#@%...'
  LAST_REMOTE=$(curl -s http://distro.ibiblio.org/puppylinux/puppy-tahr/quickpet/ \
   --list-only |grep tahrfix | sort -r | head -n 1 | cut -f 7 -d '>' | cut -f 1 -d ' ' \
  | sed "s/Jan/01/;s/Feb/02/;s/Mar/03/;s/Apr/04/;s/May/05/;s/Jun/06/;\
  s/Jul/07/;s/Aug/08/;s/Sep/09/;s/Oct/10/;s/Nov/11/;s/Dec/12/")
  # Update quickpet and prompt to udate bug fixes
  # This can be a problem as the date of upload may be different than the  
  # latest one in bugfixes.txt. 
  DAY_DIFF=$(($(($(date -d $LAST_REMOTE +%s)/86400)) - $(($(date -d $LAST_LOCAL +%s)/86400))))
  if [ "$DAY_DIFF" -ge 1 ]; then
   /usr/local/quickpet_precise/update &
   sleep 5
   xmessage -center -bg orange -fg teal " There are new 
 turpup bug fixes.
 Please update"
  else
   exit 0
  fi
 fi
}

last_check() {
 if [ -f /var/local/upgrade_check ]; then
   DAY=$(expr $(cat /var/local/upgrade_check) + 7)
   [ "$DAY" -lt "$(($(date +%s)/86400))" ] && check_upgrade
 else
  check_upgrade
 fi
}

while $1
do
 [ -f /var/local/upgrade_check ]
 if [ "$(cat /var/local/upgrade_check)" -eq "$(($(date +%s)/86400))" ]; then
  sleep 3600
 else 
  last_check &
  sleep 3600
 fi
done

exit 0