2 # Filename: restore-config
3 # Purpose: generate grml configuration archive and store it anywhere
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 # Latest change: Son Mai 13 11:12:38 CEST 2007 [mika]
8 ################################################################################
11 autoload colors ; colors
12 [ -r /etc/grml/sh-lib ] && . /etc/grml/sh-lib
23 if [[ $DEBUG -gt 0 ]] ; then
37 # usage information {{{
41 $bg[black]$fg[green]${boldcolor}${PROGRAMNAME} - restore configuration of grml system${reset_color}
43 $bg[black]$fg[blue]${boldcolor}Usage:${reset_color}
44 $PROGRAMNAME [-target_options] <configuration_file>
46 $bg[black]$fg[blue]${boldcolor}Target options:${reset_color}
47 -home extract hidden files from \$HOME (\$HOME/.*)
48 -grmlhome store hidden files from \$HOME (\$HOME/.*) of user grml [use as user root]
49 -etc extract modified files from /etc
50 -configdir extract \$HOME/config
52 Default: restore/extract complete archive.
54 Notice: it is also possible to use environment variables:
55 \$RESTORE_HOME, \$RESTORE_ETC, \$RESTORE_CONFIGDIR and \$RESTORE_ALL
57 $bg[black]$fg[blue]${boldcolor}Usage examples:${reset_color}
58 $PROGRAMNAME -home foo_bar_config.tbz => restore configuration from file foo_bar_config.tbz
59 $PROGRAMNAME config.tbz => restore configuration from file config.tbz
61 More information on restore-config can be found in the manual page: man restore-config
63 See also: save-config(1), bootoptions: myconfig=/dev/ice, extract=PATH,
64 netconfig=server.tld/path/to/config.tbz
66 Report bugs, send wishes and feedback to the grml team:
67 http://grml.org/bugs/ - contact (at) grml.org
73 # extract configuration file {{{
75 echo "Trying to extract $FILENAME"
76 ( cd / && unp $FILENAME )
80 echo "Trying to extract $FILENAME in $HOME"
81 ( cd $HOME && unp $FILENAME -- -x $HOME )
85 echo "Trying to extract $FILENAME in /home/grml"
86 ( cd /home/grml/ && unp $FILENAME -- -x /home/grml )
90 echo "Trying to extract $FILENAME in /etc"
91 ( cd /etc && unp $FILENAME -- -x /etc )
95 echo "Trying to extract $FILENAME in $HOME/config"
96 ( cd $HOME && unp $FILENAME -- -x $HOME/config )
101 # commandline parsing {{{
104 zparseopts -K -- help=o_help file:=o_file home=o_home etc=o_etc \
105 configdir=o_configdir all=o_all
107 if [[ "$#" == 0 || "$o_help" != "" || "$1" == '-h' || "$1" == '--help' ]]; then
111 if [[ "$1" == "" ]]; then
112 echo "Error: No filename provided." ; exit 1
115 FILENAME=`readlink -f $FILENAME`
118 if [[ "$o_home" != "" ]]; then
119 echo "debug: home is set"
123 if [[ "$o_grmlhome" != "" ]]; then
124 echo "debug: grmlhome is set"
125 RESTORE_GRMLHOME="yes"
128 if [[ "$o_etc" != "" ]]; then
129 echo "debug: etc is set"
133 if [[ "$o_configdir" != "" ]]; then
134 echo "debug: configdir is set"
135 RESTORE_CONFIGDIR="yes"
143 if [[ $RESTORE_HOME == "yes" ]]; then
144 debug "running restore_home"
148 if [[ $RESTORE_GRMLHOME == "yes" ]]; then
149 debug "running restore_grmlhome"
153 if [[ $RESTORE_ETC == "yes" ]] ; then
154 debug "running restore_etc"
158 if [[ $RESTORE_CONFIGDIR == "yes" ]] ; then
159 debug "running restore_configdir"
163 debug "FILENAME = $FILENAME"
164 if [ -z $RESTORE_SET ] ; then
165 debug "running restore all"
174 ## END OF FILE #################################################################
175 # vim:foldmethod=marker