Skip to content

rm -rf but with softly #sotlyforcing #underconstuction 👷

License

Notifications You must be signed in to change notification settings

thapakazi/soft_rm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

soft_rm :co

rm -rf but with softly #sotlyforcing

  • It all started here:

    https://raw.githubusercontent.com/zerOnepal/soft_rm/master/soft_rm_1st_tweet.png

  • then it got public discussion

https://raw.githubusercontent.com/zerOnepal/soft_rm/master/soft_rm_begins.png

and

https://raw.githubusercontent.com/zerOnepal/soft_rm/master/soft_rm_into.png

how it works:

  1. getting file path
    rm -rf myfiles/*
        
  2. tag the files and expiry date
    # setting necessary tag attributes
    set_attribs(){
        expires_on=$(date +%d_%m_%Y -d "+$EXPIRE_ON")
        deleted_from="$(echo $1|awk -F/ 'BEGIN{OFS="/"}{$NF="";print$0}')"
    
        export SAVEDIR=$TMPDIR/"$(echo $1|awk -F/ '{print$NF}')" #(mktemp -td my_blob.XXXXXXXXXX) #lets have some randomness
        mkdir -p $SAVEDIR
        #lets put some attr to the file/folder
        setfattr -n user.expires_on \
                 -v $expires_on $SAVEDIR \
            || { echo; echo 'mount / -o remount,user_xattr
                      if you see Operation not permitted error
                      also donot use /tmp spits out crazy issue, trust me'; exit; }
        setfattr -n user.deleted_from \
                 -v $deleted_from $SAVEDIR \
            || { echo; echo 'bailing out setting attrs about deleted_path
                             flie/folder being removed seems fishy'; exit; }
    
        move_and_fake_rm-rf "$1"
        print_thrash_home_contents "$SAVEDIR"
    }
        
  3. move file/folder to MOTHER_OF_RECYCLE_BIN_FOLDER
    mv myfiles/* $MOTHER_OF_RECYCLE_BIN_FOLDER
        

left:

a cronie to take care of this:

# file: /mytemp/soft_rm/01_04_2016/soft_rm_into.png
user.deleted_from="tests/"
user.expires_on="21_04_201

About

rm -rf but with softly #sotlyforcing #underconstuction 👷

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages