1、前往 /etc/init.d/
添加自定义脚本,如添加 vi /etc/init.d/user_init.sh
#!/bin/bash
#add for chkconfig
#chkconfig:2345 70 30
#description:the description of the shell
#关闭防火墙
/etc/init.d/iptables stop
#挂载window共享文件
username=xxx
password=xxx
share=//xxx.xxx.xxx.xxx/work
targe=/mnt/work
if [ ! -d $targe ]
then
/bin/mkdir -p $targe >/dev/null 2>&1 && echo "Directory $targe created." || echo "Error: Failed to create $targe directory."
fi
mount -t cifs -o username=$username,password=$password,rw,dir_mode=0777,file_mode=0777 $share $targe
2、给脚本加上可执行权限:
chmod +x user_init.sh
3、将脚本设置为自启动:
chkconfig --add andy.sh
chkconfig 用于处理系统自动运行脚本指令