Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../../../../../../lib/svc/bin/restore_repository
Real path: /lib/svc/bin/restore_repository
Zurück
#!/usr/bin/sh # # Copyright (c) 2004, 2023, Oracle and/or its affiliates. # PATH=/sbin:/usr/bin:/usr/sbin LC_ALL=C export PATH LC_ALL . /lib/svc/share/smf_include.sh . /lib/svc/share/fs_include.sh usage() { echo "usage: $0 [-r rootdir]" >&2 echo " See http://support.oracle.com/msg/SMF-8000-MY for more information on the use of this script." exit 2; } repositorydir=etc/svc repository=repository SQL3=/usr/bin/sqlite3 myroot=/ while getopts r: opt; do case "$opt" in r) myroot=$OPTARG if [ ! -d $myroot ]; then echo "$myroot: not a directory" >&2 exit 1 fi # validate directory and make sure it ends in '/'. case "$myroot" in //*) echo "$myroot: must begin with a single /" >&2 usage;; /) echo "$myroot: alternate root cannot be /" >&2 usage;; /*/) ;; # ends with / /*) myroot="$myroot/";; # add final / *) echo "$myroot: must be a full path" >&2 usage;; esac;; ?) usage;; esac done if [ $OPTIND -le $# ]; then # getopts(1) didn't slurp up everything. usage fi # # Note that the below test is carefully constructed to fail *open*; if # anything goes wrong, it will drive onward. # if [ -x /usr/bin/id ] && [ "$(id -u 2>/dev/null)" != 0 ]; then echo "$0: may only be invoked by root" >&2 exit 2 fi echo >&2 " See http://support.oracle.com/msg/SMF-8000-MY for more information on the use of this script to restore backup copies of the smf(7) repository. If there are any problems which need human intervention, this script will give instructions and then exit back to your shell." if [ "$myroot" = / ]; then system="system" [ "`/usr/sbin/zonename`" != global ] && system="zone" echo >&2 " Note that upon full completion of this script, the $system will be rebooted using reboot(8), which will interrupt any active services. " fi # check that the filesystem is as expected cd "$myroot" || exit 1 cd "$myroot$repositorydir" || exit 1 nouser=false rootro=false # check to make sure /usr is mounted if [ ! -x /usr/bin/pgrep ]; then nouser=true fi if [ ! -w "$myroot" ]; then rootro=true fi if [ "$nouser" = true -o "$rootro" = true ]; then if [ "$nouser" = true -a "$rootro" = true ]; then echo "The / filesystem is mounted read-only, and the /usr" >&2 echo "filesystem has not yet been mounted." >&2 elif [ "$nouser" = true ]; then echo "The /usr filesystem has not yet been mounted." >&2 else echo "The / filesystem is mounted read-only." >&2 fi echo >&2 " This must be rectified before $0 can continue. If / or /usr are on SVM (md(4D)) partitions, first run /lib/svc/method/svc-metainit To properly mount / and /usr, run: /lib/svc/method/fs-root then /lib/svc/method/fs-usr After those have completed successfully, re-run: $0 $* to continue. " exit 1 fi # at this point, we know / is mounted read-write, and /usr is mounted. oldreps="` /bin/ls -1rt $repository-*-[0-9]*[0-9] | \ /bin/sed -e '/[^A-Za-z0-9_,.-]/d' -e 's/^'$repository'-//' `" if [ -z "$oldreps" ]; then cat >&2 <<EOF There are no available backups of $myroot$repositorydir/$repository.db. The only available repository is "-seed-". Note that restoring the seed will lose all customizations, including those made by the system during the installation and/or upgrade process. EOF prompt="Enter -seed- to restore from the seed, or -quit- to exit: \c" default= else cat >&2 <<EOF The following backups of $myroot$repositorydir/$repository.db exist, from oldest to newest: $oldreps The backups are named based on their type and the time what they were taken. Backups beginning with "boot" are made before the first change is made to the repository after system boot. Backups beginning with "manifest_import" are made after svc:/system/manifest-import:default finishes its processing. The time of backup is given in YYYYMMDD_HHMMSS format. Please enter either a specific backup repository from the above list to restore it, or one of the following choices: CHOICE ACTION ---------------- ---------------------------------------------- boot restore the most recent post-boot backup manifest_import restore the most recent manifest_import backup -seed- restore the initial starting repository (All customizations will be lost, including those made by the install/upgrade process.) -quit- cancel script and quit EOF prompt="Enter response [boot]: \c" default="boot" fi cont=false while [ $cont = false ]; do echo "$prompt" read x || exit 1 [ -z "$x" ] && x="$default" case "$x" in -seed-) file= ;; -quit-) echo "Exiting." exit 0;; /*) file="$x";; */*) file="$myroot$x";; ?*) file="$myroot$repositorydir/repository-$x";; *) file= ;; esac if [ "$x" = "-seed-" ]; then cont=true elif [ -f $file ]; then if [ -r $file ]; then $SQL3 $file .schema > /dev/null 2>&1 if [ $? -ne 0 ] ; then echo "$file is not an Sqlite file." >&2 echo continue fi checkresults="`echo PRAGMA integrity_check\; | \ $SQL3 $file >&1 | grep -v '^ok$'`" if [ -n "$checkresults" ]; then echo "$file: integrity check failed:" >&2 echo "$checkresults" >&2 echo else cont=true fi else echo "$file: not readable" fi elif [ -n "$file" ]; then echo "$file: not found" fi done errors="$myroot"$SMF_SYSVOL_FS/db_errors repo="$myroot$repositorydir/$repository.db" new="$repo"_old_"`date +%Y''%m''%d'_'%H''%M''%S`" steps= if [ "$myroot" = / ]; then steps="$steps svc.startd(8) and svc.configd(8) will be quiesced, if running." fi if [ -r $repo ]; then steps="$steps $repo -- renamed --> $new" fi if [ -r $errors ]; then steps="$steps $errors -- copied --> ${new}_errors" fi if [ "$x" = "-seed-" ]; then steps="$steps rm $repo" else steps="$steps $file -- copied --> $repo " fi cat >&2 <<EOF After confirmation, the following steps will be taken: $steps EOF if [ "$myroot" = / ]; then echo "and the system will be rebooted with reboot(8)." fi echo cont=false while [ $cont = false ]; do echo "Proceed [yes/no]? \c" read a || a=n case "$a" in [Yy]|[Yy][Ee][Ss]) cont=true;; [Nn]|[Nn][Oo]) echo; echo "Exiting..." exit 0; esac; done umask 077 # we want files to be root-readable only. startd_msg= if [ "$myroot" = / ]; then zone="`zonename`" startd="`pgrep -z "$zone" -f svc.startd`" echo echo "Quiescing svc.startd(8) and svc.configd(8): \c" if [ -n "$startd" ]; then pstop $startd startd_msg=\ "To start svc.startd(8), do: /usr/bin/prun $startd" fi pkill -z "$zone" -f svc.configd sleep 1 # yes, this is hack echo "done." fi if [ -r "$repo" ]; then echo "$repo" echo " -- renamed --> $new" if mv $repo $new; then : else echo "Failed. $startd_msg" exit 1; fi fi if [ -r $errors ]; then echo "$errors" echo " -- copied --> ${new}_errors" if cp -p $errors ${new}_errors; then : else mv -f $new $repo echo "Failed. $startd_msg" exit 1; fi fi if [ "$x" = "-seed-" ]; then echo "removed --> $repo" if rm -f $repo; then : else echo "Failed. $startd_msg" exit 1; fi else echo "$file" echo " -- copied --> $repo" if cp $file $repo.new.$$ && mv $repo.new.$$ $repo; then : else rm -f $repo.new.$$ ${new}_errors mv -f $new $repo echo "Failed. $startd_msg" exit 1; fi fi echo echo "The backup repository has been successfully restored." echo if [ "$myroot" = / ]; then echo "Rebooting in 5 seconds." sleep 5 reboot fi