init_rootfs.sh 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. if [ -z $1 ];then
  2. echo "kokdizin parametresi eksik!"
  3. exit 1
  4. else
  5. ROOTDIR=$1
  6. fi
  7. [ ! -d $ROOTDIR ] && mkdir -pv $ROOTDIR
  8. mkdir -pv $ROOTDIR/{boot,etc/{opt,sysconfig},home,mnt,opt}
  9. mkdir -pv $ROOTDIR/{media/{floppy,cdrom},srv,var}
  10. install -dv -m 0750 $ROOTDIR/root
  11. install -dv -m 1777 $ROOTDIR/tmp $ROOTDIR/var/tmp
  12. mkdir -pv $ROOTDIR/usr/{,local/}{bin,include,lib,lib/firmware,src}
  13. mkdir -pv $ROOTDIR/usr/{,local/}share/{color,dict,doc,info,locale,man}
  14. mkdir -v $ROOTDIR/usr/{,local/}share/{misc,terminfo,zoneinfo}
  15. mkdir -pv $ROOTDIR/usr/{,local/}share/man/man{1..8}
  16. ln -sf /usr/bin $ROOTDIR/bin
  17. ln -sf /usr/bin $ROOTDIR/usr/sbin
  18. ln -sf /usr/bin $ROOTDIR/sbin
  19. ln -sf /usr/lib $ROOTDIR/lib
  20. ln -sf /usr/lib $ROOTDIR/lib64
  21. ln -sf /usr/lib $ROOTDIR/usr/lib64
  22. mkdir -v $ROOTDIR/var/{log,mail,spool}
  23. ln -sv /run $ROOTDIR/var/run
  24. ln -sv /run/lock $ROOTDIR/var/lock
  25. mkdir -pv $ROOTDIR/var/{opt,cache,lib/{color,misc,locate},local}
  26. install -vdm755 $ROOTDIR/usr/lib/pkgconfig
  27. ln -sv /proc/self/mounts $ROOTDIR/etc/mtab
  28. cat > $ROOTDIR/etc/fstab << "EOF"
  29. # Static information about the filesystems.
  30. # See fstab(5) for details.
  31. # <file system> <dir> <type> <options> <dump> <pass>
  32. EOF
  33. cat > $ROOTDIR/etc/issue << "EOF"
  34. Milis Linux \r (\l)
  35. EOF
  36. cat > $ROOTDIR/etc/lsb-release << "EOF"
  37. DISTRIB_ID="Milis Linux"
  38. DISTRIB_RELEASE="2.0"
  39. DISTRIB_CODENAME="HAN"
  40. DISTRIB_DESCRIPTION="Milis Linux Operating System"
  41. EOF
  42. cat > $ROOTDIR/etc/passwd << "EOF"
  43. root:x:0:0:root:/root:/bin/bash
  44. bin:x:1:1:bin:/dev/null:/bin/false
  45. daemon:x:6:6:Daemon User:/dev/null:/bin/false
  46. messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
  47. nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
  48. EOF
  49. cat > $ROOTDIR/etc/shadow << "EOF"
  50. root:JINC7Qk9605P2:17405:0:99999:7:::
  51. bin:x:17367:0:99999:7:::
  52. daemon:x:17367:0:99999:7:::
  53. messagebus:x:17367:0:99999:7:::
  54. nobody:x:17367:0:99999:7:::
  55. EOF
  56. cat > $ROOTDIR/etc/gshadow << "EOF"
  57. root:x::
  58. bin:x::
  59. sys:x::
  60. kmem:x::
  61. tape:x::
  62. tty:x::
  63. daemon:x::
  64. floppy:x::
  65. disk:x::
  66. lp:x::
  67. dialout:x::
  68. audio:x::
  69. video:x::
  70. utmp:x::
  71. usb:x::
  72. cdrom:x::
  73. adm:x::
  74. messagebus:x::
  75. input:x::
  76. mail:x::
  77. kvm:x::
  78. wheel:x::
  79. nogroup:x::
  80. users:x::
  81. EOF
  82. chmod 400 $ROOTDIR/etc/shadow
  83. chmod 400 $ROOTDIR/etc/gshadow
  84. cat > $ROOTDIR/etc/group << "EOF"
  85. root:x:0:
  86. bin:x:1:daemon
  87. sys:x:2:
  88. kmem:x:3:
  89. tape:x:4:
  90. tty:x:5:
  91. daemon:x:6:
  92. floppy:x:7:
  93. disk:x:8:
  94. lp:x:9:
  95. dialout:x:10:
  96. audio:x:11:
  97. video:x:12:
  98. utmp:x:13:
  99. usb:x:14:
  100. cdrom:x:15:
  101. adm:x:16:
  102. messagebus:x:18:
  103. input:x:24:
  104. mail:x:34:
  105. kvm:x:61:
  106. wheel:x:97:
  107. nogroup:x:99:
  108. users:x:999:
  109. EOF
  110. # profil ayarları
  111. cat > $ROOTDIR/etc/profile << "EOF"
  112. # /etc/profile
  113. # Set our umask
  114. umask 022
  115. # Append our default paths
  116. appendpath () {
  117. case ":$PATH:" in
  118. *:"$1":*)
  119. ;;
  120. *)
  121. PATH="${PATH:+$PATH:}$1"
  122. esac
  123. }
  124. appendpath '/usr/local/sbin'
  125. appendpath '/usr/local/bin'
  126. appendpath '/usr/bin'
  127. appendpath '/usr/milis/bin'
  128. appendpath '/usr/milis/mps/bin'
  129. unset appendpath
  130. export PATH
  131. # Load profiles from /etc/profile.d
  132. if test -d /etc/profile.d/; then
  133. for profile in /etc/profile.d/*.sh; do
  134. test -r "$profile" && . "$profile"
  135. done
  136. unset profile
  137. fi
  138. # Source global bash config
  139. if test "$PS1" && test "$BASH" && test -z ${POSIXLY_CORRECT+x} && test -r /etc/bash.bashrc; then
  140. . /etc/bash.bashrc
  141. fi
  142. # Termcap is outdated, old, and crusty, kill it.
  143. unset TERMCAP
  144. # Man is much better than us at figuring this out
  145. unset MANPATH
  146. EOF
  147. mkdir -p $ROOTDIR/etc/profile.d
  148. cat > $ROOTDIR/etc/profile.d/bash_completion.sh << "EOF"
  149. # Begin /etc/profile.d/bash_completion.sh
  150. # Import bash completion scripts
  151. # If the bash-completion package is installed, use its configuration instead
  152. if [ -f /usr/share/bash-completion/bash_completion ]; then
  153. # Check for interactive bash and that we haven't already been sourced.
  154. if [ -n "${BASH_VERSION-}" -a -n "${PS1-}" -a -z "${BASH_COMPLETION_VERSINFO-}" ]; then
  155. # Check for recent enough version of bash.
  156. if [ ${BASH_VERSINFO[0]} -gt 4 ] || \
  157. [ ${BASH_VERSINFO[0]} -eq 4 -a ${BASH_VERSINFO[1]} -ge 1 ]; then
  158. [ -r "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion" ] && \
  159. . "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion"
  160. if shopt -q progcomp && [ -r /usr/share/bash-completion/bash_completion ]; then
  161. # Source completion code.
  162. . /usr/share/bash-completion/bash_completion
  163. fi
  164. fi
  165. fi
  166. else
  167. # bash-completions are not installed, use only bash completion directory
  168. if shopt -q progcomp; then
  169. for script in /etc/bash_completion.d/* ; do
  170. if [ -r $script ] ; then
  171. . $script
  172. fi
  173. done
  174. fi
  175. fi
  176. # End /etc/profile.d/bash_completion.sh
  177. EOF
  178. cat > $ROOTDIR/etc/profile.d/dircolors.sh << "EOF"
  179. # Setup for /bin/ls and /bin/grep to support color, the alias is in /etc/bashrc.
  180. if [ -f "/etc/dircolors" ] ; then
  181. eval $(dircolors -b /etc/dircolors)
  182. fi
  183. if [ -f "$HOME/.dircolors" ] ; then
  184. eval $(dircolors -b $HOME/.dircolors)
  185. fi
  186. alias ls='ls --color=auto'
  187. alias grep='grep --color=auto'
  188. EOF
  189. cat > $ROOTDIR/etc/profile.d/readline.sh << "EOF"
  190. # Setup the INPUTRC environment variable.
  191. if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ] ; then
  192. INPUTRC=/etc/inputrc
  193. fi
  194. export INPUTRC
  195. EOF
  196. cat > $ROOTDIR/etc/profile.d/umask.sh << "EOF"
  197. # By default, the umask should be set.
  198. if [ "$(id -gn)" = "$(id -un)" -a $EUID -gt 99 ] ; then
  199. umask 002
  200. else
  201. umask 022
  202. fi
  203. EOF
  204. cat > $ROOTDIR/etc/profile.d/i18n.sh << "EOF"
  205. # Set up i18n variables
  206. export LANG=tr_TR.UTF-8
  207. EOF
  208. # saat ayarları
  209. cat > $ROOTDIR/etc/sysconfig/clock << "EOF"
  210. # Begin /etc/sysconfig/clock
  211. UTC=2
  212. # Set this to any options you might need to give to hwclock,
  213. # such as machine hardware clock type for Alphas.
  214. CLOCKPARAMS=
  215. # End /etc/sysconfig/clock
  216. EOF
  217. # mouse ayarları
  218. cat > $ROOTDIR/etc/sysconfig/mouse << "EOF"
  219. MDEVICE="/dev/input/mice"
  220. PROTOCOL="imps2"
  221. EOF
  222. # ağ ayarları
  223. cat > $ROOTDIR/etc/sysconfig/template.ifconfig.eth0 << "EOF"
  224. ONBOOT=yes
  225. IFACE=eth0
  226. SERVICE=ipv4-static
  227. IP=192.168.1.2
  228. GATEWAY=192.168.1.1
  229. PREFIX=24
  230. BROADCAST=192.168.1.255
  231. EOF
  232. cat > $ROOTDIR/etc/resolv.conf << "EOF"
  233. # Begin /etc/resolv.conf
  234. domain <Your Domain Name>
  235. nameserver <IP address of your primary nameserver>
  236. nameserver <IP address of your secondary nameserver>
  237. # End /etc/resolv.conf
  238. EOF
  239. cat > $ROOTDIR/etc/hosts << "EOF"
  240. # Begin /etc/hosts
  241. 127.0.0.1 localhost
  242. ::1 localhost ip6-localhost ip6-loopback
  243. ff02::1 ip6-allnodes
  244. ff02::2 ip6-allrouters
  245. # End /etc/hosts
  246. EOF
  247. echo "milis" > $ROOTDIR/etc/hostname
  248. touch $ROOTDIR/var/log/{btmp,lastlog,faillog,wtmp}
  249. chgrp -v utmp $ROOTDIR/var/log/lastlog
  250. chmod -v 664 $ROOTDIR/var/log/lastlog
  251. chmod -v 600 $ROOTDIR/var/log/btmp
  252. # talimatname yolu
  253. mkdir -p $ROOTDIR/usr/milis/talimatname
  254. # mps
  255. #mkdir -p $ROOTDIR/var/lib/mps/db
  256. #mkdir -p $ROOTDIR/var/log/mps/kur
  257. #mkdir -p $ROOTDIR/var/log/mps/sil