7600 zfs rollback should pass target snapshot to kernel
[unleashed.git] / usr / src / cmd / bnu / uupick
blobf4cfe85a5f4a94db5e1198a68180da0b38ebd18c
1 #!/bin/sh
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License, Version 1.0 only
7 # (the "License"). You may not use this file except in compliance
8 # with the License.
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
21 # CDDL HEADER END
24 # Copyright 1999 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
27 #ident "%Z%%M% %I% %E% SMI"
29 export IFS PATH
30 IFS="
32 PATH="/usr/bin"
34 # sys: system; user: login name; cdir: current directory;
35 # tdir: temporary directory; pu: PUBDIR/receive/user;
36 cdir=`pwd`
37 dir=""
38 abs=""
39 sys=""
40 var=""
41 varto=""
42 varfrom=""
43 trap "exit 1" 1 2 13 15
45 # mktmpdir - Create a private (mode 0700) temporary directory inside of /tmp
46 # for this process's temporary files. We set up a trap to remove the
47 # directory on exit (trap 0), and also on SIGHUP, SIGINT, SIGQUIT, and
48 # SIGTERM.
50 mktmpdir() {
51 tmpdir=/tmp/bnu.$$
52 trap '/usr/bin/rm -rf $tmpdir' 0 1 2 3 15
53 /usr/bin/mkdir -m 700 $tmpdir || exit 1
56 mktmpdir
58 # get options
59 while getopts s: FLAG; do
60 case $FLAG in
61 s) sys=$OPTARG
63 ?) gettext "Usage: uupick [-s sysname]\n" 1>&2;
64 exit 1
66 esac
67 done
68 shift `expr $OPTIND - 1`
70 if [ $# -gt 0 ]; then
71 gettext "Usage: uupick [-s sysname]\n" 1>&2;
74 user=`id | sed -n "/^uid=[0-9]*(\([^)]*\)).*/s//\1/p"`
76 if test -z "$user"
77 then gettext "User id required!\n" >&2; exit 1
80 pu=/var/spool/uucppublic/receive/$user
81 if test -d $pu -a -s $pu
82 then
83 for i in `/usr/bin/ls $pu`
85 if test $sys
86 then
87 if test $sys != $i; then continue; fi
89 if test -d $pu/$i -a -s $pu/$i
90 then
91 cd $pu/$i
92 for j in `/usr/bin/ls -a`
94 if test $j = "." -o $j = ".."; then continue; fi
95 if test -d $j
96 then printf "`gettext 'from system %s: directory %s '`" $i $j
97 else printf "`gettext 'from system %s: file %s '`" $i $j
99 while true
101 echo '? \c'
102 if read cmd dir
103 then
104 trap ": ;;" 1
105 case $cmd in
107 rm -fr $j ; break ;;
109 break ;;
110 # options m, a:
111 # If dir path begins with a slash, use full path for destination;
112 # otherwise, use path relative to current dir;
113 # default destination is current dir
115 # As files are transferred, put their names in $tmpdir/$$uupick.
116 # Only remove those named files from...receive/..dir if cmp
117 # verifies transfer took place. then find & remove directories
118 # (separate find is necessary because cpio -v doesn't print dir names)
119 a|m)
120 eval dir="$dir"
121 if test $dir
122 then abs=`expr "$dir" : '/.*'`
123 if test $abs != 0
124 then tdir=$dir
125 else tdir=$cdir/$dir
127 else
128 tdir=$cdir
130 if [ ! -d $tdir -o ! -w $tdir ]; then
131 printf "`gettext 'directory %s doesn't exist or isn't writable'`" $tdir >&2
132 continue
134 if [ "$cmd" = "a" ]
135 then
136 find . -depth -print | \
137 grep -v '^\.$' > $tmpdir/$$uupick
138 level=2
139 else
140 find $j -depth -print > $tmpdir/$$uupick
141 level=1
143 cpio -pdmu $tdir < $tmpdir/$$uupick
144 for k in `cat $tmpdir/$$uupick`
146 varto="$tdir/$k"
147 varfrom="$pu/$i/$k"
148 if test -f $varfrom; then
149 if cmp $varfrom $varto ; then
150 rm -f $varfrom
151 else
152 printf "`gettext 'file %s not removed'`" $varfrom >&2
154 else
155 rmdir $varfrom 2>/dev/null
157 done
158 rm -f $tmpdir/$$uupick
159 break $level;;
161 if test -d $j
162 then find $j -print
163 elif test -s $j
164 then cat $j
165 fi;;
167 break 3;;
169 ex=`expr "$cmd $dir" : '!\(.*\)'`
170 tdir=`pwd`
171 cd $cdir
172 sh -c "$ex"
173 cd $tdir
174 echo '!';;
176 gettext "Usage: [d][m dir][a dir][p][q][cntl-d][!cmd][*][new-line]";;
177 esac
178 trap "exit 1" 1
179 else
180 break 3
182 done
183 done
185 done