Guest User

live

a guest
May 1st, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.14 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. source /opt/livecd/options.conf
  4. source /opt/livecd/functions
  5.  
  6. CONSOLEFONT="$(kernel_cmdline vconsole.font)"
  7. CONSOLEMAP="$(kernel_cmdline vconsole.font.map)"
  8. PACMAN_LNG="pacman --config /opt/livecd/pacman-lng.conf --noconfirm --noprogressbar"
  9. arch=$(uname -m)
  10. _kernver=$(uname -r)
  11. EXTRAMODULES=extramodules-${_kernver%.*}-MANJARO
  12.  
  13. echo "update fstab for swap" > /tmp/livecd.log
  14.  
  15. ## Systemd should do it
  16. # scan_swap
  17. swapdev="$(fdisk -l 2>/dev/null | grep swap | cut -d' ' -f1)"
  18. if [ -e "${swapdev}" ]; then
  19. swapon ${swapdev}
  20. echo "${swapdev} swap swap defaults 0 0 #configured by manjaroiso" >>/etc/fstab
  21. fi
  22.  
  23. echo "set locale" >> /tmp/livecd.log
  24.  
  25. # set_locale
  26. set_locale
  27. locale-gen
  28.  
  29. echo "configure alsa" >> /tmp/livecd.log
  30.  
  31. # configure alsa
  32. set_alsa
  33.  
  34. # configure pulse
  35. if [ -e "/usr/bin/pulseaudio-ctl" ] ; then
  36. pulseaudio-ctl normal
  37. fi
  38.  
  39. # save settings
  40. alsactl -f /etc/asound.state store &>/dev/null
  41.  
  42. echo "enable default mirror" >> /tmp/livecd.log
  43.  
  44. # enable default mirror
  45. #cp -f /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
  46. #if [ ! -z "$ping_check" ] ; then
  47. # pacman-mirrors -g &>/dev/null
  48. #fi
  49.  
  50. echo "configure system" >> /tmp/livecd.log
  51.  
  52. # add BROWSER var
  53. echo "BROWSER=/usr/bin/xdg-open" >> /etc/environment
  54. echo "BROWSER=/usr/bin/xdg-open" >> /etc/skel/.bashrc
  55. echo "BROWSER=/usr/bin/xdg-open" >> /etc/profile
  56. # add TERM var
  57. if [ -e "/usr/bin/mate-session" ] ; then
  58. echo "TERM=mate-terminal" >> /etc/environment
  59. echo "TERM=mate-terminal" >> /etc/profile
  60. fi
  61.  
  62. ## FIXME - Workaround to launch mate-terminal
  63. if [ -e "/usr/bin/mate-session" ] ; then
  64. sed -i -e "s~^.*Exec=.*~Exec=mate-terminal -e 'sudo setup'~" "/etc/skel/Desktop/Manjaro CLI Installer.desktop"
  65. sed -i -e "s~^.*Terminal=.*~Terminal=false~" "/etc/skel/Desktop/Manjaro CLI Installer.desktop"
  66. fi
  67.  
  68. echo "configure user" >> /tmp/livecd.log
  69.  
  70. # do_makeuser
  71. addgroups="video,audio,power,disk,storage,optical,network,lp,scanner"
  72. useradd -m -p "" -g users -G $addgroups ${username}
  73. sed -i "s#${username}.*#${username}:\$1\$uYIrxnwJ\$a5wTa84YxxYmD.sKX/Lll1:14942:0:99999:7:::#" /etc/shadow
  74. echo "Icon=/var/lib/AccountsService/icons/${username}.png" >> /var/lib/AccountsService/users/${username}
  75.  
  76. # do_configsforroot
  77. cp -a /etc/skel/. /root/
  78.  
  79. echo "configure display managers" >> /tmp/livecd.log
  80.  
  81. # do_setuplightdm
  82. if [ -e "/usr/bin/lightdm" ] ; then
  83. mkdir -p /run/lightdm > /dev/null
  84. getent group lightdm > /dev/null 2>&1 || groupadd -g 620 lightdm
  85. getent passwd lightdm > /dev/null 2>&1 || useradd -c 'LightDM Display Manager' -u 620 -g lightdm -d /var/run/lightdm -s /usr/bin/nologin lightdm
  86. passwd -l lightdm > /dev/null
  87. chown -R lightdm:lightdm /var/run/lightdm > /dev/null
  88. if [ -e "/usr/bin/startxfce4" ] ; then
  89. sed -i -e 's/^.*user-session=.*/user-session=xfce/' /etc/lightdm/lightdm.conf
  90. ln -s /usr/lib/lightdm/lightdm/gdmflexiserver /usr/bin/gdmflexiserver
  91. fi
  92. sed -i -e "s/^.*autologin-user=.*/autologin-user=${username}/" /etc/lightdm/lightdm.conf
  93. sed -i -e 's/^.*autologin-user-timeout=.*/autologin-user-timeout=0/' /etc/lightdm/lightdm.conf
  94. groupadd autologin
  95. gpasswd -a ${username} autologin
  96. chmod +r /etc/lightdm/lightdm.conf
  97. # livecd fix
  98. systemd-tmpfiles --create /usr/lib/tmpfiles.d/lightdm.conf
  99. /usr/bin/systemd-tmpfiles --create --remove
  100. fi
  101.  
  102. # do_setupkdm
  103. if [ -e "/usr/share/config/kdm/kdmrc" ] ; then
  104. getent group kdm >/dev/null 2>&1 || groupadd -g 135 kdm &>/dev/null
  105. getent passwd kdm >/dev/null 2>&1 || useradd -u 135 -g kdm -d /var/lib/kdm -s /bin/false -r -M kdm &>/dev/null
  106. chown -R 135:135 var/lib/kdm &>/dev/null
  107. xdg-icon-resource forceupdate --theme hicolor &> /dev/null
  108. if [ -e "/usr/bin/update-desktop-database" ] ; then
  109. update-desktop-database -q
  110. fi
  111. sed -i -e "s/^.*AutoLoginUser=.*/AutoLoginUser=${username}/" /usr/share/config/kdm/kdmrc
  112. sed -i -e "s/^.*AutoLoginPass=.*/AutoLoginPass=${username}/" /usr/share/config/kdm/kdmrc
  113. fi
  114.  
  115. # do_setupgdm
  116. if [ -e "/usr/bin/gdm" ] ; then
  117. getent group gdm >/dev/null 2>&1 || groupadd -g 120 gdm
  118. getent passwd gdm > /dev/null 2>&1 || usr/bin/useradd -c 'Gnome Display Manager' -u 120 -g gdm -d /var/lib/gdm -s /usr/bin/nologin gdm
  119. passwd -l gdm > /dev/null
  120. chown -R gdm:gdm /var/lib/gdm &> /dev/null
  121. if [ -d "/var/lib/AccountsService/users" ] ; then
  122. echo "[User]" > /var/lib/AccountsService/users/gdm
  123. if [ -e "/usr/bin/startxfce4" ] ; then
  124. echo "XSession=xfce" >> /var/lib/AccountsService/users/gdm
  125. fi
  126. if [ -e "/usr/bin/cinnamon-session" ] ; then
  127. echo "XSession=cinnamon" >> /var/lib/AccountsService/users/gdm
  128. fi
  129. if [ -e "/usr/bin/mate-session" ] ; then
  130. echo "XSession=mate" >> /var/lib/AccountsService/users/gdm
  131. fi
  132. if [ -e "/usr/bin/enlightenment_start" ] ; then
  133. echo "XSession=enlightenment" >> /var/lib/AccountsService/users/gdm
  134. fi
  135. if [ -e "/usr/bin/openbox-session" ] ; then
  136. echo "XSession=openbox" >> /var/lib/AccountsService/users/gdm
  137. fi
  138. if [ -e "/usr/bin/lxsession" ] ; then
  139. echo "XSession=LXDE" >> /var/lib/AccountsService/users/gdm
  140. fi
  141. echo "Icon=" >> /var/lib/AccountsService/users/gdm
  142. fi
  143. fi
  144.  
  145. # do_setupmdm
  146. if [ -e "/usr/bin/mdm" ] ; then
  147. getent group mdm >/dev/null 2>&1 || groupadd -g 128 mdm
  148. getent passwd mdm >/dev/null 2>&1 || usr/bin/useradd -c 'Linux Mint Display Manager' -u 128 -g mdm -d /var/lib/mdm -s /usr/bin/nologin mdm
  149. passwd -l mdm > /dev/null
  150. chown root:mdm /var/lib/mdm > /dev/null
  151. chmod 1770 /var/lib/mdm > /dev/null
  152. if [ -e "/usr/bin/startxfce4" ] ; then
  153. sed -i 's|default.desktop|xfce.desktop|g' /etc/mdm/custom.conf
  154. fi
  155. if [ -e "/usr/bin/cinnamon-session" ] ; then
  156. sed -i 's|default.desktop|cinnamon.desktop|g' /etc/mdm/custom.conf
  157. fi
  158. if [ -e "/usr/bin/openbox-session" ] ; then
  159. sed -i 's|default.desktop|openbox.desktop|g' /etc/mdm/custom.conf
  160. fi
  161. if [ -e "/usr/bin/mate-session" ] ; then
  162. sed -i 's|default.desktop|mate.desktop|g' /etc/mdm/custom.conf
  163. fi
  164. if [ -e "/usr/bin/lxsession" ] ; then
  165. sed -i 's|default.desktop|LXDE.desktop|g' /etc/mdm/custom.conf
  166. fi
  167. if [ -e "/usr/bin/enlightenment_start" ] ; then
  168. sed -i 's|default.desktop|enlightenment.desktop|g' /etc/mdm/custom.conf
  169. fi
  170. fi
  171.  
  172. # do_setupsddm
  173. if [ -e "/usr/bin/sddm" ] ; then
  174. sed -i -e "s|^.*LastUser=.*|LastUser=${username}|" /etc/sddm.conf
  175. sed -i -e "s|^.*AutoUser=.*|AutoUser=${username}|" /etc/sddm.conf
  176. if [ -e "/usr/bin/startxfce4" ] ; then
  177. sed -i -e 's|^.*LastSession=.*|LastSession=xfce.desktop|' /etc/sddm.conf
  178. fi
  179. if [ -e "/usr/bin/cinnamon-session" ] ; then
  180. sed -i -e 's|^.*LastSession=.*|LastSession=cinnamon.desktop|' /etc/sddm.conf
  181. fi
  182. if [ -e "/usr/bin/openbox-session" ] ; then
  183. sed -i -e 's|^.*LastSession=.*|LastSession=openbox.desktop|' /etc/sddm.conf
  184. fi
  185. if [ -e "/usr/bin/mate-session" ] ; then
  186. sed -i -e 's|^.*LastSession=.*|LastSession=mate.desktop|' /etc/sddm.conf
  187. fi
  188. if [ -e "/usr/bin/lxsession" ] ; then
  189. sed -i -e 's|^.*LastSession=.*|LastSession=LXDE.desktop|' /etc/sddm.conf
  190. fi
  191. if [ -e "/usr/bin/enlightenment_start" ] ; then
  192. sed -i -e 's|^.*LastSession=.*|LastSession=enlightenment.desktop|' /etc/sddm.conf
  193. fi
  194. fi
  195.  
  196. # do_setuplxdm
  197. if [ -e "/usr/bin/lxdm" ] ; then
  198. if [ -z "`getent group "lxdm" 2> /dev/null`" ]; then
  199. groupadd --system lxdm > /dev/null
  200. fi
  201. sed -i -e "s/^.*autologin=.*/autologin=${username}/" /etc/lxdm/lxdm.conf
  202. if [ -e "/usr/bin/startxfce4" ] ; then
  203. sed -i -e 's|^.*session=.*|session=/usr/bin/startxfce4|' /etc/lxdm/lxdm.conf
  204. fi
  205. if [ -e "/usr/bin/cinnamon-session" ] ; then
  206. sed -i -e 's|^.*session=.*|session=/usr/bin/cinnamon-session|' /etc/lxdm/lxdm.conf
  207. fi
  208. if [ -e "/usr/bin/mate-session" ] ; then
  209. sed -i -e 's|^.*session=.*|session=/usr/bin/mate-session|' /etc/lxdm/lxdm.conf
  210. fi
  211. if [ -e "/usr/bin/enlightenment_start" ] ; then
  212. sed -i -e 's|^.*session=.*|session=/usr/bin/enlightenment_start|' /etc/lxdm/lxdm.conf
  213. fi
  214. if [ -e "/usr/bin/openbox-session" ] ; then
  215. sed -i -e 's|^.*session=.*|session=/usr/bin/openbox-session|' /etc/lxdm/lxdm.conf
  216. fi
  217. if [ -e "/usr/bin/lxsession" ] ; then
  218. sed -i -e 's|^.*session=.*|session=/usr/bin/lxsession|' /etc/lxdm/lxdm.conf
  219. fi
  220. chgrp -R lxdm /var/lib/lxdm > /dev/null
  221. chgrp lxdm /etc/lxdm/lxdm.conf > /dev/null
  222. chmod +r /etc/lxdm/lxdm.conf > /dev/null
  223. fi
  224.  
  225. echo "configure sudoers" >> /tmp/livecd.log
  226.  
  227. # do_fix_perms
  228. chown root:root /etc/sudoers
  229. sed -i -e 's|# %wheel ALL=(ALL) ALL|%wheel ALL=(ALL) ALL|g' /etc/sudoers
  230. chmod 440 /etc/sudoers
  231.  
  232. echo "configure applications" >> /tmp/livecd.log
  233.  
  234. # fix_gnome_apps
  235. glib-compile-schemas /usr/share/glib-2.0/schemas
  236. gtk-update-icon-cache -q -t -f /usr/share/icons/hicolor
  237. if [ -e "/usr/bin/dconf" ] ; then
  238. dconf update
  239. fi
  240. if [ -e "/usr/bin/gnome-keyring-daemon" ] ; then
  241. setcap cap_ipc_lock=ep /usr/bin/gnome-keyring-daemon &> /dev/null
  242. fi
  243.  
  244. # configurate pacman
  245. pacman-key --init
  246. pacman-key --populate archlinux manjaro
  247.  
  248. # fix_ping_installation
  249. setcap cap_net_raw=ep /usr/bin/ping &> /dev/null
  250. setcap cap_net_raw=ep /usr/bin/ping6 &> /dev/null
  251.  
  252. # installing localization packages
  253. if [ -e "/bootmnt/${install_dir}/${arch}/lng-image.sqfs" ] ; then
  254. echo "install translation packages" >> /tmp/livecd.log
  255. _configure_translation_pkgs
  256. ${PACMAN_LNG} -Sy
  257. if [ -e "/bootmnt/${install_dir}/${arch}/kde-image.sqfs" ] ; then
  258. ${PACMAN_LNG} -S ${KDE_LNG_INST} &> /dev/null
  259. fi
  260. if [ -e "/usr/bin/firefox" ] ; then
  261. ${PACMAN_LNG} -S ${FIREFOX_LNG_INST} &> /dev/null
  262. fi
  263. if [ -e "/usr/bin/thunderbird" ] ; then
  264. ${PACMAN_LNG} -S ${THUNDER_LNG_INST} &> /dev/null
  265. fi
  266. if [ -e "/usr/bin/libreoffice" ] ; then
  267. ${PACMAN_LNG} -S ${LIBRE_LNG_INST} &> /dev/null
  268. fi
  269. if [ -e "/usr/bin/hunspell" ] ; then
  270. ${PACMAN_LNG} -S ${HUNSPELL_LNG_INST} &> /dev/null
  271. fi
  272. fi
  273.  
  274. # set unique machine-id
  275. dbus-uuidgen --ensure=/etc/machine-id
  276. dbus-uuidgen --ensure=/var/lib/dbus/machine-id
  277.  
  278. echo "configure keyboard" >> /tmp/livecd.log
  279.  
  280. # load keys
  281. keyboardctl --setup
  282.  
  283. # depmod extramodules
  284. depmod $(cat /usr/lib/modules/$EXTRAMODULES/version)
  285.  
  286. # check if we are running inside a virtual machine and unistall kalu
  287. DESTDIR="/"
  288. if [ -e "/usr/bin/kalu" ] ; then
  289. _rm_kalu
  290. fi
  291.  
  292. if [ -e "/etc/live-installer/install.conf" ] ; then
  293. echo "configure live-installer" >> /tmp/livecd.log
  294. _conf_file="/etc/live-installer/install.conf"
  295. fi
  296. if [ -e "/etc/thus.conf" ] ; then
  297. echo "configure thus" >> /tmp/livecd.log
  298. _conf_file="/etc/thus.conf"
  299. fi
  300.  
  301. if [ -e "$_conf_file" ] ; then
  302. sed -i "s|_root-image_|/bootmnt/${install_dir}/_ARCH_/root-image.sqfs|g" $_conf_file
  303. sed -i "s|_kernel_|$manjaro_kernel|g" $_conf_file
  304. release=$(cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d= -f2)
  305. sed -i "s|_version_|$release|g" $_conf_file
  306.  
  307. if [ -e "/bootmnt/${install_dir}/${arch}/xfce-image.sqfs" ] ; then
  308. sed -i "s|_desktop_|/bootmnt/${install_dir}/_ARCH_/xfce-image.sqfs|g" $_conf_file
  309. sed -i "s|_title_|Manjaro XFCE Edition|g" $_conf_file
  310. fi
  311. if [ -e "/bootmnt/${install_dir}/${arch}/gnome-image.sqfs" ] ; then
  312. sed -i "s|_desktop_|/bootmnt/${install_dir}/_ARCH_/gnome-image.sqfs|g" $_conf_file
  313. sed -i "s|_title_|Manjaro Gnome Edition|g" $_conf_file
  314. fi
  315. if [ -e "/bootmnt/${install_dir}/${arch}/cinnamon-image.sqfs" ] ; then
  316. sed -i "s|_desktop_|/bootmnt/${install_dir}/_ARCH_/cinnamon-image.sqfs|g" $_conf_file
  317. sed -i "s|_title_|Manjaro Cinnamon Edition|g" $_conf_file
  318. fi
  319. if [ -e "/bootmnt/${install_dir}/${arch}/openbox-image.sqfs" ] ; then
  320. sed -i "s|_desktop_|/bootmnt/${install_dir}/_ARCH_/openbox-image.sqfs|g" $_conf_file
  321. sed -i "s|_title_|Manjaro Openbox Edition|g" $_conf_file
  322. fi
  323. if [ -e "/bootmnt/${install_dir}/${arch}/mate-image.sqfs" ] ; then
  324. sed -i "s|_desktop_|/bootmnt/${install_dir}/_ARCH_/mate-image.sqfs|g" $_conf_file
  325. sed -i "s|_title_|Manjaro MATE Edition|g" $_conf_file
  326. fi
  327. if [ -e "/bootmnt/${install_dir}/${arch}/kde-image.sqfs" ] ; then
  328. sed -i "s|_desktop_|/bootmnt/${install_dir}/_ARCH_/kde-image.sqfs|g" $_conf_file
  329. sed -i "s|_title_|Manjaro KDE Edition|g" $_conf_file
  330. fi
  331. if [ -e "/bootmnt/${install_dir}/${arch}/lxde-image.sqfs" ] ; then
  332. sed -i "s|_desktop_|/bootmnt/${install_dir}/_ARCH_/lxde-image.sqfs|g" $_conf_file
  333. sed -i "s|_title_|Manjaro LXDE Edition|g" $_conf_file
  334. fi
  335. if [ -e "/bootmnt/${install_dir}/${arch}/enlightenment-image.sqfs" ] ; then
  336. sed -i "s|_desktop_|/bootmnt/${install_dir}/_ARCH_/enlightenment-image.sqfs|g" $_conf_file
  337. sed -i "s|_title_|Manjaro Enlightenment Edition|g" $_conf_file
  338. fi
  339. if [ -e "/bootmnt/${install_dir}/${arch}/custom-image.sqfs" ] ; then
  340. sed -i "s|_desktop_|/bootmnt/${install_dir}/_ARCH_/custom-image.sqfs|g" $_conf_file
  341. sed -i "s|_title_|Manjaro Custom Edition|g" $_conf_file
  342. fi
  343. if [ "${arch}" == "i686" ] ; then
  344. sed -i "s|_ARCH_|i686|g" $_conf_file
  345. else
  346. sed -i "s|_ARCH_|x86_64|g" $_conf_file
  347. fi
  348. fi
Add Comment
Please, Sign In to add comment