Skip to content

Commit

Permalink
- fix merge conclict
Browse files Browse the repository at this point in the history
  • Loading branch information
lrupp committed Jan 17, 2019
2 parents b891b60 + 8c0a31a commit 090f764
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 17 deletions.
61 changes: 61 additions & 0 deletions suse-online-update.man8
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.\" Contact [email protected]
.TH "suse-online-update" "8" "2019-01-17" "Lars Vogdt" "suse-online-update"
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.ss \n[.ss] 0
.nh
.ad l
.de URL
\\$2 \(laURL: \\$1 \(ra\\$3
..
.if \n[.g] .mso www.tmac
.LINKSTYLE blue R
.SH "NAME"
suse-online-update \- SUSE online update script
.SH "SYNOPSIS"
.sp
\fBsuse-online-update\fP [\fIoptions\fP]
.SH DESCRIPTION
This is a simple wrapper script around zypper or other system-management
software for installing updates automatically which doesn't require any
interaction.
.SH OPTIONS
You can find the options for this script in /etc/sysconfig/suse-online-update
.RE
.SS "Command line options:"
.sp
\fB\-e\fP\ your@mail
.RS 4
send error messages to this Email address (default: root@localhost)
.RE
.sp
\fB\-f\fP /path/to/file
.RS 4
use <sysconfig> as configuration file (default: /etc/sysconfig/suse-online-update)
.RE
.sp
\fB\-l\fP /path/to/file
.RS 4
use <logfile> as log file (default: /var/log/systemupdate.log)
.RE
.sp
\fB\-c\fP
.RS 4
run cleanup (default: yes)
.RE
.sp
\fB\-p\fP
.RS 4
run the permission scripts (like 'chkstat') after update (default: yes)
.RE
.SH BUGS
No known bugs so far, please report any issue here:
.sp
.URL "https://github.com/lrupp/suse-online-update/issues" "" ""
.SH "HOMEPAGE"
.sp
.URL "https://github.com/lrupp/suse-online-update" "" ""
.SH AUTHOR
Lars Vogdt <[email protected]>
.SH SEE ALSO
zypper(8), mail(1)
7 changes: 7 additions & 0 deletions suse-online-update.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Unit]
Description=Install non-interactive updates
ConditionACPower=true

[Service]
Type=oneshot
ExecStart=/usr/sbin/suse-online-update
10 changes: 10 additions & 0 deletions suse-online-update.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Daily non-interactive online update

[Timer]
OnCalendar=daily
AccuracySec=24h
Persistent=true

[Install]
WantedBy=timers.target
62 changes: 45 additions & 17 deletions suse.de-online-update
Original file line number Diff line number Diff line change
Expand Up @@ -75,34 +75,62 @@ trap cleanup_and_exit 0 1 2 3 7 13 15
function LOG(){
local MESSAGE="$1"
local LOG_DATE=$(date "+%b %d %H:%M:%S")
if [ -z "$LOGFILE" ]; then
echo "ERROR: LOGFILE is not defined" | $MAILX -s "[$LOGNAME] error on $FQHOSTNAME" $EMAIL
cleanup_and_exit 1
fi
if [ ! -d "$LOGDIR" ]; then
mkdir -p "$LOGDIR" || exit 1
touch "$LOGFILE" || { echo "Could not create $LOGFILE"; exit 1; }
echo "$LOG_DATE $HOST $LOGNAME[$$]: function LOG created $LOGDIR" > "$LOGFILE"
fi
if [ -w "$LOGFILE" ]; then
echo "$LOG_DATE $HOST $LOGNAME[$$]: $MESSAGE" >> $LOGFILE
else
echo "Could not write to $LOGFILE - please fix" >&2
cleanup_and_exit 1
fi
echo "$LOG_DATE $HOST $LOGNAME[$$]: $MESSAGE" >> $LOGFILE
if [ "$DEBUG" = "yes" ]; then
echo "DEBUG: $MESSAGE"
fi
}

function usage(){
echo "Usage: $0 [OPTION]"
echo
echo " -e <email> : send error messages to this Email address (default: $EMAIL)"
echo " -f <sysconfig> : use <sysconfig> as configuration file (default: $DISTCONFIG)"
echo " -l <logfile> : use <logfile> as log file (default: $LOGFILE)"
echo " -c : run cleanup (default: $RUN_CLEANUP)"
echo " -p : run the permission scripts (like 'chkstat') after update (default: $FIX_PERMISSIONS)"
echo " -h : print this help"
echo
}

while getopts 'e:f:l:cph' OPT; do
case "$OPT" in
e) EMAIL="$OPTARG"
;;
f) DISTCONFIG="$OPTARG"
;;
l) LOGFILE="$OPTARG"
;;
c) RUN_CLEANUP='yes'
;;
p) FIX_PERMISSIONS='yes'
;;
h) usage; exit 0;
;;
esac
done
shift $(( OPTIND - 1 ))

# source our config
if [ -f "$DISTCONFIG" ]; then
. "$DISTCONFIG"
else
echo "$DISTCONFIG not found - using defaults" >&2
LOG "$DISTCONFIG not found - using defaults"
if [ -w "$LOGFILE" ]; then LOG "$DISTCONFIG not found - using defaults"; fi
fi
if [ -z "$LOGFILE" ]; then
echo "ERROR: LOGFILE is not defined" | $MAILX -s "[$LOGNAME] error on $FQHOSTNAME" $EMAIL
cleanup_and_exit 1
fi
if [ ! -d "$LOGDIR" ]; then
mkdir -p "$LOGDIR" || exit 1
touch "$LOGFILE" || { echo "Could not create $LOGFILE"; cleanup_and_exit 1; }
echo "$LOG_DATE $HOST $LOGNAME[$$]: function LOG created $LOGDIR" > "$LOGFILE"
fi
if [ ! -w "$LOGFILE" ]; then
echo "Could not write to $LOGFILE - please fix" >&2
cleanup_and_exit 1
fi

if [ -n "$CLEANUP_USER" ]; then
CLEAN_USR=''
else
Expand Down

0 comments on commit 090f764

Please sign in to comment.