Editing
Save-vsdata.sh
From Linix VServer
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
\#!/bin/bash # # Copyright (C) 2008 Daniel Hokka Zakrisson # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, # Boston, MA 02110-1301, USA. tmp=$(getopt -o '+R:f:ut' --long root:,file:,unset,tags -n "$0" -- "$@") || { echo "Usage: $0 [--root ] [--file ]" echo " [--unset] [--tags]" echo echo " --root begin traversing the tree at " echo " --file send output to " echo " --unset unset attributes after reading them" echo " WARNING: USE WITH CAUTION" echo " --tags save tags too" echo echo "Copyright (C) 2008 Daniel Hokka Zakrisson" echo "This program is free software; you may redistribute it under the terms of" echo "the GNU General Public License. This program has absolutely no warranty." exit 1 } >&2 eval set -- "$tmp" ROOT=/ FILE= UNSET=0 TAGS=0 while true; do case "$1" in (-R|--root) ROOT="$2"; shift;; (-f|--file) FILE="$2"; shift;; (-u|--unset) UNSET=1;; (-t|--tags) TAGS=1;; (--) shift; break;; (*) echo "$0: unrecognized option: '$1'" >&2 exit 1;; esac shift done set -e export LANG=C if test -n "$FILE"; then exec >"$FILE" fi showattr -Ra "$ROOT" | gawk '$1 ~ /[BUI]/ { printf "setattr "; unsetter="setattr "; if ($1 ~ /B/) { printf "--barrier "; unsetter=unsetter"--~barrier "; } if ($1 ~ /UI/) { printf "--iunlink "; unsetter=unsetter"--~iunlink "; } else if ($1 ~ /I/) { printf "--immutable "; unsetter=unsetter"--~immutable "; } else if ($1 ~ /U/) { printf "--iunlink-but-not-immutable "; unsetter=unsetter"--~iunlink-but-not-immutable "; } print $2; unsetter=unsetter" "$2; if ('$UNSET') system(unsetter); } $1 ~ /X/ && '$TAGS' { tmp="lsxid -nd "$2; tmp | getline > 0; printf "chxid -c %s %s\n", $1, $2; close(tmp); if ($1 != "0" && '$UNSET') system("chxid -c 0 "$2); }' exit 0
Summary:
Please note that all contributions to Linix VServer may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Linix VServer:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Page actions
Page
Discussion
Read
Edit
History
Page actions
Page
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
About
Overview
Paper
News
Developers
Donations
Search
Getting Started
Downloads
FAQs
Documentation
Support
Participate
How to participate
Report a Bug
Communicate
Teams/Projects
Hall of Fame
Resources
Archives
Recent Wiki Changes
Pastebin
Related Projects
VServer Hosting
Happy VServer Users
Tools
What links here
Related changes
Special pages
Page information