ubuntu常用服务搭建

1、samba服务,映射共享文件,如共享/sdb目录。

mkdir /sdb/

apt-get install -y samba

vi /etc/samba/smb.conf

{

[DiskShare]

  comment = DiskShare_sdb

  path = /sdb/

  browseable = yes

  writable = yes

  directory mask = 0755

}


sudo smbpasswd -a zh

sudo service smbd restart


2、shell自动输入密码,如启动时,让系统自动挂载磁盘需要root用户,使用 sudo时输入密码:

fdisk /dev/sdb

mkfs.ext4 /dev/sdb1

安装expect 执行以下命令

sudo apt-get install  -y tcl 

sudo apt-get install  -y tk 

sudo apt-get install  -y expect

自动挂载磁盘脚本mount_disk.sh内容:

#!/usr/bin/expect

/usr/bin/expect

set timeout 5 

spawn /usr/bin/sudo /bin/mount /dev/sdb1 /sdb/

expect "password for *:" 

send "123456\r" 

interact


在/etc/profile最后添加:

IS_SDB_MOUNT=`mount | grep "sdb1"`

if [ "0" = "${#IS_SDB_MOUNT}" ];then

echo "mount /dev/sdb1 /sdb/..."

if [ -x ./custom_mount_sdb.sh ]; then

expect /etc/mount_disk.sh

fi

fi

你可能感兴趣的:(ubuntu常用服务搭建)