install-houaphan 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654
  1. #*******************************************************************************
  2. # Written by Thierry Nuttens
  3. # Copyright Thierry Nuttens 2010-2011-2012-2013-2014-2015-2016
  4. # Installation script for the NuTyX system
  5. # Based on LFS scripts
  6. #*******************************************************************************
  7. # Function - boot_mesg()
  8. #
  9. # Purpose: Sending information from bootup scripts to the console
  10. #
  11. # Inputs: $1 is the message
  12. # $2 is the colorcode for the console
  13. #
  14. # Outputs: Standard Output
  15. #
  16. # Dependencies: - sed for parsing strings.
  17. # - grep for counting string length.
  18. #
  19. # Todo:
  20. #*******************************************************************************
  21. boot_mesg() {
  22. local ECHOPARM=""
  23. while true
  24. do
  25. case "${1}" in
  26. -n)
  27. ECHOPARM=" -n "
  28. shift 1
  29. ;;
  30. -*)
  31. echo "Unknown Option: ${1}"
  32. return 1
  33. ;;
  34. *)
  35. break
  36. ;;
  37. esac
  38. done
  39. ## Figure out the length of what is to be printed to be used
  40. ## for warning messages.
  41. STRING_LENGTH=$((${#1} + 1))
  42. # Print the message to the screen
  43. ${ECHO} ${ECHOPARM} -e "${2}${1}"
  44. }
  45. boot_mesg_flush() {
  46. # Reset STRING_LENGTH for next message
  47. STRING_LENGTH="0"
  48. }
  49. boot_log() {
  50. # Left in for backwards compatibility
  51. :
  52. }
  53. echo_ok() {
  54. ${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${SUCCESS} OK ${BRACKET}]"
  55. ${ECHO} -e "${NORMAL}"
  56. boot_mesg_flush
  57. }
  58. echo_info() {
  59. ${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${INFO} INFO ${BRACKET}]"
  60. ${ECHO} -e "${NORMAL}"
  61. boot_mesg_flush
  62. }
  63. echo_failure() {
  64. ${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]"
  65. ${ECHO} -e "${NORMAL}"
  66. boot_mesg_flush
  67. }
  68. echo_warning() {
  69. ${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${WARNING} WARN ${BRACKET}]"
  70. ${ECHO} -e "${NORMAL}"
  71. boot_mesg_flush
  72. }
  73. print_error_msg() {
  74. echo_failure
  75. ERREUR="yes"
  76. # $i is inherited by the rc script
  77. boot_mesg -n " FAILURE:\n\n You should not read this error.\n\n" ${FAILURE}
  78. boot_mesg -n " It means something went wrong with the installation"
  79. boot_mesg -n " of ${i} "
  80. boot_mesg_flush
  81. boot_mesg -n " Thanks to inform us"
  82. boot_mesg -n " via the website http://www.nutyx.org."
  83. boot_mesg " Thanks again for your collaboration.\n"
  84. boot_mesg_flush
  85. boot_mesg -n "Press Enter to continue..." ${INFO}
  86. boot_mesg "" ${NORMAL}
  87. read ENTER
  88. end
  89. exit 1
  90. }
  91. #*******************************************************************************
  92. # Function - log_success_msg "message"
  93. #
  94. # Purpose: Print a success message
  95. #
  96. # Inputs: $@ - Message
  97. #
  98. # Outputs: Text output to screen
  99. #
  100. # Dependencies: echo
  101. #
  102. # Todo: logging
  103. #
  104. #*******************************************************************************
  105. log_success_msg() {
  106. ${ECHO} -n -e "${BOOTMESG_PREFIX}${@}"
  107. ${ECHO} -e "${SET_COL}""${BRACKET}""[""${SUCCESS}"" OK
  108. ""${BRACKET}""]""${NORMAL}"
  109. return 0
  110. }
  111. #*******************************************************************************
  112. # Function - log_failure_msg "message"
  113. #
  114. # Purpose: Print a failure message
  115. #
  116. # Inputs: $@ - Message
  117. #
  118. # Outputs: Text output to screen
  119. #
  120. # Dependencies: echo
  121. #
  122. # Todo: logging
  123. #
  124. #*******************************************************************************
  125. log_failure_msg() {
  126. ${ECHO} -n -e "${BOOTMESG_PREFIX}${@}"
  127. ${ECHO} -e "${SET_COL}""${BRACKET}""[""${FAILURE}"" FAIL
  128. ""${BRACKET}""]""${NORMAL}"
  129. return 0
  130. }
  131. #*******************************************************************************
  132. # Function - log_warning_msg "message"
  133. #
  134. # Purpose: print a warning message
  135. #
  136. # Inputs: $@ - Message
  137. #
  138. # Outputs: Text output to screen
  139. #
  140. # Dependencies: echo
  141. #
  142. # Todo: logging
  143. #
  144. #*******************************************************************************
  145. log_warning_msg() {
  146. ${ECHO} -n -e "${BOOTMESG_PREFIX}${@}"
  147. ${ECHO} -e "${SET_COL}""${BRACKET}""[""${WARNING}"" WARN
  148. ""${BRACKET}""]""${NORMAL}"
  149. return 0
  150. }
  151. #*******************************************************************************
  152. # Function - unmountall
  153. #
  154. # Purpose: unmount all the mounted disks and partitions
  155. #
  156. # Inputs: $1 the full path of the Distro
  157. #
  158. # Outputs: Standard Output
  159. #
  160. # Dependencies: chroot
  161. #
  162. #*******************************************************************************
  163. unmountall() {
  164. if [ -d "$DEPOT_CD/depot" ]; then
  165. umount ${{FOLDER}/${DEPOT}
  166. umount `cat /tmp/depot`
  167. fi
  168. umount ${FOLDER}/run
  169. umount ${FOLDER}/dev/pts
  170. umount ${FOLDER}/dev
  171. umount ${FOLDER}/proc
  172. umount ${FOLDER}/sys
  173. }
  174. #*******************************************************************************
  175. # Function - setup_chroot
  176. #
  177. # Purpose: Enter the NuTyX Distribution
  178. #
  179. # Inputs: $1 the full path of the Distro
  180. #
  181. # Outputs: Standard Output
  182. #
  183. # Dependencies: chroot
  184. #
  185. #*******************************************************************************
  186. setup_chroot() {
  187. cp /etc/resolv.conf ${FOLDER}/etc/resolv.conf
  188. mount --bind /dev ${FOLDER}/dev
  189. mount -t devpts devpts ${FOLDER}/dev/pts
  190. mount -t proc proc ${FOLDER}/proc
  191. mount -t sysfs sysfs ${FOLDER}/sys
  192. mount -t tmpfs tmpfs ${FOLDER}/run
  193. if [ -h ${FOLDER}/dev/shm ]; then
  194. mkdir -p ${FOLDER}/$(readlink ${FOLDER}/dev/shm)
  195. fi
  196. }
  197. enter_chroot() {
  198. echo "
  199. ******************************
  200. Chroot path: $DEVICE
  201. ******************************"
  202. chroot ${FOLDER} /usr/bin/env -i \
  203. HOME=/root \
  204. TERM="$TERM" \
  205. PS1='\u:\w\$ ' \
  206. /bin/bash --login
  207. }
  208. #*******************************************************************************
  209. # Function - install_pkg()
  210. #
  211. # Purpose: Install the selected package
  212. #
  213. # Inputs: $1 is the package
  214. # $2 is the group
  215. # $3 Option to install, normally nothing except for grub
  216. # Outputs: Standard Output
  217. #
  218. # Dependencies: - wget
  219. # - boot_mesg
  220. # - pkgadd
  221. # Todo:
  222. #*******************************************************************************
  223. install_pkg() {
  224. if $TMP/usr/bin/pkginfo -r $FOLDER -i| grep "^$1 " > /dev/null; then
  225. boot_mesg "$1 is already install on $DEVICE..."
  226. echo_info
  227. else
  228. packagefileToDownload=`getPackageName ${1}`
  229. boot_mesg "Downloading $1..."
  230. wget ${DEPOT_BASE}/${1}/$packagefileToDownload -O $TMP/$packagefileToDownload > /dev/null 2>&1
  231. echo_info
  232. # Installing the package
  233. $TMP/usr/bin/pkgadd -r $FOLDER -i $packagefileToDownload || print_error_msg
  234. echo_ok
  235. fi
  236. }
  237. #*******************************************************************************
  238. # Function Check_DiskSpace
  239. #
  240. # Purpose: Check the Available space after the using amont
  241. # Inputs: $1: Mount point
  242. # $2: Amount in Kbytes going to be used
  243. #
  244. # Return: status: 0 when ok
  245. # 1 not ok
  246. # Todo:
  247. #*******************************************************************************
  248. check_diskspace() {
  249. # df|grep "$1"|awk '{print $4}'
  250. let MinSize=$2+100
  251. let Amoung=`df|grep $FOLDER |awk '{print $(NF-2)}'`/1024 || exit 1
  252. let Amoung=$Amoung-$MinSize
  253. status="0"
  254. if [ $Amoung -lt 0 ]; then
  255. echo "Not enough space for the installation"
  256. echo_failure
  257. status="1"
  258. else
  259. echo "Space remind after install: $Amoung Mbytes"
  260. echo_info
  261. fi
  262. if [ $status == "1" ]; then
  263. check_availablespace $1
  264. echo "The installation needs $BaseInstall Mbytes minimum"
  265. end
  266. exit 1
  267. fi
  268. }
  269. #*******************************************************************************
  270. # Function check_availablespace
  271. #
  272. # Purpose: Printout the Available space on the Mount point
  273. #
  274. # Inputs: $1: Mount point
  275. #
  276. # Output: Standard Output
  277. #
  278. # Todo:
  279. #*******************************************************************************
  280. check_availablespace() {
  281. let TotAmoung=`df|grep "$1"|awk '{print $4}'`/1024 || exit 1
  282. echo "You have at the moment: ${TotAmoung} Mbytes on the destination disk"
  283. }
  284. error() {
  285. echo ""
  286. echo " $1"
  287. echo ""
  288. rm -rf $TMP
  289. exit 1
  290. }
  291. end() {
  292. if [ "$ERREUR" == "yes" ]; then
  293. if [ ! -f $TMP/depot ]; then
  294. rm -r ${FOLDER}/${DEPOT}
  295. boot_mesg "Cleaning up temporary files.."
  296. boot_mesg "Please correct and start again"
  297. fi
  298. fi
  299. cd ~
  300. unmountall $FOLDER > /dev/null 2>&1
  301. rm -rf $TMP
  302. }
  303. #****************************************************************************
  304. # Function expect
  305. #
  306. # Purpose: Check that the answer is nothing else then the supply
  307. # arguments
  308. # Inputs: $1: answer 1
  309. # $2: answer 2
  310. # $3: The question to ask
  311. #
  312. # Output: Standard Output
  313. #
  314. #****************************************************************************
  315. expect(){
  316. # echo -n "$3"
  317. # read answer
  318. while [ "$answer" != "o" ] && [ "$answer" != "n" ]; do
  319. echo -n "$3"
  320. read answer
  321. done
  322. }
  323. #****************************************************************************
  324. # Function getPackageName
  325. #
  326. # Purpose: Get the fullname of the package
  327. # directory
  328. # Inputs: $1 is the package name
  329. #
  330. # Output: fullname of the archive without url
  331. # something like: cpio1414074943i686.cards.tar.xz
  332. #****************************************************************************
  333. getPackageName() {
  334. local BUILD_DATE EXT HEAD
  335. wget ${DEPOT_BASE}/${1}/.PKGREPO -O $TMP/.PKGREPO > /dev/null 2>&1
  336. HEAD=`head -1 $TMP/.PKGREPO`
  337. if [ "${HEAD:10:1}" == "#" ]; then
  338. BUILD_DATE="`echo $HEAD|cut -d "#" -f1`"
  339. EXT="`echo $HEAD|cut -d "#" -f2`"
  340. echo "${1}${BUILD_DATE}${ARCH}${EXT}"
  341. fi
  342. }
  343. install_base() {
  344. for i in \
  345. nutyx acl attr bash bc binutils bzip2 coreutils curl \
  346. diffutils expat file findutils flex gcc gdbm \
  347. gettext glibc gmp gperf grep gzip inetutils kbd lzo \
  348. libarchive libcap libpipeline mpc mpfr ncurses openssl pam \
  349. procps-ng psmisc readline sed shadow util-linux xz zlib \
  350. cards
  351. do
  352. install_pkg "$i"
  353. done
  354. }
  355. generate_blfs_bootscripts() {
  356. [ -f ${FOLDER}/etc/${FOLDER}/etc/blfs-bootscripts ] && return
  357. [ ! -d ${FOLDER}/etc ] && mkdir -pv ${FOLDER}/etc
  358. echo "scripts=blfs-bootscripts
  359. scriptsversion=20150924" > ${FOLDER}/etc/blfs-bootscripts
  360. }
  361. generate_etc_bashrc() {
  362. local FILE
  363. FILE="bashrc"
  364. [ -f ${FOLDER}/etc/$FILE ] && return
  365. [ ! -d ${FOLDER}/etc ] && mkdir -pv ${FOLDER}/etc
  366. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  367. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  368. ${FOLDER}/etc/$FILE
  369. return
  370. fi
  371. cat > ${FOLDER}/etc/$FILE << "EOF"
  372. # Begin /etc/bashrc
  373. # Written for Beyond Linux From Scratch
  374. # by James Robertson <jameswrobertson@earthlink.net>
  375. # updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>
  376. # System wide aliases and functions.
  377. # System wide environment variables and startup programs should go into
  378. # /etc/profile. Personal environment variables and startup programs
  379. # should go into ~/.bash_profile. Personal aliases and functions should
  380. # go into ~/.bashrc
  381. # Provides a colored /bin/ls command. Used in conjunction with code in
  382. # /etc/profile.
  383. alias ls='ls --color=auto'
  384. # Provides prompt for non-login shells, specifically shells started
  385. # in the X environment. [Review the LFS archive thread titled
  386. # PS1 Environment Variable for a great case study behind this script
  387. # addendum.]
  388. NORMAL="\[\e[0m\]"
  389. RED="\[\e[1;31m\]"
  390. GREEN="\[\e[1;32m\]"
  391. WHITE="\[\e[1;37m\]"
  392. INFOMACHINE="`date +%H:%M` `uname -m` `uname -r` `whoami`@`uname -n`"
  393. prompt_command() {
  394. # Sauvegarde de la pos courante
  395. tput sc
  396. # Calcul de la largeur
  397. let backwash=$(tput cols)-$(echo $INFOMACHINE | wc -m)-2
  398. # Pos des curseurs à la position Y=0, X=longueur calculée
  399. tput cup 0 ${backwash}
  400. # Spécifie la couleur et la casse de la police
  401. tput setaf 4; tput bold
  402. # Affiche le chemin entre crochets
  403. echo -n "["
  404. # Specifie la couleur du chemin
  405. tput setaf 6
  406. # Affiche le chemin complet
  407. echo -n "$INFOMACHINE"
  408. tput setaf 4; tput bold
  409. # Affiche le crochet fermé
  410. echo -n "]"
  411. # Remet le curseur à sa place
  412. tput rc
  413. }
  414. PROMPT_COMMAND=prompt_command
  415. case $TERM in
  416. xterm|rxvt*)
  417. TITLEBAR='\[\033]0;\u@\h \007\]'
  418. ;;
  419. *)
  420. TITLEBAR=''
  421. ;;
  422. esac
  423. if [[ $EUID == 0 ]] ; then
  424. PS1="$TITLEBAR$RED\u [ $NORMAL\w$RED ]# $NORMAL"
  425. else
  426. PS1="$TITLEBAR$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
  427. fi
  428. # End /etc/bashrc
  429. EOF
  430. }
  431. generate_rc_site() {
  432. local FILE
  433. FILE="rc.site"
  434. [ -f ${FOLDER}/etc/sysconfig/$FILE ] && return
  435. [ ! -d ${FOLDER}/etc/sysconfig ] && mkdir -pv ${FOLDER}/etc/sysconfig
  436. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  437. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  438. ${FOLDER}/etc/sysconfig/$FILE
  439. return
  440. fi
  441. cat > ${FOLDER}/etc/sysconfig/$FILE << "EOF"
  442. # rc.site [20:15 i686 3.18.11-NuTyX-iso thierry@nutyx]
  443. # Optional parameters for boot scripts.
  444. # Distro Information
  445. # These values, if specified here, override the defaults
  446. #DISTRO="Linux From Scratch" # The distro name
  447. #DISTRO_CONTACT="lfs-dev@linuxfromscratch.org" # Bug report address
  448. #DISTRO_MINI="LFS" # Short name used in filenames for distro config
  449. # Define custom colors used in messages printed to the screen
  450. # Please consult `man console_codes` for more information
  451. # under the "ECMA-48 Set Graphics Rendition" section
  452. #
  453. # Warning: when switching from a 8bit to a 9bit font,
  454. # the linux console will reinterpret the bold (1;) to
  455. # the top 256 glyphs of the 9bit font. This does
  456. # not affect framebuffer consoles
  457. # These values, if specified here, override the defaults
  458. #BRACKET="\\033[1;34m" # Blue
  459. #FAILURE="\\033[1;31m" # Red
  460. #INFO="\\033[1;36m" # Cyan
  461. #NORMAL="\\033[0;39m" # Grey
  462. #SUCCESS="\\033[1;32m" # Green
  463. #WARNING="\\033[1;33m" # Yellow
  464. # Use a colored prefix
  465. # These values, if specified here, override the defaults
  466. #BMPREFIX=" "
  467. #SUCCESS_PREFIX="${SUCCESS} * ${NORMAL}"
  468. #FAILURE_PREFIX="${FAILURE}*****${NORMAL}"
  469. #WARNING_PREFIX="${WARNING} *** ${NORMAL}"
  470. # Interactive startup
  471. #IPROMPT="yes" # Whether to display the interactive boot prompt
  472. #itime="3" # The amount of time (in seconds) to display the prompt
  473. # The total length of the distro welcome string, without escape codes
  474. #wlen=$(echo "Welcome to ${DISTRO}" | wc -c )
  475. #welcome_message="Welcome to ${INFO}${DISTRO}${NORMAL}"
  476. # The total length of the interactive string, without escape codes
  477. #ilen=$(echo "Press 'I' to enter interactive startup" | wc -c )
  478. #i_message="Press '${FAILURE}I${NORMAL}' to enter interactive startup"
  479. # Set scripts to skip the file system check on reboot
  480. #FASTBOOT=yes
  481. # Skip reading from the console
  482. #HEADLESS=yes
  483. # Write out fsck progress if yes
  484. #VERBOSE_FSCK=no
  485. # Speed up boot without waiting for settle in udev
  486. #OMIT_UDEV_SETTLE=y
  487. # Speed up boot without waiting for settle in udev_retry
  488. #OMIT_UDEV_RETRY_SETTLE=yes
  489. # Skip cleaning /tmp if yes
  490. #SKIPTMPCLEAN=no
  491. # For setclock
  492. #UTC=1
  493. #CLOCKPARAMS=
  494. # For consolelog
  495. #LOGLEVEL=5
  496. # For network
  497. #HOSTNAME=mylfs
  498. # Delay between TERM and KILL signals at shutdown
  499. #KILLDELAY=3
  500. # Optional sysklogd parameters
  501. #SYSKLOGD_PARMS="-m 0"
  502. # Console parameters
  503. #UNICODE=1
  504. #KEYMAP="de-latin1"
  505. #KEYMAP_CORRECTIONS="euro2"
  506. #FONT="lat0-16 -m 8859-15"
  507. #LEGACY_CHARSET=
  508. EOF
  509. }
  510. generate_udev_retry() {
  511. local FILE
  512. FILE="udev_retry"
  513. [ -f ${FOLDER}/etc/sysconfig/$FILE ] && return
  514. [ ! -d ${FOLDER}/etc/sysconfig ] && mkdir -pv ${FOLDER}/etc/sysconfig
  515. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  516. cp /etc/sysconfig/$FILE \
  517. ${FOLDER}/etc/sysconfig/$FILE
  518. return
  519. fi
  520. cat > ${FOLDER}/etc/sysconfig/$FILE << "EOF"
  521. ########################################################################
  522. # Begin /etc/sysconfig/udev_retry
  523. #
  524. # Description : udev_retry script configuration
  525. #
  526. # Authors :
  527. #
  528. # Version : 00.00
  529. #
  530. # Notes : Each subsystem that may need to be re-triggered after mountfs
  531. # runs should be listed in this file. Probable subsystems to be
  532. # listed here are rtc (due to /var/lib/hwclock/adjtime) and sound
  533. # (due to both /var/lib/alsa/asound.state and /usr/sbin/alsactl).
  534. # Entries are whitespace-separated.
  535. ########################################################################
  536. rtc
  537. # End /etc/sysconfig/udev_retry
  538. EOF
  539. }
  540. generate_createfiles() {
  541. local FILE
  542. FILE="createfiles"
  543. [ -f ${FOLDER}/etc/sysconfig/$FILE ] && return
  544. [ ! -d ${FOLDER}/etc/sysconfig ] && mkdir -pv ${FOLDER}/etc/sysconfig
  545. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  546. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  547. ${FOLDER}/etc/sysconfig/$FILE
  548. return
  549. fi
  550. cat > ${FOLDER}/etc/sysconfig/$FILE << "EOF"
  551. ########################################################################
  552. # Begin /etc/sysconfig/createfiles
  553. #
  554. # Description : Createfiles script config file
  555. #
  556. # Authors :
  557. #
  558. # Version : 00.00
  559. #
  560. # Notes : The syntax of this file is as follows:
  561. # if type is equal to "file" or "dir"
  562. # <filename> <type> <permissions> <user> <group>
  563. # if type is equal to "dev"
  564. # <filename> <type> <permissions> <user> <group> <devtype>
  565. # <major> <minor>
  566. #
  567. # <filename> is the name of the file which is to be created
  568. # <type> is either file, dir, or dev.
  569. # file creates a new file
  570. # dir creates a new directory
  571. # dev creates a new device
  572. # <devtype> is either block, char or pipe
  573. # block creates a block device
  574. # char creates a character deivce
  575. # pipe creates a pipe, this will ignore the <major> and
  576. # <minor> fields
  577. # <major> and <minor> are the major and minor numbers used for
  578. # the device.
  579. ########################################################################
  580. # End /etc/sysconfig/createfiles
  581. EOF
  582. }
  583. generate_modules() {
  584. local FILE
  585. FILE="modules"
  586. [ -f ${FOLDER}/etc/sysconfig/$FILE ] && return
  587. [ ! -d ${FOLDER}/etc/sysconfig ] && mkdir -pv ${FOLDER}/etc/sysconfig
  588. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  589. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  590. ${FOLDER}/etc/sysconfig/$FILE
  591. return
  592. fi
  593. cat > ${FOLDER}/etc/sysconfig/$FILE << "EOF"
  594. ########################################################################
  595. # Begin /etc/sysconfig/modules
  596. #
  597. # Description : Module auto-loading configuration
  598. #
  599. # Authors :
  600. #
  601. # Version : 00.00
  602. #
  603. # Notes : The syntax of this file is as follows:
  604. # <module> [<arg1> <arg2> ...]
  605. #
  606. # Each module should be on its own line, and any options that you want
  607. # passed to the module should follow it. The line deliminator is either
  608. # a space or a tab.
  609. ########################################################################
  610. # End /etc/sysconfig/modules
  611. EOF
  612. }
  613. generate_mouse() {
  614. local FILE
  615. FILE="mouse"
  616. [ -f ${FOLDER}/etc/$FILE ] && return
  617. [ ! -d ${FOLDER}/etc/sysconfig ] && mkdir -pv ${FOLDER}/etc/sysconfig
  618. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  619. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  620. ${FOLDER}/etc/sysconfig/$FILE
  621. return
  622. fi
  623. cat > ${FOLDER}/etc/sysconfig/$FILE << "EOF"
  624. MDEVICE="/dev/input/mice"
  625. PROTOCOL="imps2"
  626. EOF
  627. }
  628. generate_inputrc() {
  629. local FILE
  630. FILE="inputrc"
  631. [ -f ${FOLDER}/etc/$FILE ] && return
  632. [ ! -d ${FOLDER}/etc ] && mkdir -pv ${FOLDER}/etc
  633. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  634. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  635. ${FOLDER}/etc/$FILE
  636. return
  637. fi
  638. cat > ${FOLDER}/etc/$FILE << "EOF"
  639. # Begin /etc/inputrc
  640. # Modified by Chris Lynn <roryo@roryo.dynup.net>
  641. # Allow the command prompt to wrap to the next line
  642. set horizontal-scroll-mode Off
  643. # Enable 8bit input
  644. set meta-flag On
  645. set input-meta On
  646. # Turns off 8th bit stripping
  647. set convert-meta Off
  648. # Keep the 8th bit for display
  649. set output-meta On
  650. # none, visible or audible
  651. set bell-style none
  652. # All of the following map the escape sequence of the value
  653. # contained in the 1st argument to the readline specific functions
  654. "\eOd": backward-word
  655. "\eOc": forward-word
  656. # for linux console
  657. "\e[1~": beginning-of-line
  658. "\e[4~": end-of-line
  659. "\e[5~": beginning-of-history
  660. "\e[6~": end-of-history
  661. "\e[3~": delete-char
  662. "\e[2~": quoted-insert
  663. # for xorg-term
  664. "\eOH": beginning-of-line
  665. "\eOF": end-of-line
  666. # for Konsole
  667. "\e[H": beginning-of-line
  668. "\e[F": end-of-line
  669. # End /etc/inputrc
  670. EOF
  671. }
  672. generate_hosts() {
  673. local FILE
  674. FILE="hosts"
  675. [ -f ${FOLDER}/etc/$FILE ] && return
  676. [ ! -d ${FOLDER}/etc ] && mkdir -pv ${FOLDER}/etc
  677. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  678. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  679. ${FOLDER}/etc/$FILE
  680. return
  681. fi
  682. cat > ${FOLDER}/etc/$FILE << "EOF"
  683. # Begin /etc/hosts
  684. 127.0.0.1 localhost.localdomain localhost
  685. 127.0.0.1 nutyx
  686. # End /etc/hosts
  687. EOF
  688. }
  689. generate_shells() {
  690. local FILE
  691. FILE="shells"
  692. [ -f ${FOLDER}/etc/$FILE ] && return
  693. [ ! -d ${FOLDER}/etc ] && mkdir -pv ${FOLDER}/etc
  694. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  695. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  696. ${FOLDER}/etc/$FILE
  697. return
  698. fi
  699. cat > ${FOLDER}/etc/$FILE << "EOF"
  700. # Begin /etc/shells
  701. /bin/sh
  702. /bin/bash
  703. # End /etc/shells
  704. EOF
  705. }
  706. generate_umask_sh() {
  707. local FILE
  708. FILE="umask.sh"
  709. [ -f ${FOLDER}/etc/profile.d/$FILE ] && return
  710. [ ! -d ${FOLDER}/etc/profile.d ] && mkdir -pv ${FOLDER}/etc/profile.d
  711. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  712. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  713. ${FOLDER}/etc/profile.d/$FILE
  714. return
  715. fi
  716. cat > ${FOLDER}/etc/profile.d/$FILE << "EOF"
  717. # By default we want the umask to get set.
  718. if [ "$(id -gn)" = "$(id -un)" -a $EUID -gt 99 ] ; then
  719. umask 002
  720. else
  721. umask 022
  722. fi
  723. EOF
  724. }
  725. generate_readline_sh() {
  726. local FILE
  727. FILE="readline.sh"
  728. [ -f ${FOLDER}/etc/profile.d/$FILE ] && return
  729. [ ! -d ${FOLDER}/etc/profile.d ] && mkdir -pv ${FOLDER}/etc/profile.d
  730. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  731. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  732. ${FOLDER}/etc/profile.d/$FILE
  733. return
  734. fi
  735. cat > ${FOLDER}/etc/profile.d/$FILE << "EOF"
  736. # Setup the INPUTRC environment variable.
  737. if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ] ; then
  738. INPUTRC=/etc/inputrc
  739. fi
  740. export INPUTRC
  741. EOF
  742. }
  743. generate_extrapaths_sh() {
  744. local FILE
  745. FILE="extrapaths.sh"
  746. [ -f ${FOLDER}/etc/profile.d/$FILE ] && return
  747. [ ! -d ${FOLDER}/etc/profile.d ] && mkdir -pv ${FOLDER}/etc/profile.d
  748. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  749. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  750. ${FOLDER}/etc/profile.d/$FILE
  751. return
  752. fi
  753. cat > ${FOLDER}/etc/profile.d/$FILE << "EOF"
  754. if [ -d /usr/local/lib/pkgconfig ] ; then
  755. pathappend /usr/local/lib/pkgconfig PKG_CONFIG_PATH
  756. fi
  757. if [ -d /usr/local/bin ]; then
  758. pathprepend /usr/local/bin
  759. fi
  760. if [ -d /usr/local/sbin -a $EUID -eq 0 ]; then
  761. pathprepend /usr/local/sbin
  762. fi
  763. if [ -d ~/bin ]; then
  764. pathprepend ~/bin
  765. fi
  766. #if [ $EUID -gt 99 ]; then
  767. # pathappend .
  768. #fi
  769. EOF
  770. }
  771. generate_dircolors_sh() {
  772. local FILE
  773. FILE="dircolors.sh"
  774. [ -f ${FOLDER}/etc/profile.d/$FILE ] && return
  775. [ ! -d ${FOLDER}/etc/profile.d ] && mkdir -pv ${FOLDER}/etc/profile.d
  776. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  777. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  778. ${FOLDER}/etc/profile.d/$FILE
  779. return
  780. fi
  781. cat > ${FOLDER}/etc/profile.d/$FILE << "EOF"
  782. # Setup for /bin/ls to support color, the alias is in /etc/bashrc.
  783. if [ -f "/etc/dircolors" ] ; then
  784. eval $(dircolors -b /etc/dircolors)
  785. if [ -f "$HOME/.dircolors" ] ; then
  786. eval $(dircolors -b $HOME/.dircolors)
  787. fi
  788. fi
  789. alias ls='ls --color=auto'
  790. EOF
  791. }
  792. generate_profile() {
  793. local FILE
  794. FILE="profile"
  795. [ -f ${FOLDER}/etc/$FILE ] && return
  796. [ ! -d ${FOLDER}/etc ] && mkdir -pv ${FOLDER}/etc
  797. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  798. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  799. ${FOLDER}/etc/$FILE
  800. return
  801. fi
  802. cat > ${FOLDER}/etc/$FILE << "EOF"
  803. # Begin /etc/profile
  804. # Written for Beyond Linux From Scratch
  805. # by James Robertson <jameswrobertson@earthlink.net>
  806. # modifications by Dagmar d'Surreal <rivyqntzne@pbzpnfg.arg>
  807. # System wide environment variables and startup programs.
  808. # System wide aliases and functions should go in /etc/bashrc. Personal
  809. # environment variables and startup programs should go into
  810. # ~/.bash_profile. Personal aliases and functions should go into
  811. # ~/.bashrc.
  812. # Functions to help us manage paths. Second argument is the name of the
  813. # path variable to be modified (default: PATH)
  814. pathremove () {
  815. local IFS=':'
  816. local NEWPATH
  817. local DIR
  818. local PATHVARIABLE=${2:-PATH}
  819. for DIR in ${!PATHVARIABLE} ; do
  820. if [ "$DIR" != "$1" ] ; then
  821. NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
  822. fi
  823. done
  824. export $PATHVARIABLE="$NEWPATH"
  825. }
  826. pathprepend () {
  827. pathremove $1 $2
  828. local PATHVARIABLE=${2:-PATH}
  829. export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
  830. }
  831. pathappend () {
  832. pathremove $1 $2
  833. local PATHVARIABLE=${2:-PATH}
  834. export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
  835. }
  836. export -f pathremove pathprepend pathappend
  837. # Set the initial path
  838. export PATH=/usr/bin:/bin:/usr/sbin:/sbin
  839. if [ $EUID -eq 0 ] ; then
  840. unset HISTFILE
  841. fi
  842. # Setup some environment variables.
  843. export HISTSIZE=1000
  844. export HISTIGNORE="&:[bf]g:exit"
  845. # Set some defaults for graphical systems
  846. export XDG_DATA_DIRS=/usr/share/
  847. export XDG_CONFIG_DIRS=/etc/xdg/
  848. # Setup a red prompt for root and a green one for users.
  849. NORMAL="\[\e[0m\]"
  850. RED="\[\e[1;31m\]"
  851. GREEN="\[\e[1;32m\]"
  852. if [[ $EUID == 0 ]] ; then
  853. PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL"
  854. else
  855. PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
  856. fi
  857. for script in /etc/profile.d/*.sh ; do
  858. if [ -r $script ] ; then
  859. . $script
  860. fi
  861. done
  862. unset script RED GREEN NORMAL
  863. # End /etc/profile
  864. EOF
  865. }
  866. generate_group() {
  867. [ -f ${FOLDER}/etc/group ] && return
  868. [ ! -d ${FOLDER}/etc ] && mkdir -pv ${FOLDER}/etc
  869. cat > ${FOLDER}/etc/group << "EOF"
  870. root:x:0:
  871. bin:x:1:
  872. sys:x:2:
  873. kmem:x:3:
  874. tape:x:4:
  875. tty:x:5:
  876. daemon:x:6:
  877. floppy:x:7:
  878. disk:x:8:
  879. lp:x:9:
  880. dialout:x:10:
  881. audio:x:11:gdm
  882. video:x:12:gdm
  883. utmp:x:13:
  884. usb:x:14:
  885. cdrom:x:15:
  886. adm:x:16:
  887. atd:x:17:
  888. messagebus:x:18:
  889. lpadmin:x:19:
  890. named:x:20:
  891. gdm:x:21:
  892. fcron:x:22:
  893. www:x:24:
  894. apache:x:25:
  895. smmsp:x:26:
  896. polkitd:x:27:
  897. wheel:x:30:root
  898. exim:x:31:
  899. postfix:x:32:
  900. postdrop:x:33:
  901. mail:x:34:
  902. vmailman:x:35:
  903. news:x:36:
  904. kdm:x:37:
  905. mysql:x:40:
  906. postgres:x:41:
  907. dovecot:x:42:
  908. dovenull:x:43:
  909. ftp:x:45:
  910. proftpd:x:46:
  911. vsftpd:x:47:
  912. rsyncd:x:48:
  913. sshd:x:50:
  914. stunnel:x:51:
  915. svn:x:56:
  916. svntest:x:57:
  917. pulse:x:58:
  918. pulse-access:x:59:
  919. games:x:60:
  920. kvm:x:61:
  921. wireshark:x:62:
  922. lightdm:x:63:
  923. sddm:x:64:
  924. scanner:x:70:
  925. colord:x:71:
  926. vboxusers:x:80:
  927. ldap:x:83:
  928. avahi:x:84:
  929. avahi-autoipd:x:85:
  930. netdev:x:86:
  931. ntp:x:87:
  932. unbound:x:88:
  933. nogroup:x:99:
  934. users:x:999:
  935. EOF
  936. }
  937. generate_passwd() {
  938. [ -f ${FOLDER}/etc/passwd ] && return
  939. [ ! -d ${FOLDER}/etc ] && mkdir -pv ${FOLDER}/etc
  940. cat > ${FOLDER}/etc/passwd << "EOF"
  941. root::0:0:root:/root:/bin/bash
  942. bin:x:1:1:bin:/dev/null:/bin/false
  943. lp:x:9:9:Print Service User:/dev/null:/bin/false
  944. atd:x:17:17:add daemon:/dev/null:/bin/false
  945. messagebus:x:18:18:D-Bus Message Daemon User:/dev/null:/bin/false
  946. named:x:20:20:BIND Owner:/home/named:/bin/false
  947. gdm:x:21:21:GDM Daemon User:/var/lib/gdm:/bin/false
  948. fcron:x:22:22:Fcron User:/dev/null:/bin/false
  949. www:x:24:24:Nginx Server:/dev/null:bin/false
  950. apache:x:25:25:Apache Server:/dev/null:/bin/false
  951. smmsp:x:26:26:Sendmail Daemon:/dev/null:/bin/false
  952. polkitd:x:27:27:Policy Kit Daemon User:/etc/polkit-1:/bin/false
  953. exim:x:31:31:Exim Daemon:/dev/null:/bin/false
  954. postfix:x:32:32:Postfix Daemon User:/var/spool/postfix:/bin/false
  955. sendmail:x:34:34:Sendmail Daemon:/dev/null:/bin/false
  956. vmailman:x:35:35:Vmail Daemon:/dev/null:/bin/false
  957. news:x:36:36:News Daemon:/dev/null:/bin/false
  958. kdm:x:37:37:KDM Daemon Owner:/var/lib/kdm:/bin/false
  959. mysql:x:40:40:MySQL Server:/dev/null:/bin/false
  960. postgres:x:41:41:PostgreSQL Server:/srv/pgsql/data:/bin/bash
  961. dovecot:x:42:42:Dovecot unprivileged user:/dev/null:/bin/false
  962. dovenull:x:43:43:Dovecot login user:/dev/null:/bin/false
  963. ftp:x:45:45:anonymous_user:/home/ftp:/bin/false
  964. proftpd:x:46:46:proftpd:/srv/ftp:/usr/bin/proftpdshell
  965. vsftpd:x:47:47:vsftpd User:/dev/null:/bin/false
  966. rsyncd:x:48:48:rsyncd Daemon:/home/rsync:/bin/false
  967. sshd:x:50:50:sshd PrivSep:/var/lib/sshd:/bin/false
  968. stunnel:x:51:51:stunnel Daemon:/var/lib/stunnel:/bin/false
  969. svn:x:56:56:SVN Owner:/home/svn:/bin/false
  970. games:x:60:60:Games High Score Owner:/var/games:/bin/false
  971. lightdm:x:63:63:Light Display Manager:/var/lib/lightdm:/sbin/nologin
  972. sddm:x:64:64:Simple Desktop Display Manager:/var/lib/sddm:/bin/false
  973. colord:x:71:71:Color Daemon Owner:/var/lib/colord:/bin/false
  974. ldap:x:83:83:OpenLDAP Daemon Owner:/var/lib/openldap:/bin/false
  975. avahi:x:84:84:Avahi Daemon Owner:/var/run/avahi-daemon:/bin/false
  976. avahi-autoipd:x:85:85:Avahi autoip Daemon:/:/var/run/avahi-autoipd:/bin/false
  977. ntp:x:87:87:Network Time Protocol:/var/lib/ntp:/bin/false
  978. unbound:x:88:88:Unbound DNS resolver:/var/lib/unbound:/bin/false
  979. anonymous:x:98:99:Unprivileged User:/dev/null:/bin/false
  980. nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
  981. EOF
  982. }
  983. generate_fstab() {
  984. local FILE
  985. FILE="fstab"
  986. [ -f ${FOLDER}/etc/$FILE ] && return
  987. [ ! -d ${FOLDER}/etc ] && mkdir -pv ${FOLDER}/etc
  988. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  989. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  990. ${FOLDER}/etc/$FILE
  991. return
  992. fi
  993. cat > ${FOLDER}/etc/$FILE << "EOF"
  994. # Begin /etc/fstab
  995. # file system mount-point type options dump fsck
  996. # order
  997. # Exemple de montage nfs
  998. # 192.168.254.254:/home/thierry /home/thierry nfs rw,vers=3,_netdev,rsize=8192,wsize=8192 0 0
  999. proc /proc proc nosuid,noexec,nodev 0 0
  1000. sysfs /sys sysfs nosuid,noexec,nodev 0 0
  1001. devpts /dev/pts devpts gid=5,mode=620 0 0
  1002. tmpfs /run tmpfs defaults 0 0
  1003. devtmpfs /dev devtmpfs mode=0755,nosuid 0 0
  1004. EOF
  1005. }
  1006. generate_dmrc() {
  1007. local FILE
  1008. FILE=".dmrc"
  1009. [ -f ${FOLDER}/etc/skel/$FILE ] && return
  1010. [ ! -d ${FOLDER}/etc/skel ] && mkdir -pv ${FOLDER}/etc/skel
  1011. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  1012. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  1013. ${FOLDER}/etc/skel/$FILE
  1014. return
  1015. fi
  1016. cat > ${FOLDER}/etc/skel/$FILE << "EOF"
  1017. [Desktop]
  1018. Session=default
  1019. EOF
  1020. }
  1021. generate_bashrc() {
  1022. local FILE
  1023. FILE=".bashrc"
  1024. [ -f ${FOLDER}/etc/skel/$FILE ] && return
  1025. [ ! -d ${FOLDER}/etc/skel ] && mkdir -pv ${FOLDER}/etc/skel
  1026. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  1027. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  1028. ${FOLDER}/etc/skel/$FILE
  1029. return
  1030. fi
  1031. cat > ${FOLDER}/etc/skel/$FILE << "EOF"
  1032. # Personal aliases and functions.
  1033. # Personal environment variables and startup programs should go in
  1034. # ~/.bash_profile. System wide environment variables and startup
  1035. # programs are in /etc/profile. System wide aliases and functions are
  1036. # in /etc/bashrc.
  1037. if [ -f "/etc/bashrc" ] ; then
  1038. source /etc/bashrc
  1039. fi
  1040. if [ $EUID -eq 0 ] ; then
  1041. alias del='cards remove'
  1042. alias get='cards install'
  1043. alias up='cards install -u'
  1044. alias check='cards sync;cards diff'
  1045. else
  1046. alias del='sudo cards remove'
  1047. alias get='sudo cards install'
  1048. alias up='sudo cards install -u'
  1049. alias check='sudo cards sync;sudo cards diff'
  1050. fi
  1051. alias search='cards search'
  1052. alias ll='ls -l'
  1053. alias l='ls -alh'
  1054. alias duh='du -h --max-depth=1'
  1055. alias dfh='df -h'
  1056. alias pkgfind='cards list | grep -i'
  1057. # End ~/.bashrc
  1058. EOF
  1059. [ -f ${FOLDER}/root/$FILE ] && return
  1060. [ ! -d ${FOLDER}/root ] && install -dv -m0750 ${FOLDER}/root
  1061. cp -v ${FOLDER}/etc/skel/$FILE \
  1062. ${FOLDER}/root
  1063. }
  1064. generate_bash_profile() {
  1065. local FILE
  1066. FILE=".bash_profile"
  1067. [ -f ${FOLDER}/etc/skel/$FILE ] && return
  1068. [ ! -d ${FOLDER}/etc/skel ] && mkdir -pv ${FOLDER}/etc/skel
  1069. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  1070. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  1071. ${FOLDER}/etc/skel/$FILE
  1072. return
  1073. fi
  1074. cat > ${FOLDER}/etc/skel/$FILE << "EOF"
  1075. # Personal environment variables and startup programs.
  1076. # Personal aliases and functions should go in ~/.bashrc. System wide
  1077. # environment variables and startup programs are in /etc/profile.
  1078. # System wide aliases and functions are in /etc/bashrc.
  1079. append () {
  1080. # First remove the directory
  1081. local IFS=':'
  1082. local NEWPATH
  1083. for DIR in $PATH; do
  1084. if [ "$DIR" != "$1" ]; then
  1085. NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
  1086. fi
  1087. done
  1088. # Then append the directory
  1089. export PATH=$NEWPATH:$1
  1090. }
  1091. if [ -f "$HOME/.bashrc" ] ; then
  1092. source $HOME/.bashrc
  1093. fi
  1094. # unset append
  1095. # End ~/.bash_profile
  1096. EOF
  1097. [ ! -d ${FOLDER}/root ] && install -dv -m0750 ${FOLDER}/root
  1098. [ -f ${FOLDER}/root/$FILE ] && return
  1099. cp -v ${FOLDER}/etc/skel/$FILE \
  1100. ${FOLDER}/root
  1101. }
  1102. generate_pkgmk_conf() {
  1103. local FILE
  1104. FILE="pkgmk.conf"
  1105. [ -f ${FOLDER}/etc/$FILE ] && return
  1106. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  1107. [ ! -d ${FOLDER}/etc ] && mkdir -pv ${FOLDER}/etc
  1108. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  1109. ${FOLDER}/etc/$FILE
  1110. fi
  1111. }
  1112. generate_cards_conf() {
  1113. local FILE
  1114. FILE="cards.conf"
  1115. [ -f ${FOLDER}/etc/$FILE ] && return
  1116. [ ! -d ${FOLDER}/etc ] && mkdir -pv ${FOLDER}/etc
  1117. if [ -f /etc/${INSTALL_COMMAND}.conf.d/$FILE ]; then
  1118. cp /etc/${INSTALL_COMMAND}.conf.d/$FILE \
  1119. ${FOLDER}/etc/$FILE
  1120. return
  1121. fi
  1122. echo "## For kde5
  1123. # Comment following 2 lines
  1124. # if you don't want to install kde5
  1125. #
  1126. dir ${DEPOT}/kde5-extra|${URL}
  1127. dir ${DEPOT}/kde5|${URL}
  1128. ##
  1129. ## For kde (4)
  1130. # Comment following 2 lines
  1131. # if you don't want to install kde (version4)
  1132. #
  1133. dir ${DEPOT}/kde-extra|${URL}
  1134. dir ${DEPOT}/kde|${URL}
  1135. #
  1136. ## For cinnamon
  1137. # Cinnamon is not yet ready to ude
  1138. # Decomment following 2 lines
  1139. # if you want to try cinnamon anyway
  1140. #
  1141. # dir ${DEPOT}/cinnamon-extra|${URL}
  1142. # dir ${DEPOT}/cinnamon|${URL}
  1143. #
  1144. ## For Gnome
  1145. # Comment following 2 lines
  1146. # if you don't want to install gnome
  1147. #
  1148. dir ${DEPOT}/gnome-extra|${URL}
  1149. dir ${DEPOT}/gnome|${URL}
  1150. #
  1151. ## For mate
  1152. # Comment following 2 lines
  1153. # if you don't want to install mate
  1154. #
  1155. dir ${DEPOT}/mate-extra|${URL}
  1156. dir ${DEPOT}/mate|${URL}
  1157. #
  1158. ## For xfce4
  1159. # Comment following 2 lines
  1160. # if you don't want to install xfce4
  1161. #
  1162. dir ${DEPOT}/xfce4-extra|${URL}
  1163. dir ${DEPOT}/xfce4|${URL}
  1164. #
  1165. ## For lxqt
  1166. # Comment following 2 lines
  1167. # if you don't want to install lxqt
  1168. #
  1169. dir ${DEPOT}/lxqt-extra|${URL}
  1170. dir ${DEPOT}/lxqt|${URL}
  1171. #
  1172. ## For lxde
  1173. # Comment following 2 lines
  1174. # if you don't want to install lxde
  1175. #
  1176. dir ${DEPOT}/lxde-extra|${URL}
  1177. dir ${DEPOT}/lxde|${URL}
  1178. #
  1179. ## Normally everything under this line
  1180. # are needed stuffs
  1181. #
  1182. ## For all the graphical applications
  1183. dir ${DEPOT}/gui-extra|${URL}
  1184. #
  1185. ## For a minimal graphical interface
  1186. dir ${DEPOT}/gui|${URL}
  1187. #
  1188. ## For all the console applications
  1189. dir ${DEPOT}/cli-extra|${URL}
  1190. #
  1191. ## For a minimal console interface
  1192. dir ${DEPOT}/cli|${URL}
  1193. #
  1194. ## Strict minimum Base system to be able to boot on it
  1195. dir ${DEPOT}/base-extra|${URL}
  1196. #
  1197. # Chroot system without reboot possibilities for a chroot
  1198. dir ${DEPOT}/base|${URL}
  1199. #
  1200. ## Normaly you want to keep base and
  1201. base ${DEPOT}/base
  1202. #
  1203. ## and base-extra
  1204. base ${DEPOT}/base-extra
  1205. #
  1206. ## If you want to keep more collections remove comments below
  1207. # Adjust to your needs
  1208. #
  1209. # base ${DEPOT}/cli
  1210. # base ${DEPOT}/cli-extra
  1211. # base ${DEPOT}/gui
  1212. # base ${DEPOT}/gui-extra
  1213. # base ${DEPOT}/..." > ${FOLDER}/etc/cards.conf
  1214. }
  1215. generate_nutyx_version() {
  1216. local FILE
  1217. FILE="nutyx-version"
  1218. [ -f ${FOLDER}/var/lib/pkg/$FILE ] && return
  1219. [ ! -d ${FOLDER}/var/lib/pkg ] && mkdir -pv ${FOLDER}/var/lib/pkg
  1220. echo "name ${CODE_NAME}
  1221. version $VERSION" > ${FOLDER}/var/lib/pkg/$FILE
  1222. }
  1223. install_resolv_conf() {
  1224. [ -f /etc/resolv.conf ] && cp /etc/resolv.conf ${FOLDER}/etc
  1225. }
  1226. successfull_installation () {
  1227. echo "
  1228. ****************************************************
  1229. * Installation of NuTyX $VERSION finished. *
  1230. * *
  1231. * Thanks for installing NuTyX *
  1232. * *
  1233. * Check http://www.nutyx.org/en/documentation.html *
  1234. * or http://www.nutyx.org/fr/documentation.html *
  1235. * *
  1236. * Make sure to review /etc/cards.conf *
  1237. * to meet your requirements in packages selection *
  1238. * *
  1239. ****************************************************
  1240. "
  1241. }
  1242. check_root() {
  1243. [ "$UID" != "0" ] && error " You are not root, cannot continue"
  1244. }
  1245. check_bash() {
  1246. BASH_VERSION=`bash --version|head -n1 | cut -d " " -f4|cut -d "(" -f1|sed "s/\.//g"`
  1247. if [ -z ${BASH_VERSION} ]; then
  1248. error " Wrong interpreter, please use 'bash' as interpreter"
  1249. fi
  1250. # Checking bash version
  1251. if [ ${BASH_VERSION} -lt 4333 ]; then
  1252. boot_mesg " You not use 'bash' version 4.3.33 or newer..."
  1253. echo_warning
  1254. fi
  1255. }
  1256. check_tools() {
  1257. if ! (`which wget > /dev/null`); then
  1258. error " Command 'wget' not found, please install wget"
  1259. fi
  1260. if ! (`which tar > /dev/null`); then
  1261. error " Command 'tar' not found, please install tar"
  1262. fi
  1263. if ! (`which gawk > /dev/null`); then
  1264. error " Command 'gawk' not found, please install gawk"
  1265. fi
  1266. }
  1267. check_variables() {
  1268. [ -z $URL ] && URL="http://downloads.nutyx.org"
  1269. [ -z $VERSION ] && VERSION="8.0"
  1270. [ -z $DEPOT ] && DEPOT="/var/lib/pkg/depotrepo"
  1271. [ -z $FOLDER ] && FOLDER="/mnt/hd"
  1272. HOMEPAGE="${URL}" ## http://downloads.nutyx.org
  1273. INSTALL_BASE="$VERSION/$ARCH" ## 8.0/x86_64
  1274. DEPOT_ROOT="$HOMEPAGE/${INSTALL_BASE}" ## http://downloads.nutyx.org/8.0/x86_64
  1275. DEPOT_BASE="$DEPOT_ROOT/$BASE" ## http://downloads.nutyx.org/8.0/x86_64/base
  1276. LOCAL_DEPOT_PACKAGES="$DEPOT/$BASE"
  1277. DEPOT_CD="/media/cdrom"
  1278. SETUP_FILE=/tmp/setup
  1279. # Size of the FullInstall in Mbytes
  1280. let BASE_SIZE=450
  1281. }
  1282. config() {
  1283. ARCH=`uname -m`
  1284. # Number of seconds between STOPSIG and FALLBACK when stopping processes
  1285. KILLDELAY="3"
  1286. ## Screen Dimensions
  1287. # Find current screen size
  1288. if [ -z "${COLUMNS}" ]; then
  1289. COLUMNS=$(stty size)
  1290. COLUMNS=${COLUMNS##* }
  1291. fi
  1292. # When using remote connections, such as a serial port, stty size returns 0
  1293. if [ "${COLUMNS}" = "0" ]; then
  1294. COLUMNS=80
  1295. fi
  1296. ## Measurements for positioning result messages
  1297. COL=$((${COLUMNS} - 8))
  1298. WCOL=$((${COL} - 2))
  1299. ## Provide an echo that supports -e and -n
  1300. # If formatting is needed, $ECHO should be used
  1301. case "`echo -e -n test`" in
  1302. -[en]*)
  1303. ECHO=/bin/echo
  1304. ;;
  1305. *)
  1306. ECHO=echo
  1307. ;;
  1308. esac
  1309. ## Set Cursor Position Commands, used via $ECHO
  1310. SET_COL="\\033[${COL}G" # at the $COL char
  1311. SET_WCOL="\\033[${WCOL}G" # at the $WCOL char
  1312. CURS_UP="\\033[1A\\033[0G" # Up one line, at the 0'th char
  1313. ## Set color commands, used via $ECHO
  1314. # Please consult `man console_codes for more information
  1315. # under the "ECMA-48 Set Graphics Rendition" section
  1316. #
  1317. # Warning: when switching from a 8bit to a 9bit font,
  1318. # the linux console will reinterpret the bold (1;) to
  1319. # the top 256 glyphs of the 9bit font. This does
  1320. # not affect framebuffer consoles
  1321. NORMAL="\\033[0;39m" # Standard console grey
  1322. SUCCESS="\\033[1;32m" # Success is green
  1323. WARNING="\\033[1;33m" # Warnings are yellow
  1324. FAILURE="\\033[1;31m" # Failures are red
  1325. INFO="\\033[1;36m" # Information is light cyan
  1326. BRACKET="\\033[1;34m" # Brackets are blue
  1327. STRING_LENGTH="0" # the length of the current message
  1328. }
  1329. check_lfs() {
  1330. # LFS is set ?
  1331. if [ ! -z "${LFS}" ]; then
  1332. DEVICE=${LFS}
  1333. FOLDER=${LFS}
  1334. else
  1335. DEVICE=${FOLDER}
  1336. fi
  1337. echo "
  1338. ******************************
  1339. Installation path: $DEVICE
  1340. ******************************"
  1341. }
  1342. check_mountpoint() {
  1343. [ -z $FOLDER ] && error "Variable FOLDER not define"
  1344. }
  1345. check_arch() {
  1346. if [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "i686" ]; then
  1347. boot_mesg "
  1348. >>> This arch ($ARCH) is not supported"
  1349. echo_failure
  1350. exit 1
  1351. fi
  1352. }
  1353. create_database() {
  1354. [ ! -d ${FOLDER}/var/lib/pkg/DB ] && mkdir -p ${FOLDER}/var/lib/pkg/DB
  1355. }
  1356. create_locale_link() {
  1357. [ ! -d ${FOLDER}/etc/locale ] && mkdir -p ${FOLDER}/etc/locale
  1358. if [ -d ${FOLDER}/usr/lib/locale ]; then
  1359. rm -r ${FOLDER}/usr/lib/locale
  1360. ln -sv /etc/locale/ ${FOLDER}/usr/lib/locale
  1361. fi
  1362. }
  1363. make_directories() {
  1364. mkdir ${FOLDER}/{dev,sys,proc,run,tmp,home,srv,mnt}
  1365. mkdir -p ${FOLDER}/var/tmp
  1366. mkdir -p ${FOLDER}/usr/{,local/}lib
  1367. chmod 1777 ${FOLDER}/{,var/}tmp
  1368. mkdir -v ${FOLDER}/var/{mail,spool}
  1369. mkdir -pv ${FOLDER}/var/run/lock
  1370. mknod -m 600 ${FOLDER}/dev/console c 5 1
  1371. mknod -m 666 ${FOLDER}/dev/null c 1 3
  1372. }
  1373. download_pkgadd() {
  1374. if [ ! -f $TMP/usr/bin/pkgadd ]; then
  1375. cd $TMP
  1376. basepackagefile=`getPackageName cards`
  1377. if [ "$basepackagefile" == "" ]; then
  1378. error "variable 'basepackagefile' is not set"
  1379. fi
  1380. packagefile=`echo ${basepackagefile}|sed "s|^cards|cards.devel|"`
  1381. if [ ! -f ${packagefile} ]; then
  1382. wget ${DEPOT_BASE}/cards/$packagefile || print_error_msg
  1383. echo_ok
  1384. fi
  1385. echo "Extraction of cards.devel ..."
  1386. tar -xf ${packagefile} || print_error_msg
  1387. echo_ok
  1388. fi
  1389. }
  1390. check_mountfolder() {
  1391. [ ! -d $FOLDER ] && mkdir -p $FOLDER
  1392. }
  1393. generate_setupfile() {
  1394. echo "#!/bin/bash
  1395. source /etc/profile
  1396. cards sync
  1397. cards install e2fsprogs \
  1398. reiserfsprogs \
  1399. xfsprogs jfsutils \
  1400. btrfs-progs sudo \
  1401. sysklogd sysvinit \
  1402. dhcpcd grub \
  1403. tzdata iproute2 iana-etc \
  1404. e3 eudev kmod less \
  1405. groff man-db cards.man \
  1406. nutyx.man \
  1407. lvm2 mdadm dialog cpio squashfs \
  1408. linux-firmware \
  1409. kernel-lts \
  1410. ca-certificates
  1411. exit" > $FOLDER/$SETUP_FILE
  1412. chmod 177 $FOLDER/$SETUP_FILE
  1413. setup_chroot
  1414. chroot ${FOLDER} /bin/bash -c "$SETUP_FILE"
  1415. unmountall
  1416. }
  1417. install_configuration_files() {
  1418. generate_cards_conf
  1419. generate_pkgmk_conf
  1420. generate_fstab
  1421. generate_passwd
  1422. generate_group
  1423. generate_bash_profile
  1424. generate_bashrc
  1425. generate_dmrc
  1426. generate_hosts
  1427. generate_inputrc
  1428. generate_shells
  1429. generate_dircolors_sh
  1430. generate_extrapaths_sh
  1431. generate_readline_sh
  1432. generate_umask_sh
  1433. generate_profile
  1434. generate_hosts
  1435. generate_inputrc
  1436. generate_modules
  1437. generate_createfiles
  1438. generate_mouse
  1439. generate_udev_retry
  1440. generate_rc_site
  1441. generate_etc_bashrc
  1442. generate_blfs_bootscripts
  1443. generate_nutyx_version
  1444. }
  1445. print_help() {
  1446. echo "
  1447. usage: `basename ${INSTALL_COMMAND}` [options] options
  1448. -p, --path <installation-path> will install NuTyX in <installation-path>
  1449. -ec, --enter-chroot will enter in the chroot if exist
  1450. -ic, --install-config will install all the configuration files only
  1451. -h, --help print help and exit
  1452. -v, --version print the version and exit
  1453. "
  1454. }
  1455. parse_options() {
  1456. while [ "$1" ]; do
  1457. case $1 in
  1458. -h|--help)
  1459. print_help
  1460. exit 0;;
  1461. -ec|--enter-chroot)
  1462. check_lfs "$@"
  1463. check_root
  1464. setup_chroot
  1465. enter_chroot
  1466. unmountall
  1467. exit 0;;
  1468. -ic|--install-config)
  1469. check_variables
  1470. check_lfs "$@"
  1471. check_root
  1472. check_mountfolder
  1473. check_mountpoint
  1474. make_directories
  1475. create_locale_link
  1476. install_configuration_files
  1477. exit 0;;
  1478. -p|--path)
  1479. if [ ! "$2" ]; then
  1480. echo "`basename $INSTALL_COMMAND`: option $1 requires an argument"
  1481. exit 1
  1482. fi
  1483. FOLDER="$2"
  1484. shift;;
  1485. -v|--version)
  1486. echo "`basename $INSTALL_COMMAND` $VERSION-$RELEASE"
  1487. exit 0;;
  1488. /*)
  1489. boot_mesg "
  1490. >>> This methode is depreciate <<<: use '-p $1' instead or adjust the 'LFS' variable"
  1491. echo_warning
  1492. echo "
  1493. press any key to continue ...
  1494. "
  1495. read a
  1496. FOLDER="$1";;
  1497. *)
  1498. echo "`basename $0`: invalid option $1"
  1499. exit 1 ;;
  1500. esac
  1501. shift
  1502. done
  1503. }
  1504. main() {
  1505. config
  1506. [ -f /etc/`basename $INSTALL_COMMAND`.conf ] && source /etc/`basename $INSTALL_COMMAND`.conf
  1507. check_variables "$@"
  1508. parse_options "$@"
  1509. check_arch
  1510. check_lfs "$@"
  1511. if [ $# -lt 1 ] && [ -z "$LFS" ] ; then
  1512. echo "
  1513. *******************************************
  1514. * You didn't specify enough arguments *
  1515. * Argument 1: Folder destionation *
  1516. * *
  1517. * Please re-enter the command with the *
  1518. * corrects arguments *
  1519. *******************************************
  1520. example: ${INSTALL_COMMAND} -p /chroot
  1521. "
  1522. return
  1523. fi
  1524. check_root
  1525. check_bash
  1526. check_tools
  1527. TMP=`mktemp -d`
  1528. check_mountfolder
  1529. check_mountpoint
  1530. download_pkgadd
  1531. create_database
  1532. install_base
  1533. create_locale_link
  1534. make_directories
  1535. install_configuration_files
  1536. install_resolv_conf
  1537. generate_setupfile
  1538. end
  1539. successfull_installation
  1540. }
  1541. readonly CODE_NAME="houaphan"
  1542. readonly BASE="base"
  1543. readonly RELEASE=2
  1544. INSTALL_COMMAND="`basename $0`"
  1545. main "$@"