Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- check_root() {
- [ "$EUID" -ne 0 ] && echo "This script must be run as root (superuser)."; exit 1
- }
- # Check if the 'extundelete' utility is installed
- check_extundelete() {
- [ ! $(command -v extundelete > /dev/null) ] && echo "The 'extundelete' utility is not installed. Please install it before proceeding."; exit 1
- }
- # Recover a deleted file
- recover_file() {
- local file_to_recover="$1"
- local device="/dev/sdXY" # Replace with the appropriate device
- extundelete --restore-file "$file_to_recover" --device "$device"
- local exit_code=$?
- [ $exit_code -eq 0 ] && echo "File successfully recovered: $file_to_recover" ||
- echo "File recovery failed. Please verify the file name and device, and ensure the file has not been overwritten."
- }
- main() {
- check_root
- check_extundelete
- [ $# -ne 1 ] && echo "Usage: $0 <file_to_recover>"; exit 1
- file_to_recover="$1"
- recover_file "$file_to_recover"
- }
- main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement