删除技术支持部门的回收站机制

This commit is contained in:
Jinnan Wang
2014-03-18 14:33:29 +08:00
parent b81f1ec1fc
commit 563c19b2cc
3 changed files with 0 additions and 132 deletions

View File

@@ -1,46 +0,0 @@
#!/bin/bash
#set_recycling-station.sh
#Linux回收站改写rm防止误删文件引起无法恢复
#Jincheng Ye
#2013/05/14
#modified by Jincheng Ye,2013/10/28
grep trash /root/.bashrc &> /dev/null
if [ $? -eq 0 ];then
echo "trash exist..."
else
cat >> /root/.bashrc <<EOF
#Linux回收站改写rm,防止bash用户误删文件引起无法恢复
mkdir -p ~/.trash
alias rm=trash
alias r=trash
alias rl='ls ~/.trash'
alias ur=undelfile
#回收函数
undelfile()
{
mv -i ~/.trash/\$@ ./
}
#垃圾函数,该函数不删除系统重要目录下的重要文件如果用户实在想删除可以指定rm命令的路径来完成原来rm的功能如:
#/bin/rm /opt/test.sh
trash()
{
#Can't delete / /s* /b* /l* /d* /e* /u* /r* /v* /h* /o* /p* /* ~ ~/*
if [[ \$@ != /[sbldeurvhop]* ]] && [[ \$@ != "/" ]] && [[ \$@ != "/*" ]] && [[ \$@ != ~* ]]
then
mv \$@ ~/.trash/
else
echo "Can't delete \$@!"
fi
}
#清除垃圾回收站的内容的函数
cleartrash()
{
read -p "clear sure?[y/n]" confirm
[ ${confirm} == 'y' ]||[ ${confirm} == 'Y' ] && /bin/rm -rf ~/.trash/*
}
EOF
fi

View File

@@ -1,83 +0,0 @@
#!/bin/bash
#set_recycling-station.sh
#Linux回收站改写rm防止误删文件引起无法恢复
#Jincheng Ye
#2013/05/14
grep trash /etc/profile &> /dev/null
if [ $? -eq 0 ];then
echo "trash exist..."
else
cat >> /etc/profile <<EOF
#Linux回收站改写rm,防止bash用户误删文件引起无法恢复
mkdir -p ~/.trash
alias rm=trash
alias r=trash
alias rl='ls ~/.trash'
alias ur=undelfile
#回收函数
undelfile()
{
mv -i ~/.trash/\$@ ./
}
#垃圾函数,该函数不删除系统重要目录下的重要文件如果用户实在想删除可以指定rm命令的路径来完成原来rm的功能如:
#/bin/rm /opt/test.sh
trash()
{
#Can't delete / /s* /b* /l* /d* /e* /u* /r* /v* /h* /o* /p* /* ~ ~/*
if [[ \$@ != /[sbldeurvhop]* ]] && [[ \$@ != "/" ]] && [[ \$@ != "/*" ]] && [[ \$@ != ~* ]]
then
mv \$@ ~/.trash/
else
echo "Can't delete \$@!"
fi
}
#清除垃圾回收站的内容的函数
cleartrash()
{
read -p "clear sure?[y/n]" confirm
[ ${confirm} == 'y' ]||[ ${confirm} == 'Y' ] && /bin/rm -rf ~/.trash/*
}
EOF
cat >> ~/.bashrc <<EOF
#Linux回收站改写rm,防止bash用户误删文件引起无法恢复
mkdir -p ~/.trash
alias rm=trash
alias r=trash
alias rl='ls ~/.trash'
alias ur=undelfile
#回收函数
undelfile()
{
mv -i ~/.trash/\$@ ./
}
#垃圾函数,该函数不删除系统重要目录下的重要文件如果用户实在想删除可以指定rm命令的路径来完成原来rm的功能如:
#/bin/rm /opt/test.sh
trash()
{
#Can't delete / /s* /b* /l* /d* /e* /u* /r* /v* /h* /o* /p* /* ~ ~/*
if [[ \$@ != /[sbldeurvhop]* ]] && [[ \$@ != "/" ]] && [[ \$@ != "/*" ]] && [[ \$@ != ~* ]]
then
mv \$@ ~/.trash/
else
echo "Can't delete \$@!"
fi
}
#清除垃圾回收站的内容的函数
cleartrash()
{
read -p "clear sure?[y/n]" confirm
[ ${confirm} == 'y' ]||[ ${confirm} == 'Y' ] && /bin/rm -rf ~/.trash/*
}
EOF
cat >> /etc/csh.cshrc <<EOF
#由于cshell脚本编程中没有函数因此仅在cshell用户中删除时进行提示
alias rm 'rm -i'
EOF
fi

View File

@@ -31,9 +31,6 @@ echo "====add fonts===="
./set_limits.conf.sh
echo "====Set limits.conf===="
./set_recycling-station.sh
echo "===Set trash recycling station==="
./set_fstab.sh
echo "===Set /etc/fstab==="