## Path: System/Yast2/Snapper
-## Type: yesno
-## Default: no
-# Enable snapper.
-ENABLE_SNAPPER="no"
-
## Type: string
-## Default: "/"
+## Default: ""
# Directories for which snapper ...
-SNAPPER_SUBVOLUMES="/"
+SNAPPER_CONFIGS=""
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH
+
#
# get information from /etc/sysconfig
#
. /etc/sysconfig/snapper
fi
+
#
-# run special program for every subvolume
+# run snapper for all configs
#
-for subvolume in $SNAPPER_SUBVOLUMES ; do
- /usr/lib/snapper/bin/daily $subvolume
+for CONFIG in $CONFIGS ; do
+
+ NUMBER_CLEANUP="no"
+ TIMELINE_CLEANUP="no"
+
+ . /etc/sysconfig/snapper.d/$CONFIG
+
+ if [ "$NUMBER_CLEANUP" = "yes" ] ; then
+ snapper --config=$CONFIG cleanup number
+ fi
+
+ if [ "$TIMELINE_CLEANUP" = "yes" ] ; then
+ snapper --config=$CONFIG cleanup timeline
+ fi
+
done
exit 0
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH
+
#
# get information from /etc/sysconfig
#
. /etc/sysconfig/snapper
fi
+
#
-# run special program for every subvolume
+# run snapper for all configs
#
-for subvolume in $SNAPPER_SUBVOLUMES ; do
- /usr/lib/snapper/bin/hourly $subvolume
+for CONFIG in $CONFIGS ; do
+
+ TIMELINE_CREATE="no"
+
+ . /etc/sysconfig/snapper.d/$CONFIG
+
+ if [ "$TIMELINE_CREATE" = "yes" ] ; then
+ snapper --config=$CONFIG create --description="timeline" --cleanup="timeline"
+ fi
+
done
exit 0
Snapper*
- createSnapper(const string& subvolume)
+ createSnapper(const string& config_name)
{
assert(!haha.get());
- haha.reset(new Snapper(subvolume));
+ haha.reset(new Snapper(config_name));
return haha.get();
}
// Only one Snapper can be created at a time.
- Snapper* createSnapper(const string& subvolume = "/");
+ Snapper* createSnapper(const string& config_name = "root");
void deleteSnapper(Snapper*);
#include "snapper/SystemCmd.h"
#include "snapper/SnapperDefines.h"
#include "snapper/File.h"
+#include "snapper/AsciiFile.h"
namespace snapper
using namespace std;
- Snapper::Snapper(const string& subvolume)
- : subvolume(subvolume), snapshots(this), files(this), compare_callback(NULL)
+ Snapper::Snapper(const string& config_name)
+ : config_name(config_name), config(NULL), subvolume("/"), snapshots(this), files(this),
+ compare_callback(NULL)
{
y2mil("Snapper constructor");
y2mil("libsnapper version " VERSION);
+ y2mil("config_name:" << config_name);
+
+ config = new SysconfigFile((CONFIGDIR "/" + config_name).c_str());
+
+ string val;
+ if (config->getValue("SUBVOLUME", val))
+ subvolume = val;
+
y2mil("subvolume:" << subvolume);
snapshots.initialize();
Snapper::~Snapper()
{
y2mil("Snapper destructor");
+
+ delete config;
}
bool
Snapper::doCleanupNumber()
{
- size_t limit = 50; // TODO
+ size_t limit = 50;
+
+ string val;
+ if (config->getValue("NUMBER_LIMIT", val))
+ val >> limit;
y2mil("limit:" << limit);
namespace snapper
{
+ class SysconfigFile;
+
struct CompareCallback
{
{
public:
- Snapper(const string& subvolume = "/");
+ Snapper(const string& config_name = "root");
~Snapper();
string subvolumeDir() const;
void filter1(vector<Snapshots::iterator>& tmp1);
- const string subvolume;
+ const string config_name;
+
+ SysconfigFile* config;
+
+ string subvolume;
Snapshots snapshots;
#define SNAPPER_DEFINES_H
-#define SYSCONFIGFILE "/etc/sysconfig/snapper"
+#define CONFIGDIR "/etc/sysconfig/snapper.d"
#define SNAPSHOTDIR "/snapshot"
#define SNAPSHOTSDIR "/snapshots"
compare-dirs
snapper.o
snapper
-hourly.o
-hourly
-daily.o
-daily
toolsbindir = /usr/lib/snapper/bin
-toolsbin_PROGRAMS = compare-dirs hourly daily
+toolsbin_PROGRAMS = compare-dirs
compare_dirs_SOURCES = compare-dirs.cc
compare_dirs_LDADD = ../snapper/libsnapper.la
-hourly_SOURCES = hourly.cc
-hourly_LDADD = ../snapper/libsnapper.la
-
-daily_SOURCES = daily.cc
-daily_LDADD = ../snapper/libsnapper.la
-
bin_PROGRAMS = snapper
--- /dev/null
+#! /bin/sh
+
+# daily - temporary wrapper script for .libs/daily
+# Generated by ltmain.sh (GNU libtool) 2.2.6b
+#
+# The daily program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='/usr/bin/sed -e 1s/^X//'
+sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+relink_command=""
+
+# This environment variable determines our operation mode.
+if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
+ # install mode needs the following variables:
+ generated_by_libtool_version='2.2.6b'
+ notinst_deplibs=' ../snapper/libsnapper.la'
+else
+ # When we are sourced in execute mode, $file and $ECHO are already set.
+ if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
+ ECHO="echo"
+ file="$0"
+ # Make sure echo works.
+ if test "X$1" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+ elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
+ # Yippee, $ECHO works!
+ :
+ else
+ # Restart under the correct shell, and then maybe $ECHO will work.
+ exec /bin/sh "$0" --no-reexec ${1+"$@"}
+ fi
+ fi
+
+ # Find the directory that this script lives in.
+ thisdir=`$ECHO "X$file" | $Xsed -e 's%/[^/]*$%%'`
+ test "x$thisdir" = "x$file" && thisdir=.
+
+ # Follow symbolic links until we get to the real thisdir.
+ file=`ls -ld "$file" | /usr/bin/sed -n 's/.*-> //p'`
+ while test -n "$file"; do
+ destdir=`$ECHO "X$file" | $Xsed -e 's%/[^/]*$%%'`
+
+ # If there was a directory component, then change thisdir.
+ if test "x$destdir" != "x$file"; then
+ case "$destdir" in
+ [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;;
+ *) thisdir="$thisdir/$destdir" ;;
+ esac
+ fi
+
+ file=`$ECHO "X$file" | $Xsed -e 's%^.*/%%'`
+ file=`ls -ld "$thisdir/$file" | /usr/bin/sed -n 's/.*-> //p'`
+ done
+
+
+ # Usually 'no', except on cygwin/mingw when embedded into
+ # the cwrapper.
+ WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no
+ if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then
+ # special case for '.'
+ if test "$thisdir" = "."; then
+ thisdir=`pwd`
+ fi
+ # remove .libs from thisdir
+ case "$thisdir" in
+ *[\\/].libs ) thisdir=`$ECHO "X$thisdir" | $Xsed -e 's%[\\/][^\\/]*$%%'` ;;
+ .libs ) thisdir=. ;;
+ esac
+ fi
+
+ # Try to get the absolute directory name.
+ absdir=`cd "$thisdir" && pwd`
+ test -n "$absdir" && thisdir="$absdir"
+
+ program='daily'
+ progdir="$thisdir/.libs"
+
+
+ if test -f "$progdir/$program"; then
+ # Add our own library path to LD_LIBRARY_PATH
+ LD_LIBRARY_PATH="/ARVIN/snapper/snapper/.libs:/usr/lib:$LD_LIBRARY_PATH"
+
+ # Some systems cannot cope with colon-terminated LD_LIBRARY_PATH
+ # The second colon is a workaround for a bug in BeOS R4 sed
+ LD_LIBRARY_PATH=`$ECHO "X$LD_LIBRARY_PATH" | $Xsed -e 's/::*$//'`
+
+ export LD_LIBRARY_PATH
+
+ if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
+ # Run the actual program with our arguments.
+
+ exec "$progdir/$program" ${1+"$@"}
+
+ $ECHO "$0: cannot exec $program $*" 1>&2
+ exit 1
+ fi
+ else
+ # The program doesn't exist.
+ $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2
+ $ECHO "This script is just a wrapper for $program." 1>&2
+ echo "See the libtool documentation for more information." 1>&2
+ exit 1
+ fi
+fi
+++ /dev/null
-
-#include <stdlib.h>
-
-#include <snapper/AppUtil.h>
-#include <snapper/Snapper.h>
-#include <snapper/Factory.h>
-
-using namespace snapper;
-
-
-int
-main(int argc, char** argv)
-{
- if (argc != 2)
- {
- fprintf(stderr, "usage: daily subvolume\n");
- exit(EXIT_FAILURE);
- }
-
- initDefaultLogger();
-
- string subvolume = argv[1];
-
- y2mil("daily subvolume:" << subvolume);
-
- Snapper* sh = createSnapper(subvolume);
-
- sh->doCleanupNumber();
- sh->doCleanupTimeline();
-
- deleteSnapper(sh);
-
- exit(EXIT_SUCCESS);
-}
--- /dev/null
+#! /bin/sh
+
+# hourly - temporary wrapper script for .libs/hourly
+# Generated by ltmain.sh (GNU libtool) 2.2.6b
+#
+# The hourly program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='/usr/bin/sed -e 1s/^X//'
+sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+relink_command=""
+
+# This environment variable determines our operation mode.
+if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
+ # install mode needs the following variables:
+ generated_by_libtool_version='2.2.6b'
+ notinst_deplibs=' ../snapper/libsnapper.la'
+else
+ # When we are sourced in execute mode, $file and $ECHO are already set.
+ if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
+ ECHO="echo"
+ file="$0"
+ # Make sure echo works.
+ if test "X$1" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+ elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
+ # Yippee, $ECHO works!
+ :
+ else
+ # Restart under the correct shell, and then maybe $ECHO will work.
+ exec /bin/sh "$0" --no-reexec ${1+"$@"}
+ fi
+ fi
+
+ # Find the directory that this script lives in.
+ thisdir=`$ECHO "X$file" | $Xsed -e 's%/[^/]*$%%'`
+ test "x$thisdir" = "x$file" && thisdir=.
+
+ # Follow symbolic links until we get to the real thisdir.
+ file=`ls -ld "$file" | /usr/bin/sed -n 's/.*-> //p'`
+ while test -n "$file"; do
+ destdir=`$ECHO "X$file" | $Xsed -e 's%/[^/]*$%%'`
+
+ # If there was a directory component, then change thisdir.
+ if test "x$destdir" != "x$file"; then
+ case "$destdir" in
+ [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;;
+ *) thisdir="$thisdir/$destdir" ;;
+ esac
+ fi
+
+ file=`$ECHO "X$file" | $Xsed -e 's%^.*/%%'`
+ file=`ls -ld "$thisdir/$file" | /usr/bin/sed -n 's/.*-> //p'`
+ done
+
+
+ # Usually 'no', except on cygwin/mingw when embedded into
+ # the cwrapper.
+ WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no
+ if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then
+ # special case for '.'
+ if test "$thisdir" = "."; then
+ thisdir=`pwd`
+ fi
+ # remove .libs from thisdir
+ case "$thisdir" in
+ *[\\/].libs ) thisdir=`$ECHO "X$thisdir" | $Xsed -e 's%[\\/][^\\/]*$%%'` ;;
+ .libs ) thisdir=. ;;
+ esac
+ fi
+
+ # Try to get the absolute directory name.
+ absdir=`cd "$thisdir" && pwd`
+ test -n "$absdir" && thisdir="$absdir"
+
+ program='hourly'
+ progdir="$thisdir/.libs"
+
+
+ if test -f "$progdir/$program"; then
+ # Add our own library path to LD_LIBRARY_PATH
+ LD_LIBRARY_PATH="/ARVIN/snapper/snapper/.libs:/usr/lib:$LD_LIBRARY_PATH"
+
+ # Some systems cannot cope with colon-terminated LD_LIBRARY_PATH
+ # The second colon is a workaround for a bug in BeOS R4 sed
+ LD_LIBRARY_PATH=`$ECHO "X$LD_LIBRARY_PATH" | $Xsed -e 's/::*$//'`
+
+ export LD_LIBRARY_PATH
+
+ if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
+ # Run the actual program with our arguments.
+
+ exec "$progdir/$program" ${1+"$@"}
+
+ $ECHO "$0: cannot exec $program $*" 1>&2
+ exit 1
+ fi
+ else
+ # The program doesn't exist.
+ $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2
+ $ECHO "This script is just a wrapper for $program." 1>&2
+ echo "See the libtool documentation for more information." 1>&2
+ exit 1
+ fi
+fi
+++ /dev/null
-
-#include <stdlib.h>
-
-#include <snapper/AppUtil.h>
-#include <snapper/Snapper.h>
-#include <snapper/Factory.h>
-
-using namespace snapper;
-
-
-int
-main(int argc, char** argv)
-{
- if (argc != 2)
- {
- fprintf(stderr, "usage: hourly subvolume\n");
- exit(EXIT_FAILURE);
- }
-
- initDefaultLogger();
-
- string subvolume = argv[1];
-
- y2mil("hourly subvolume:" << subvolume);
-
- if (subvolume != "/") // TODO
- exit(EXIT_SUCCESS);
-
- Snapper* sh = createSnapper(subvolume);
-
- Snapshots::iterator snap = sh->createSingleSnapshot("timeline");
- snap->setCleanup("timeline");
-
- deleteSnapper(sh);
-
- exit(EXIT_SUCCESS);
-}
GetOpts getopts;
bool quiet = false;
-string subvolume = "/";
+string config_name = "root";
Snapper* sh = NULL;
cout << _(" Global options:") << endl
<< _("\t--quiet, -q\t\t\tSuppress normal output.") << endl
<< _("\t--table-style, -t <style>\tTable style (integer).") << endl
- << _("\t--subvolume, -s <path>\t\tSet subvolume.") << endl
+ << _("\t--config, -c <name>\t\tSet name of config to use.") << endl
<< endl;
help_list();
const struct option options[] = {
{ "quiet", no_argument, 0, 'q' },
{ "table-style", required_argument, 0, 't' },
- { "subvolume", required_argument, 0, 's' },
+ { "config", required_argument, 0, 'c' },
{ 0, 0, 0, 0 }
};
Table::defaultStyle = (TableLineStyle) s;
}
- if ((opt = opts.find("subvolume")) != opts.end())
- subvolume = opt->second;
+ if ((opt = opts.find("config")) != opts.end())
+ config_name = opt->second;
- sh = createSnapper(subvolume);
+ sh = createSnapper(config_name);
if (!quiet)
sh->setCompareCallback(&compare_callback_impl);