昨日のポスト(FreeBSDでデスクトップ環境(MATE)を構築する - くんすとの備忘録)の続き。一撃でセットアップするシェルスクリプトにしてみました。
やり直しや載せ替えの時の再利用が捗る・・・

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh

if [ $# -eq 0 ]; then
    echo "Please set default_user to \$1"
    exit 9
fi

USER=$1

set -ev

### INITIALIZE ###
freebsd-update fetch
freebsd-update install

export ASSUME_ALWAYS_YES=yes
portsnap  --interactive fetch extract

cat <<++EOS | xargs pkg install
  xorg open-vm-tools xf86-input-vmmouse xf86-video-vmware
  slim slim-themes mate
  ja-font-std ja-font-vlgothic ja-font-takao
  ja-ibus-mozc
  sudo
++EOS

Xorg -configure
mv /root/xorg.conf.new /etc/X11/xorg.conf

cat >> /boot/loader.conf << ++EOS
autoboot_delay="2"
++EOS

cat >> /etc/rc.conf << ++EOS
# Disable Send Mail
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"

# NTP
ntpdate_enable="YES"
ntpdate_hosts="ntp.jst.mfeed.ad.jp"
ntpd_enable="YES"

# X Window System & VMWare tools
dbus_enable="YES"
hald_enable="YES"
avahi_daemon_enable="YES"
avahi_dnsconfd_enable="YES"
slim_enable="YES"
vmware_guest_vmblock_enable="YES"
vmware_guest_vmhgfs_enable="YES"
vmware_guest_vmmemctl_enable="YES"
vmware_guest_vmxnet_enable="YES"
vmware_guestd_enable="YES"
++EOS

cat >> /etc/sysctl.conf << ++EOS
kern.maxfiles=65536
kern.ipc.shm_allow_removed=1
++EOS

cat >> /usr/local/etc/slim.conf << ++EOS
focus_password      yes
default_user        $USER
auto_login          yes
++EOS

sudo -u $USER cat >> /home/$USER/.xinitrc << ++EOS
export LANG=ja_JP.UTF-8
vmware-user-suid-wrapper &
exec mate-session
++EOS


### USER SETTINGS ###
cat <<++EOS | xargs pkg install
  firefox firefox-i18n
  chromium
  bash git zsh gnuls gawk ja-nkf
  qjail
  i386-wine
++EOS

qjail install -h ftp3.jp.freebsd.org

### SETUP END ###
reboot