删除技术支持部门的回收站机制
This commit is contained in:
@@ -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
|
|
||||||
@@ -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
|
|
||||||
3
setup.sh
3
setup.sh
@@ -31,9 +31,6 @@ echo "====add fonts===="
|
|||||||
./set_limits.conf.sh
|
./set_limits.conf.sh
|
||||||
echo "====Set limits.conf===="
|
echo "====Set limits.conf===="
|
||||||
|
|
||||||
./set_recycling-station.sh
|
|
||||||
echo "===Set trash recycling station==="
|
|
||||||
|
|
||||||
./set_fstab.sh
|
./set_fstab.sh
|
||||||
echo "===Set /etc/fstab==="
|
echo "===Set /etc/fstab==="
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user