hyperfi.sh 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944
  1. #!/bin/bash
  2. # shellcheck disable=SC2181
  3. # Hyperbola GNU+Linux-libre Fast Install (hyperfi)
  4. # --------------------------------
  5. # Last author : Jesus E.
  6. # First author : MatMoul
  7. # https://github.com/MatMoul
  8. # http://sourceforge.net/u/matmoul
  9. # project : https://github.com/MatMoul/archfi
  10. # http://sourceforge.net/projects/archfi/
  11. # First license : LGPL-3.0 (http://opensource.org/licenses/lgpl-3.0.html)
  12. # Second license : GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
  13. #
  14. # Reference : https://wiki.hyperbola.info/doku.php?id=en:guide:installation
  15. apptitle="Hyperbola GNU+Linux-Libre Fast Install (hyperfi) - Version: 0.4.0 (GPLv3)"
  16. baseurl=https://git.sr.ht/~heckyel/hyperfi/blob/master
  17. cpl=0
  18. skipfont="0"
  19. fspkgs=""
  20. # --------------------------------------------------------
  21. mainmenu(){
  22. if [ "${1}" = "" ]; then
  23. nextitem="."
  24. else
  25. nextitem=${1}
  26. fi
  27. options=()
  28. options+=("${txtlanguage}" "Language")
  29. options+=("${txtsetkeymap}" "(loadkeys ...)")
  30. options+=("${txteditor}" "(${txtoptional})")
  31. options+=("${txtdiskpartmenu}" "")
  32. options+=("${txtselectpartsmenu}" "")
  33. options+=("" "")
  34. options+=("${txtreboot}" "")
  35. sel=$(whiptail --backtitle "${apptitle}" --title "${txtmainmenu}" --menu "" --cancel-button "${txtexit}" --default-item "${nextitem}" 0 0 0 \
  36. "${options[@]}" \
  37. 3>&1 1>&2 2>&3)
  38. if [ "$?" = "0" ]; then
  39. case ${sel} in
  40. "${txtlanguage}")
  41. chooselanguage
  42. nextitem="${txtsetkeymap}"
  43. ;;
  44. "${txtsetkeymap}")
  45. setkeymap
  46. nextitem="${txtdiskpartmenu}"
  47. ;;
  48. "${txteditor}")
  49. chooseeditor
  50. nextitem="${txtdiskpartmenu}"
  51. ;;
  52. "${txtdiskpartmenu}")
  53. diskpartmenu
  54. nextitem="${txtselectpartsmenu}"
  55. ;;
  56. "${txtselectpartsmenu}")
  57. selectparts
  58. nextitem="${txtreboot}"
  59. ;;
  60. "${txthelp}")
  61. help
  62. nextitem="${txtreboot}"
  63. ;;
  64. "${txtchangelog}")
  65. showchangelog
  66. nextitem="${txtreboot}"
  67. ;;
  68. "${txtreboot}")
  69. rebootpc
  70. nextitem="${txtreboot}"
  71. ;;
  72. esac
  73. mainmenu "${nextitem}"
  74. else
  75. clear
  76. fi
  77. }
  78. chooselanguage(){
  79. options=()
  80. options+=("Arabic" "(By Mohammad Alawadi)")
  81. options+=("Brazilian" "(By MaxWilliamJF)")
  82. options+=("Dutch" "(By bowero)")
  83. options+=("English" "(By MatMoul)")
  84. options+=("French" "(By MatMoul)")
  85. options+=("German" "(By untergrundbiber)")
  86. options+=("Greek" "(By quelotic)")
  87. options+=("Italian" "(By thegoldgoat)")
  88. options+=("Hungarian" "(By KardiWeb)")
  89. options+=("Norwegian" "(By mrboen94)")
  90. options+=("Polish" "(By dawidd6)")
  91. options+=("Portuguese" "(By hugok)")
  92. options+=("Russian" "(By Anonymous_Prodject)")
  93. options+=("Spanish" "(By Mystogab)")
  94. options+=("Turkish" "(By c0b41)")
  95. sel=$(whiptail --backtitle "${apptitle}" --title "${txtlanguage}" --menu "" 0 0 0 \
  96. "${options[@]}" \
  97. 3>&1 1>&2 2>&3)
  98. if [ "$?" = "0" ]; then
  99. clear
  100. if [ "${sel}" = "English" ]; then
  101. loadstrings
  102. else
  103. eval "$(curl -L "${baseurl}/lng/${sel}" | sed '/^#/ d')"
  104. fi
  105. if [ "${skipfont}" = "0" ]; then
  106. eval "$(setfont "${font}")"
  107. fi
  108. font=
  109. if [ "$(grep "^#${locale}" /etc/locale.gen)" != "" ]; then
  110. sed -i "/#${locale}/s/^#//g" /etc/locale.gen
  111. locale-gen
  112. fi
  113. export LANG=${locale}
  114. fi
  115. }
  116. setkeymap(){
  117. items=$(find /usr/share/kbd/keymaps/ -type f -printf "%f\n" | sort -V)
  118. options=()
  119. for item in ${items}; do
  120. options+=("${item%%.*}" "")
  121. done
  122. keymap=$(whiptail --backtitle "${apptitle}" --title "${txtsetkeymap}" --menu "" 0 0 0 \
  123. "${options[@]}" \
  124. 3>&1 1>&2 2>&3)
  125. if [ "$?" = "0" ]; then
  126. clear
  127. echo "loadkeys ${keymap}"
  128. loadkeys "${keymap}"
  129. pressanykey
  130. fi
  131. }
  132. chooseeditor(){
  133. options=()
  134. options+=("nano" "")
  135. options+=("vim" "")
  136. options+=("vi" "")
  137. options+=("edit" "")
  138. sel=$(whiptail --backtitle "${apptitle}" --title "${txteditor}" --menu "" 0 0 0 \
  139. "${options[@]}" \
  140. 3>&1 1>&2 2>&3)
  141. if [ "$?" = "0" ]; then
  142. clear
  143. echo "export EDITOR=${sel}"
  144. export EDITOR=${sel}
  145. EDITOR=${sel}
  146. pressanykey
  147. fi
  148. }
  149. rebootpc(){
  150. if (whiptail --backtitle "${apptitle}" --title "${txtreboot}" --yesno "${txtreboot} ?" --defaultno 0 0); then
  151. clear
  152. reboot
  153. fi
  154. }
  155. # --------------------------------------------------------
  156. # --------------------------------------------------------
  157. selectdisk(){
  158. items=$(lsblk -d -p -n -l -o NAME,SIZE -e 7,11)
  159. options=()
  160. IFS_ORIG=$IFS
  161. IFS=$'\n'
  162. for item in ${items}
  163. do
  164. options+=("${item}" "")
  165. done
  166. IFS=$IFS_ORIG
  167. result=$(whiptail --backtitle "${apptitle}" --title "${1}" --menu "" 0 0 0 "${options[@]}" 3>&1 1>&2 2>&3)
  168. if [ "$?" != "0" ]
  169. then
  170. return 1
  171. fi
  172. echo "${result%%\ *}"
  173. return 0
  174. }
  175. diskpartmenu(){
  176. if [ "${1}" = "" ]; then
  177. nextitem="."
  178. else
  179. nextitem=${1}
  180. fi
  181. options=()
  182. if [ "${eficomputer}" == "0" ]; then
  183. options+=("${txtautoparts} (gpt)" "")
  184. options+=("${txtautoparts} (dos)" "")
  185. else
  186. options+=("${txtautoparts} (gpt,efi)" "")
  187. options+=("${txtautoparts} (gpt)" "")
  188. options+=("${txtautoparts} (dos)" "")
  189. options+=("${txtautoparts} (gpt,bios+efi,noswap)" "")
  190. fi
  191. options+=("${txteditparts} (cfdisk)" "")
  192. options+=("${txteditparts} (cgdisk)" "")
  193. sel=$(whiptail --backtitle "${apptitle}" --title "${txtdiskpartmenu}" --menu "" --cancel-button "${txtback}" --default-item "${nextitem}" 0 0 0 \
  194. "${options[@]}" \
  195. 3>&1 1>&2 2>&3)
  196. if [ "$?" = "0" ]; then
  197. case ${sel} in
  198. "${txtautoparts} (dos)")
  199. diskpartautodos
  200. nextitem="${txtautoparts} (dos)"
  201. ;;
  202. "${txtautoparts} (gpt)")
  203. diskpartautogpt
  204. nextitem="${txtautoparts} (gpt)"
  205. ;;
  206. "${txtautoparts} (gpt,efi)")
  207. diskpartautoefi
  208. nextitem="${txtautoparts} (gpt,efi)"
  209. ;;
  210. "${txtautoparts} (gpt,bios+efi,noswap)")
  211. diskpartautoefiusb
  212. nextitem="${txtautoparts} (gpt,bios+efi,noswap)"
  213. ;;
  214. "${txteditparts} (cfdisk)")
  215. diskpartcfdisk
  216. nextitem="${txteditparts} (cfdisk)"
  217. ;;
  218. "${txteditparts} (cgdisk)")
  219. diskpartcgdisk
  220. nextitem="${txteditparts} (cgdisk)"
  221. ;;
  222. esac
  223. diskpartmenu "${nextitem}"
  224. fi
  225. }
  226. diskpartautodos(){
  227. device=$(selectdisk "${txtautoparts} (dos)")
  228. if [ "$?" = "0" ]; then
  229. if (whiptail --backtitle "${apptitle}" --title "${txtautoparts} (dos)" --yesno "${txtautopartsconfirm//%1/${device}}" --defaultno 0 0); then
  230. clear
  231. echo "${txtautopartclear}"
  232. parted "${device}" mklabel msdos
  233. sleep 1
  234. echo "${txtautopartcreate//%1/boot}"
  235. echo -e "n\np\n\n\n+512M\na\nw" | fdisk "${device}"
  236. sleep 1
  237. echo "${txtautopartcreate//%1/swap}"
  238. swapsize=$(grep MemTotal /proc/meminfo | awk '{ print $2 }')
  239. swapsize=$((swapsize/1000))"M"
  240. echo -e "n\np\n\n\n+${swapsize}\nt\n\n82\nw" | fdisk "${device}"
  241. sleep 1
  242. echo "${txtautopartcreate//%1/root}"
  243. echo -e "n\np\n\n\n\nw" | fdisk "${device}"
  244. sleep 1
  245. echo ""
  246. pressanykey
  247. if [ "${device::8}" == "/dev/nvm" ]; then
  248. bootdev=${device}"p1"
  249. swapdev=${device}"p2"
  250. rootdev=${device}"p3"
  251. else
  252. bootdev=${device}"1"
  253. swapdev=${device}"2"
  254. rootdev=${device}"3"
  255. fi
  256. efimode="0"
  257. fi
  258. fi
  259. }
  260. diskpartautogpt(){
  261. device=$(selectdisk "${txtautoparts} (gpt)")
  262. if [ "$?" = "0" ]; then
  263. if (whiptail --backtitle "${apptitle}" --title "${txtautoparts} (gpt)" --yesno "${txtautopartsconfirm//%1/${device}}" --defaultno 0 0); then
  264. clear
  265. echo "${txtautopartclear}"
  266. parted "${device}" mklabel gpt
  267. echo "${txtautopartcreate//%1/BIOS boot}"
  268. sgdisk "${device}" -n=1:0:+31M -t=1:ef02
  269. echo "${txtautopartcreate//%1/boot}"
  270. sgdisk "${device}" -n=2:0:+512M
  271. echo "${txtautopartcreate//%1/swap}"
  272. swapsize=$(grep MemTotal /proc/meminfo | awk '{ print $2 }')
  273. swapsize=$((swapsize/1000))"M"
  274. sgdisk "${device}" -n=3:0:+${swapsize} -t=3:8200
  275. echo "${txtautopartcreate//%1/root}"
  276. sgdisk "${device}" -n=4:0:0
  277. echo ""
  278. pressanykey
  279. if [ "${device::8}" == "/dev/nvm" ]; then
  280. bootdev=${device}"p2"
  281. swapdev=${device}"p3"
  282. rootdev=${device}"p4"
  283. else
  284. bootdev=${device}"2"
  285. swapdev=${device}"3"
  286. rootdev=${device}"4"
  287. fi
  288. efimode="0"
  289. fi
  290. fi
  291. }
  292. diskpartautoefi(){
  293. device=$(selectdisk "${txtautoparts} (gpt,efi)")
  294. if [ "$?" = "0" ]; then
  295. if (whiptail --backtitle "${apptitle}" --title "${txtautoparts} (gpt,efi)" --yesno "${txtautopartsconfirm//%1/${device}}" --defaultno 0 0); then
  296. clear
  297. echo "${txtautopartclear}"
  298. parted "${device}" mklabel gpt
  299. echo "${txtautopartcreate//%1/EFI boot}"
  300. sgdisk "${device}" -n=1:0:+1024M -t=1:ef00
  301. echo "${txtautopartcreate//%1/swap}"
  302. swapsize=$(grep MemTotal /proc/meminfo | awk '{ print $2 }')
  303. swapsize=$((swapsize/1000))"M"
  304. sgdisk "${device}" -n=2:0:+${swapsize} -t=2:8200
  305. echo "${txtautopartcreate//%1/root}"
  306. sgdisk "${device}" -n=3:0:0
  307. echo ""
  308. pressanykey
  309. if [ "${device::8}" == "/dev/nvm" ]; then
  310. bootdev=${device}"p1"
  311. swapdev=${device}"p2"
  312. rootdev=${device}"p3"
  313. else
  314. bootdev=${device}"1"
  315. swapdev=${device}"2"
  316. rootdev=${device}"3"
  317. fi
  318. efimode="1"
  319. fi
  320. fi
  321. }
  322. diskpartautoefiusb(){
  323. device=$(selectdisk "${txtautoparts} (gpt,efi)")
  324. if [ "$?" = "0" ]; then
  325. if (whiptail --backtitle "${apptitle}" --title "${txtautoparts} (gpt,efi)" --yesno "${txtautopartsconfirm//%1/${device}}" --defaultno 0 0); then
  326. clear
  327. echo "${txtautopartclear}"
  328. parted "${device}" mklabel gpt
  329. echo "${txtautopartcreate//%1/EFI boot}"
  330. sgdisk "${device}" -n=1:0:+1024M -t=1:ef00
  331. echo "${txtautopartcreate//%1/BIOS boot}"
  332. sgdisk "${device}" -n=2:0:+31M -t=2:ef02
  333. echo "${txtautopartcreate//%1/root}"
  334. sgdisk "${device}" -n=3:0:0
  335. echo "${txthybridpartcreate}"
  336. echo -e "r\nh\n3\nN\n\nY\nN\nw\nY\n" | gdisk "${device}"
  337. echo ""
  338. pressanykey
  339. if [ "${device::8}" == "/dev/nvm" ]; then
  340. bootdev=${device}"p1"
  341. swapdev=
  342. rootdev=${device}"p3"
  343. else
  344. bootdev=${device}"1"
  345. swapdev=
  346. rootdev=${device}"3"
  347. fi
  348. efimode="2"
  349. fi
  350. fi
  351. }
  352. diskpartcfdisk(){
  353. device=$( selectdisk "${txteditparts} (cfdisk)" )
  354. if [ "$?" = "0" ]; then
  355. clear
  356. cfdisk "${device}"
  357. fi
  358. }
  359. diskpartcgdisk(){
  360. device=$( selectdisk "${txteditparts} (cgdisk)" )
  361. if [ "$?" = "0" ]; then
  362. clear
  363. cgdisk "${device}"
  364. fi
  365. }
  366. # --------------------------------------------------------
  367. # --------------------------------------------------------
  368. selectparts(){
  369. items=$(lsblk -p -n -l -o NAME -e 7,11)
  370. options=()
  371. for item in ${items}; do
  372. options+=("${item}" "")
  373. done
  374. bootdev=$(whiptail --backtitle "${apptitle}" --title "${txtselectpartsmenu}" --menu "${txtselectdevice//%1/boot}" --default-item "${bootdev}" 0 0 0 \
  375. "none" "-" \
  376. "${options[@]}" \
  377. 3>&1 1>&2 2>&3)
  378. if [ ! "$?" = "0" ]; then
  379. return 1
  380. else
  381. if [ "${bootdev}" = "none" ]; then
  382. bootdev=
  383. fi
  384. fi
  385. swapdev=$(whiptail --backtitle "${apptitle}" --title "${txtselectpartsmenu}" --menu "${txtselectdevice//%1/swap}" --default-item "${swapdev}" 0 0 0 \
  386. "none" "-" \
  387. "${options[@]}" \
  388. 3>&1 1>&2 2>&3)
  389. if [ ! "$?" = "0" ]; then
  390. return 1
  391. else
  392. if [ "${swapdev}" = "none" ]; then
  393. swapdev=
  394. fi
  395. fi
  396. rootdev=$(whiptail --backtitle "${apptitle}" --title "${txtselectpartsmenu}" --menu "${txtselectdevice//%1/root}" --default-item "${rootdev}" 0 0 0 \
  397. "${options[@]}" \
  398. 3>&1 1>&2 2>&3)
  399. if [ ! "$?" = "0" ]; then
  400. return 1
  401. fi
  402. realrootdev=${rootdev}
  403. homedev=$(whiptail --backtitle "${apptitle}" --title "${txtselectpartsmenu}" --menu "${txtselectdevice//%1/home}" 0 0 0 \
  404. "none" "-" \
  405. "${options[@]}" \
  406. 3>&1 1>&2 2>&3)
  407. if [ ! "$?" = "0" ]; then
  408. return 1
  409. else
  410. if [ "${homedev}" = "none" ]; then
  411. homedev=
  412. fi
  413. fi
  414. msg="${txtselecteddevices}\n\n"
  415. msg=${msg}"boot : ${bootdev}\n"
  416. msg=${msg}"swap : ${swapdev}\n"
  417. msg=${msg}"root : ${rootdev}\n"
  418. msg=${msg}"home : ${homedev}\n\n"
  419. if (whiptail --backtitle "${apptitle}" --title "${txtselectpartsmenu}" --yesno "${msg}" 0 0); then
  420. isnvme=0
  421. if [ "${bootdev::8}" == "/dev/nvm" ]; then
  422. isnvme=1
  423. fi
  424. if [ "${rootdev::8}" == "/dev/nvm" ]; then
  425. isnvme=1
  426. fi
  427. mountmenu
  428. fi
  429. }
  430. # --------------------------------------------------------
  431. # --------------------------------------------------------
  432. mountmenu(){
  433. if [ "${1}" = "" ]; then
  434. nextitem="."
  435. else
  436. nextitem=${1}
  437. fi
  438. options=()
  439. options+=("${txtformatdevices}" "")
  440. options+=("${txtmount}" "${txtmountdesc}")
  441. sel=$(whiptail --backtitle "${apptitle}" --title "${txtformatmountmenu}" --menu "" --cancel-button "${txtback}" --default-item "${nextitem}" 0 0 0 \
  442. "${options[@]}" \
  443. 3>&1 1>&2 2>&3)
  444. if [ "$?" = "0" ]; then
  445. case ${sel} in
  446. "${txtformatdevices}")
  447. formatdevices
  448. nextitem="${txtmount}"
  449. ;;
  450. "${txtmount}")
  451. mountparts
  452. nextitem="${txtmount}"
  453. ;;
  454. esac
  455. mountmenu "${nextitem}"
  456. fi
  457. }
  458. formatdevices(){
  459. if (whiptail --backtitle "${apptitle}" --title "${txtformatdevices}" --yesno "${txtformatdeviceconfirm}" --defaultno 0 0); then
  460. fspkgs=""
  461. if [ ! "${bootdev}" = "" ]; then
  462. formatbootdevice boot "${bootdev}"
  463. fi
  464. if [ ! "${swapdev}" = "" ]; then
  465. formatswapdevice swap" ${swapdev}"
  466. fi
  467. formatdevice root "${rootdev}"
  468. if [ ! "${homedev}" = "" ]; then
  469. formatdevice home "${homedev}"
  470. fi
  471. fi
  472. }
  473. formatbootdevice(){
  474. options=()
  475. if [ "${efimode}" == "1" ]||[ "${efimode}" = "2" ]; then
  476. options+=("fat32" "(EFI)")
  477. fi
  478. options+=("ext2" "")
  479. options+=("ext3" "")
  480. options+=("ext4" "")
  481. if [ ! "${efimode}" = "1" ]&&[ ! "${efimode}" = "2" ]; then
  482. options+=("fat32" "(EFI)")
  483. fi
  484. sel=$(whiptail --backtitle "${apptitle}" --title "${txtformatdevice}" --menu "${txtselectpartformat//%1/${1} (${2})}" 0 0 0 \
  485. "${options[@]}" \
  486. 3>&1 1>&2 2>&3)
  487. if [ ! "$?" = "0" ]; then
  488. return 1
  489. fi
  490. clear
  491. echo "${txtformatingpart//%1/${2}} ${sel}"
  492. echo "----------------------------------------------"
  493. case ${sel} in
  494. ext2)
  495. echo "mkfs.ext2 ${2}"
  496. mkfs.ext2 "${2}"
  497. ;;
  498. ext3)
  499. echo "mkfs.ext3 ${2}"
  500. mkfs.ext3 "${2}"
  501. ;;
  502. ext4)
  503. echo "mkfs.ext4 ${2}"
  504. mkfs.ext4 "${2}"
  505. ;;
  506. fat32)
  507. fspkgs=("${fspkgs[@]} dosfstools")
  508. echo "mkfs.fat ${2}"
  509. mkfs.fat "${2}"
  510. ;;
  511. esac
  512. echo ""
  513. pressanykey
  514. }
  515. formatswapdevice(){
  516. options=()
  517. options+=("swap" "")
  518. sel=$(whiptail --backtitle "${apptitle}" --title "${txtformatdevice}" --menu "${txtselectpartformat//%1/${1} (${2})}" 0 0 0 \
  519. "${options[@]}" \
  520. 3>&1 1>&2 2>&3)
  521. if [ ! "$?" = "0" ]; then
  522. return 1
  523. fi
  524. clear
  525. echo "${txtformatingpart//%1/${swapdev}} swap"
  526. echo "----------------------------------------------------"
  527. case ${sel} in
  528. swap)
  529. echo "mkswap ${swapdev}"
  530. mkswap "${swapdev}"
  531. echo ""
  532. pressanykey
  533. ;;
  534. esac
  535. clear
  536. }
  537. formatdevice(){
  538. options=()
  539. options+=("btrfs" "")
  540. options+=("ext4" "")
  541. options+=("ext3" "")
  542. options+=("ext2" "")
  543. options+=("xfs" "")
  544. options+=("f2fs" "")
  545. options+=("jfs" "")
  546. options+=("reiserfs" "")
  547. if [ ! "${3}" = "noluks" ]; then
  548. options+=("luks" "encrypted")
  549. fi
  550. sel=$(whiptail --backtitle "${apptitle}" --title "${txtformatdevice}" --menu "${txtselectpartformat//%1/${1} (${2})}" 0 0 0 \
  551. "${options[@]}" \
  552. 3>&1 1>&2 2>&3)
  553. if [ ! "$?" = "0" ]; then
  554. return 1
  555. fi
  556. clear
  557. echo "${txtformatingpart//%1/${2}} ${sel}"
  558. echo "----------------------------------------------"
  559. case ${sel} in
  560. btrfs)
  561. fspkgs=("${fspkgs[@]} btrfs-progs")
  562. echo "mkfs.btrfs -f ${2}"
  563. mkfs.btrfs -f "${2}"
  564. if [ "${1}" = "root" ]; then
  565. echo "mount ${2} /mnt"
  566. echo "btrfs subvolume create /mnt/root"
  567. echo "btrfs subvolume set-default /mnt/root"
  568. echo "umount /mnt"
  569. mount "${2}" /mnt
  570. btrfs subvolume create /mnt/root
  571. btrfs subvolume set-default /mnt/root
  572. umount /mnt
  573. fi
  574. ;;
  575. ext4)
  576. echo "mkfs.ext4 ${2}"
  577. mkfs.ext4 "${2}"
  578. ;;
  579. ext3)
  580. echo "mkfs.ext3 ${2}"
  581. mkfs.ext3 "${2}"
  582. ;;
  583. ext2)
  584. echo "mkfs.ext2 ${2}"
  585. mkfs.ext2 "${2}"
  586. ;;
  587. xfs)
  588. fspkgs=("${fspkgs[@]} xfsprogs")
  589. echo "mkfs.xfs -f ${2}"
  590. mkfs.xfs -f "${2}"
  591. ;;
  592. f2fs)
  593. fspkgs=("${fspkgs[@]} f2fs-tools")
  594. echo "mkfs.f2fs -f $2"
  595. mkfs.f2fs -f "${2}"
  596. ;;
  597. jfs)
  598. fspkgs=("${fspkgs[@]} jfsutils")
  599. echo "mkfs.jfs -f ${2}"
  600. mkfs.jfs -f "${2}"
  601. ;;
  602. reiserfs)
  603. fspkgs=("${fspkgs[@]} reiserfsprogs")
  604. echo "mkfs.reiserfs -f ${2}"
  605. mkfs.reiserfs -f "${2}"
  606. ;;
  607. luks)
  608. echo "${txtcreateluksdevice}"
  609. echo "cryptsetup luksFormat ${2}"
  610. cryptsetup luksFormat "${2}"
  611. if [ ! "$?" = "0" ]; then
  612. pressanykey
  613. return 1
  614. fi
  615. pressanykey
  616. echo ""
  617. echo "${txtopenluksdevice}"
  618. echo "cryptsetup luksOpen ${2} ${1}"
  619. cryptsetup luksOpen "${2}" "${1}"
  620. if [ ! "$?" = "0" ]; then
  621. pressanykey
  622. return 1
  623. fi
  624. pressanykey
  625. options=()
  626. options+=("normal" "")
  627. options+=("fast" "")
  628. sel=$(whiptail --backtitle "${apptitle}" --title "${txtformatdevice}" --menu "Wipe device ?" --cancel-button="${txtignore}" 0 0 0 \
  629. "${options[@]}" \
  630. 3>&1 1>&2 2>&3)
  631. if [ "$?" = "0" ]; then
  632. case ${sel} in
  633. normal)
  634. echo "dd if=/dev/zero of=/dev/mapper/${1}"
  635. dd if=/dev/zero of=/dev/mapper/"${1}" & PID=$! &>/dev/null
  636. ;;
  637. fast)
  638. echo "dd if=/dev/zero of=/dev/mapper/${1} bs=60M"
  639. dd if=/dev/zero of=/dev/mapper/"${1}" bs=60M & PID=$! &>/dev/null
  640. ;;
  641. esac
  642. clear
  643. sleep 1
  644. while kill -USR1 ${PID} &>/dev/null
  645. do
  646. sleep 1
  647. done
  648. fi
  649. echo ""
  650. pressanykey
  651. formatdevice "${1}" /dev/mapper/"${1}" noluks
  652. if [ "${1}" = "root" ]; then
  653. realrootdev=${rootdev}
  654. rootdev=/dev/mapper/${1}
  655. luksroot=1
  656. luksrootuuid=$(cryptsetup luksUUID "${2}")
  657. else
  658. case ${1} in
  659. home) homedev=/dev/mapper/"${1}" ;;
  660. esac
  661. luksdrive=1
  662. crypttab="\n${1} UUID=$(cryptsetup luksUUID "${2}") none"
  663. fi
  664. echo ""
  665. echo "${txtluksdevicecreated}"
  666. ;;
  667. esac
  668. echo ""
  669. pressanykey
  670. }
  671. mountparts(){
  672. clear
  673. echo "mount ${rootdev} /mnt"
  674. mount "${rootdev}" /mnt
  675. echo "mkdir /mnt/{boot,home}"
  676. mkdir /mnt/{boot,home} 2>/dev/null
  677. if [ ! "${bootdev}" = "" ]; then
  678. echo "mount ${bootdev} /mnt/boot"
  679. mount "${bootdev}" /mnt/boot
  680. fi
  681. if [ ! "${swapdev}" = "" ]; then
  682. echo "swapon ${swapdev}"
  683. swapon "${swapdev}"
  684. fi
  685. if [ ! "${homedev}" = "" ]; then
  686. echo "mount ${homedev} /mnt/home"
  687. mount "${homedev}" /mnt/home
  688. fi
  689. pressanykey
  690. installmenu
  691. }
  692. # --------------------------------------------------------
  693. # --------------------------------------------------------
  694. installmenu(){
  695. if [ "${1}" = "" ]; then
  696. nextitem="${txtinstallhyperbola}"
  697. else
  698. nextitem=${1}
  699. fi
  700. options=()
  701. options+=("${txtselectmirrorsbycountry}" "(${txtoptional})")
  702. options+=("${txteditmirrorlist}" "(${txtoptional})")
  703. options+=("${txteditpacmanconf}" "(${txtoptional})")
  704. options+=("${txtinstallhyperbola}" "pacstrap")
  705. options+=("${txtconfighyperbola}" "")
  706. sel=$(whiptail --backtitle "${apptitle}" --title "${txtinstallmenu}" --menu "" --cancel-button "${txtunmount}" --default-item "${nextitem}" 0 0 0 \
  707. "${options[@]}" \
  708. 3>&1 1>&2 2>&3)
  709. if [ "$?" = "0" ]; then
  710. case ${sel} in
  711. "${txtselectmirrorsbycountry}")
  712. selectmirrorsbycountry
  713. nextitem="${txtinstallhyperbola}"
  714. ;;
  715. "${txteditmirrorlist}")
  716. ${EDITOR} /etc/pacman.d/mirrorlist
  717. nextitem="${txtinstallhyperbola}"
  718. ;;
  719. "${txteditpacmanconf}")
  720. ${EDITOR} /etc/pacman.conf
  721. nextitem="${txtinstallhyperbola}"
  722. ;;
  723. "${txtinstallhyperbola}")
  724. if(installbase); then
  725. nextitem="${txtconfighyperbola}"
  726. fi
  727. ;;
  728. "${txtconfighyperbola}")
  729. archmenu
  730. nextitem="${txtconfighyperbola}"
  731. ;;
  732. esac
  733. installmenu "${nextitem}"
  734. else
  735. unmountdevices
  736. fi
  737. }
  738. selectmirrorsbycountry() {
  739. if [[ ! -f /etc/pacman.d/mirrorlist.backup ]]; then
  740. cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
  741. fi
  742. items=$( sed -n "/^##.*/N; {s/^## \(.*\)\nServer.*/\1/p}" < /etc/pacman.d/mirrorlist.backup | sort -u )
  743. options=()
  744. IFS_ORIG=$IFS
  745. IFS=$'\n'
  746. for item in ${items}; do
  747. options+=("${item}" "")
  748. done
  749. IFS=$IFS_ORIG
  750. country=$(whiptail --backtitle "${apptitle}" --title "${txtselectcountry}" --menu "" 0 0 0 "${options[@]}" 3>&1 1>&2 2>&3)
  751. if [ "$?" != "0" ]; then
  752. return 1
  753. fi
  754. sed "s/^\(Server .*\)/\#\1/;/^## $country/N; {s/^\(## .*\n\)\#Server \(.*\)/\1Server \2/}" < /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist
  755. }
  756. installbase(){
  757. pkgs="base"
  758. options=()
  759. options+=("linux-libre-lts" "")
  760. sel=$(whiptail --backtitle "${apptitle}" --title "${txtinstallhyperbolakernel}" --menu "" 0 0 0 \
  761. "${options[@]}" \
  762. 3>&1 1>&2 2>&3)
  763. if [ "$?" = "0" ]; then
  764. pkgs+=" ${sel}"
  765. else
  766. return 1
  767. fi
  768. options=()
  769. options+=("kernel-firmware" "(${txtoptional})" on)
  770. sel=$(whiptail --backtitle "${apptitle}" --title "${txtinstallhyperbolafirmwares}" --checklist "" 0 0 0 \
  771. "${options[@]}" \
  772. 3>&1 1>&2 2>&3)
  773. if [ ! "$?" = "0" ]; then
  774. return 1
  775. fi
  776. for itm in $sel; do
  777. pkgs="$pkgs ${itm//\"/}"
  778. done
  779. options=()
  780. for value in "${fspkgs[@]}"; do
  781. if [[ "${value}" == *"dosfstools"* ]]; then
  782. options+=("dosfstools" "" on)
  783. else
  784. options+=("dosfstools" "" off)
  785. fi
  786. if [[ "${value}" == *"btrfs-progs"* ]]; then
  787. options+=("btrfs-progs" "" on)
  788. else
  789. options+=("btrfs-progs" "" off)
  790. fi
  791. if [[ "${value}" == *"xfsprogs"* ]]; then
  792. options+=("xfsprogs" "" on)
  793. else
  794. options+=("xfsprogs" "" off)
  795. fi
  796. if [[ "${value}" == *"f2fs-tools"* ]]; then
  797. options+=("f2fs-tools" "" on)
  798. else
  799. options+=("f2fs-tools" "" off)
  800. fi
  801. if [[ "${value}" == *"jfsutils"* ]]; then
  802. options+=("jfsutils" "" on)
  803. else
  804. options+=("jfsutils" "" off)
  805. fi
  806. if [[ "${value}" == *"reiserfsprogs"* ]]; then
  807. options+=("reiserfsprogs" "" on)
  808. else
  809. options+=("reiserfsprogs" "" off)
  810. fi
  811. done
  812. options+=("lvm2" "" off)
  813. options+=("dmraid" "" off)
  814. sel=$(whiptail --backtitle "${apptitle}" --title "${txtinstallhyperbolafilesystems}" --checklist "" 0 0 0 \
  815. "${options[@]}" \
  816. 3>&1 1>&2 2>&3)
  817. if [ ! "$?" = "0" ]; then
  818. return 1
  819. fi
  820. for itm in $sel; do
  821. pkgs="$pkgs ${itm//\"/}"
  822. done
  823. if [[ ${cpl} == 1 ]]; then
  824. sed -i '/^\s*$/d' /tmp/hyperfi-custom-package-list
  825. sed -i '/^#/ d' /tmp/hyperfi-custom-package-list
  826. options=()
  827. while read -r pkg; do
  828. options+=("${pkg}" "" on)
  829. done < /tmp/hyperfi-custom-package-list
  830. sel=$(whiptail --backtitle "${apptitle}" --title "${txtinstallhyperbolacustompackagelist}" --checklist "" 0 0 0 \
  831. "${options[@]}" \
  832. 3>&1 1>&2 2>&3)
  833. if [ ! "$?" = "0" ]; then
  834. return 1
  835. fi
  836. for itm in $sel; do
  837. pkgs="$pkgs ${itm//\"/}"
  838. done
  839. fi
  840. clear
  841. echo "pacstrap /mnt ${pkgs}"
  842. # shellcheck disable=SC2086
  843. pacstrap /mnt ${pkgs}
  844. pressanykey
  845. }
  846. unmountdevices(){
  847. clear
  848. echo "umount -R /mnt"
  849. umount -R /mnt
  850. if [ ! "${swapdev}" = "" ]; then
  851. echo "swapoff ${swapdev}"
  852. swapoff "${swapdev}"
  853. fi
  854. pressanykey
  855. }
  856. # --------------------------------------------------------
  857. # --------------------------------------------------------
  858. archmenu(){
  859. if [ "${1}" = "" ]; then
  860. nextitem="."
  861. else
  862. nextitem=${1}
  863. fi
  864. options=()
  865. options+=("${txtsethostname}" "/etc/hostname")
  866. options+=("${txtsetkeymap}" "/etc/vconsole.conf")
  867. options+=("${txtsetfont}" "/etc/vconsole.conf (${txtoptional})")
  868. options+=("${txtsetlocale}" "/etc/locale.conf, /etc/locale.gen")
  869. options+=("${txtsettime}" "/etc/localtime")
  870. options+=("${txtsetrootpassword}" "")
  871. options+=("${txtgenerate//%1/fstab}" "")
  872. if [ "${luksdrive}" = "1" ]; then
  873. options+=("${txtgenerate//%1/crypttab}" "")
  874. fi
  875. if [ "${luksroot}" = "1" ]; then
  876. options+=("${txtgenerate//%1/mkinitcpio.conf-luks}" "(encrypt hooks)")
  877. fi
  878. if [ "${isnvme}" = "1" ]; then
  879. options+=("${txtgenerate//%1/mkinitcpio.conf-nvme}" "(nvme module)")
  880. fi
  881. options+=("${txtedit//%1/fstab}" "(${txtoptional})")
  882. options+=("${txtedit//%1/crypttab}" "(${txtoptional})")
  883. options+=("${txtedit//%1/mkinitcpio.conf}" "(${txtoptional})")
  884. options+=("${txtedit//%1/mirrorlist}" "(${txtoptional})")
  885. options+=("${txtedit//%1/pacman.conf}" "(${txtoptional})")
  886. options+=("${txtbootloader}" "")
  887. options+=("${txtextrasmenu}" "")
  888. options+=("hyperdi" "${txthyperdidesc}")
  889. sel=$(whiptail --backtitle "${apptitle}" --title "${txthyperbolainstallmenu}" --menu "" --cancel-button "${txtback}" --default-item "${nextitem}" 0 0 0 \
  890. "${options[@]}" \
  891. 3>&1 1>&2 2>&3)
  892. if [ "$?" = "0" ]; then
  893. case ${sel} in
  894. "${txtsethostname}")
  895. archsethostname
  896. nextitem="${txtsetkeymap}"
  897. ;;
  898. "${txtsetkeymap}")
  899. archsetkeymap
  900. nextitem="${txtsetlocale}"
  901. ;;
  902. "${txtsetfont}")
  903. archsetfont
  904. nextitem="${txtsetlocale}"
  905. ;;
  906. "${txtsetlocale}")
  907. archsetlocale
  908. nextitem="${txtsettime}"
  909. ;;
  910. "${txtsettime}")
  911. archsettime
  912. nextitem="${txtsetrootpassword}"
  913. ;;
  914. "${txtsetrootpassword}")
  915. archsetrootpassword
  916. nextitem="${txtgenerate//%1/fstab}"
  917. ;;
  918. "${txtgenerate//%1/fstab}")
  919. archgenfstabmenu
  920. if [ "${luksdrive}" = "1" ]; then
  921. nextitem="${txtgenerate//%1/crypttab}"
  922. else
  923. if [ "${luksroot}" = "1" ]; then
  924. nextitem="${txtgenerate//%1/mkinitcpio.conf-luks}"
  925. else
  926. if [ "${isnvme}" = "1" ]; then
  927. nextitem="${txtgenerate//%1/mkinitcpio.conf-nvme}"
  928. else
  929. nextitem="${txtbootloader}"
  930. fi
  931. fi
  932. fi
  933. ;;
  934. "${txtgenerate//%1/crypttab}")
  935. archgencrypttab
  936. if [ "${luksroot}" = "1" ]; then
  937. nextitem="${txtgenerate//%1/mkinitcpio.conf-luks}"
  938. else
  939. if [ "${isnvme}" = "1" ]; then
  940. nextitem="${txtgenerate//%1/mkinitcpio.conf-nvme}"
  941. else
  942. nextitem="${txtbootloader}"
  943. fi
  944. fi
  945. ;;
  946. "${txtgenerate//%1/mkinitcpio.conf-luks}")
  947. archgenmkinitcpioluks
  948. if [ "${isnvme}" = "1" ]; then
  949. nextitem="${txtgenerate//%1/mkinitcpio.conf-nvme}"
  950. else
  951. nextitem="${txtbootloader}"
  952. fi
  953. ;;
  954. "${txtgenerate//%1/mkinitcpio.conf-nvme}")
  955. archgenmkinitcpionvme
  956. nextitem="${txtbootloader}"
  957. ;;
  958. "${txtedit//%1/fstab}")
  959. ${EDITOR} /mnt/etc/fstab
  960. nextitem="${txtedit//%1/fstab}"
  961. ;;
  962. "${txtedit//%1/crypttab}")
  963. ${EDITOR} /mnt/etc/crypttab
  964. nextitem="${txtedit//%1/crypttab}"
  965. ;;
  966. "${txtedit//%1/mkinitcpio.conf}")
  967. archeditmkinitcpio
  968. nextitem="${txtedit//%1/mkinitcpio.conf}"
  969. ;;
  970. "${txtedit//%1/mirrorlist}")
  971. ${EDITOR} /mnt/etc/pacman.d/mirrorlist
  972. nextitem="${txtedit//%1/mirrorlist}"
  973. ;;
  974. "${txtedit//%1/pacman.conf}")
  975. ${EDITOR} /mnt/etc/pacman.conf
  976. nextitem="${txtedit//%1/pacman.conf}"
  977. ;;
  978. "${txtbootloader}")
  979. archbootloadermenu
  980. nextitem="${txtextrasmenu}"
  981. ;;
  982. "${txtextrasmenu}")
  983. archextrasmenu
  984. nextitem="hyperdi"
  985. ;;
  986. "hyperdi")
  987. installhyperdi
  988. nextitem="hyperdi"
  989. ;;
  990. esac
  991. archmenu "${nextitem}"
  992. fi
  993. }
  994. archchroot(){
  995. echo "arch-chroot /mnt /root"
  996. cp "${0}" /mnt/root
  997. chmod 755 /mnt/root/"$(basename "${0}")"
  998. arch-chroot /mnt /root/"$(basename "${0}")" --chroot "${1}" "${2}"
  999. rm /mnt/root/"$(basename "${0}")"
  1000. echo "exit"
  1001. }
  1002. archsethostname(){
  1003. hostname=$(whiptail --backtitle "${apptitle}" --title "${txtsethostname}" --inputbox "" 0 0 "hyperbola" 3>&1 1>&2 2>&3)
  1004. if [ "$?" = "0" ]; then
  1005. clear
  1006. echo "echo \"${hostname}\" > /mnt/etc/hostname"
  1007. echo "${hostname}" > /mnt/etc/hostname
  1008. pressanykey
  1009. fi
  1010. }
  1011. archsetkeymap(){
  1012. items=$(find /usr/share/kbd/keymaps/ -type f -printf "%f\n" | sort -V)
  1013. options=()
  1014. defsel=""
  1015. for item in ${items}; do
  1016. if [ "${item%%.*}" == "${keymap}" ]; then
  1017. defsel="${item%%.*}"
  1018. fi
  1019. options+=("${item%%.*}" "")
  1020. done
  1021. keymap=$(whiptail --backtitle "${apptitle}" --title "${txtsetkeymap}" --menu "" --default-item "${defsel}" 0 0 0 \
  1022. "${options[@]}" \
  1023. 3>&1 1>&2 2>&3)
  1024. if [ "$?" = "0" ]; then
  1025. clear
  1026. echo "echo \"KEYMAP=${keymap}\" > /mnt/etc/vconsole.conf"
  1027. echo "KEYMAP=${keymap}" > /mnt/etc/vconsole.conf
  1028. echo "sed -e \"s|^keymap=\\\"us\\\"|keymap=\\\"${keymap}\\\"|g\" -i /mnt/etc/conf.d/keymaps"
  1029. sed -e "s|^keymap=\"us\"|keymap=\"${keymap}\"|g" -i /mnt/etc/conf.d/keymaps
  1030. pressanykey
  1031. fi
  1032. }
  1033. archsetfont(){
  1034. items=$(find /usr/share/kbd/consolefonts/*.psfu.gz -printf "%f\n")
  1035. options=()
  1036. for item in ${items}; do
  1037. options+=("${item%%.*}" "")
  1038. done
  1039. vcfont=$(whiptail --backtitle "${apptitle}" --title "${txtsetfont} (${txtoptional})" --menu "" 0 0 0 \
  1040. "${options[@]}" \
  1041. 3>&1 1>&2 2>&3)
  1042. if [ "$?" = "0" ]; then
  1043. clear
  1044. echo "echo \"FONT=${vcfont}\" >> /mnt/etc/vconsole.conf"
  1045. echo "FONT=${vcfont}" >> /mnt/etc/vconsole.conf
  1046. pressanykey
  1047. fi
  1048. }
  1049. archsetlocale(){
  1050. items=$(ls /usr/share/i18n/locales)
  1051. options=()
  1052. defsel=""
  1053. for item in ${items}; do
  1054. if [ "${defsel}" == "" ]&&[ "${keymap::2}" == "${item::2}" ]; then
  1055. defsel="${item}"
  1056. fi
  1057. options+=("${item}" "")
  1058. done
  1059. locale=$(whiptail --backtitle "${apptitle}" --title "${txtsetlocale}" --menu "" --default-item "${defsel}" 0 0 0 \
  1060. "${options[@]}" \
  1061. 3>&1 1>&2 2>&3)
  1062. if [ "$?" = "0" ]; then
  1063. clear
  1064. echo "echo \"LANG=${locale}.UTF-8\" > /mnt/etc/locale.conf"
  1065. echo "LANG=${locale}.UTF-8" > /mnt/etc/locale.conf
  1066. echo "echo \"LC_COLLATE=C\" >> /mnt/etc/locale.conf"
  1067. echo "LC_COLLATE=C" >> /mnt/etc/locale.conf
  1068. echo "sed -i '/#${locale}.UTF-8/s/^#//g' /mnt/etc/locale.gen"
  1069. sed -i '/#'"${locale}"'.UTF-8/s/^#//g' /mnt/etc/locale.gen
  1070. archchroot setlocale
  1071. pressanykey
  1072. fi
  1073. }
  1074. archsetlocalechroot(){
  1075. echo "locale-gen"
  1076. locale-gen
  1077. exit
  1078. }
  1079. archsettime(){
  1080. items=$(find /usr/share/zoneinfo/ -mindepth 1 -maxdepth 1 -type d -printf '%f/\n' | sort)
  1081. options=()
  1082. for item in ${items}; do
  1083. options+=("${item}" "")
  1084. done
  1085. timezone=$(whiptail --backtitle "${apptitle}" --title "${txtsettime}" --menu "" 0 0 0 \
  1086. "${options[@]}" \
  1087. 3>&1 1>&2 2>&3)
  1088. if [ ! "$?" = "0" ]; then
  1089. return 1
  1090. fi
  1091. items=$(ls /mnt/usr/share/zoneinfo/"${timezone}"/)
  1092. options=()
  1093. for item in ${items}; do
  1094. options+=("${item}" "")
  1095. done
  1096. timezone=${timezone}/$(whiptail --backtitle "${apptitle}" --title "${txtsettime}" --menu "" 0 0 0 \
  1097. "${options[@]}" \
  1098. 3>&1 1>&2 2>&3)
  1099. if [ ! "$?" = "0" ]; then
  1100. return 1
  1101. fi
  1102. clear
  1103. echo "ln -sf /mnt/usr/share/zoneinfo/${timezone} /mnt/etc/localtime"
  1104. ln -sf /usr/share/zoneinfo/"${timezone}" /mnt/etc/localtime
  1105. pressanykey
  1106. options=()
  1107. options+=("UTC" "")
  1108. options+=("Local" "")
  1109. sel=$(whiptail --backtitle "${apptitle}" --title "${txtsettime}" --menu "${txthwclock}" 0 0 0 \
  1110. "${options[@]}" \
  1111. 3>&1 1>&2 2>&3)
  1112. if [ ! "$?" = "0" ]; then
  1113. return 1
  1114. fi
  1115. clear
  1116. case ${sel} in
  1117. "${txthwclockutc}")
  1118. archchroot settimeutc
  1119. ;;
  1120. "${txthwclocklocal}")
  1121. archchroot settimelocal
  1122. ;;
  1123. esac
  1124. pressanykey
  1125. }
  1126. archsettimeutcchroot(){
  1127. echo "hwclock --systohc --utc"
  1128. hwclock --systohc --utc
  1129. exit
  1130. }
  1131. archsettimelocalchroot(){
  1132. echo "hwclock --systohc --localtime"
  1133. hwclock --systohc --localtime
  1134. exit
  1135. }
  1136. archsetrootpassword(){
  1137. clear
  1138. archchroot setrootpassword
  1139. pressanykey
  1140. }
  1141. archsetrootpasswordchroot(){
  1142. echo "passwd root"
  1143. passed=1
  1144. while [[ ${passed} != 0 ]]; do
  1145. passwd root
  1146. passed=$?
  1147. done
  1148. exit
  1149. }
  1150. archgenfstabmenu(){
  1151. options=()
  1152. options+=("UUID" "genfstab -U")
  1153. options+=("LABEL" "genfstab -L")
  1154. options+=("PARTUUID" "genfstab -t PARTUUID")
  1155. options+=("PARTLABEL" "genfstab -t PARTLABEL")
  1156. sel=$(whiptail --backtitle "${apptitle}" --title "${txtgenerate//%1/fstab}" --menu "" --cancel-button "${txtback}" --default-item "${nextitem}" 0 0 0 \
  1157. "${options[@]}" \
  1158. 3>&1 1>&2 2>&3)
  1159. if [ "$?" = "0" ]; then
  1160. case ${sel} in
  1161. "UUID")
  1162. clear
  1163. echo "genfstab -U -p /mnt > /mnt/etc/fstab"
  1164. genfstab -U -p /mnt > /mnt/etc/fstab
  1165. ;;
  1166. "LABEL")
  1167. clear
  1168. echo "genfstab -L -p /mnt > /mnt/etc/fstab"
  1169. genfstab -L -p /mnt > /mnt/etc/fstab
  1170. ;;
  1171. "PARTUUID")
  1172. clear
  1173. echo "genfstab -t PARTUUID -p /mnt > /mnt/etc/fstab"
  1174. genfstab -t PARTUUID -p /mnt > /mnt/etc/fstab
  1175. ;;
  1176. "PARTLABEL")
  1177. clear
  1178. echo "genfstab -t PARTLABEL -p /mnt > /mnt/etc/fstab"
  1179. genfstab -t PARTLABEL -p /mnt > /mnt/etc/fstab
  1180. ;;
  1181. esac
  1182. fi
  1183. pressanykey
  1184. }
  1185. archgencrypttab(){
  1186. clear
  1187. echo "echo -e \"${crypttab}\" >> /mnt/etc/crypttab"
  1188. echo -e "${crypttab}" >> /mnt/etc/crypttab
  1189. pressanykey
  1190. }
  1191. archgenmkinitcpioluks(){
  1192. clear
  1193. echo "sed -i \"s/block filesystems/block encrypt filesystems/g\" /mnt/etc/mkinitcpio.conf"
  1194. sed -i "s/block filesystems/block encrypt filesystems/g" /mnt/etc/mkinitcpio.conf
  1195. archchroot genmkinitcpio
  1196. pressanykey
  1197. }
  1198. archgenmkinitcpionvme(){
  1199. clear
  1200. echo "sed -i \"s/MODULES=()/MODULES=(nvme)/g\" /mnt/etc/mkinitcpio.conf"
  1201. sed -i "s/MODULES=()/MODULES=(nvme)/g" /mnt/etc/mkinitcpio.conf
  1202. archchroot genmkinitcpio
  1203. pressanykey
  1204. }
  1205. archeditmkinitcpio(){
  1206. ${EDITOR} /mnt/etc/mkinitcpio.conf
  1207. if (whiptail --backtitle "${apptitle}" --title "${txtedit//%1/mkinitcpio.conf}" --yesno "${txtgenerate//%1/mkinitcpio} ?" 0 0); then
  1208. clear
  1209. archchroot genmkinitcpio
  1210. pressanykey
  1211. fi
  1212. }
  1213. archgenmkinitcpiochroot(){
  1214. echo "mkinitcpio -p linux-libre-lts"
  1215. mkinitcpio -p linux-libre-lts
  1216. exit
  1217. }
  1218. archbootloadermenu(){
  1219. options=()
  1220. options+=("grub" "")
  1221. if [ "${efimode}" == "1" ]; then
  1222. options+=("refind" "")
  1223. fi
  1224. if [ "${efimode}" != "2" ]; then
  1225. options+=("syslinux" "")
  1226. fi
  1227. sel=$(whiptail --backtitle "${apptitle}" --title "${txtbootloadermenu}" --menu "" --cancel-button "${txtback}" 0 0 0 \
  1228. "${options[@]}" \
  1229. 3>&1 1>&2 2>&3)
  1230. if [ "$?" = "0" ]; then
  1231. case ${sel} in
  1232. "grub") archbootloadergrubmenu;;
  1233. "refind") archbootloaderrefindmenu;;
  1234. "syslinux")archbootloadersyslinuxbmenu;;
  1235. esac
  1236. fi
  1237. }
  1238. archbootloadergrubmenu(){
  1239. if [ "${1}" = "" ]; then
  1240. nextblitem="."
  1241. else
  1242. nextblitem=${1}
  1243. fi
  1244. options=()
  1245. options+=("${txtinstall//%1/grub}" "pacstrap grub (efibootmgr), grub-mkconfig")
  1246. options+=("${txtedit//%1/grub}" "(${txtoptional})")
  1247. options+=("${txtinstall//%1/bootloader}" "grub-install")
  1248. sel=$(whiptail --backtitle "${apptitle}" --title "${txtbootloadergrubmenu}" --menu "" --cancel-button "${txtback}" --default-item "${nextblitem}" 0 0 0 \
  1249. "${options[@]}" \
  1250. 3>&1 1>&2 2>&3)
  1251. if [ "$?" = "0" ]; then
  1252. case ${sel} in
  1253. "${txtinstall//%1/grub}")
  1254. archgrubinstall
  1255. nextblitem="${txtinstall//%1/bootloader}"
  1256. ;;
  1257. "${txtedit//%1/grub}")
  1258. ${EDITOR} /mnt/etc/default/grub
  1259. if (whiptail --backtitle "${apptitle}" --title "${txtedit//%1/grub}" --yesno "${txtrungrubmakeconfig}" 0 0) ; then
  1260. clear
  1261. archchroot grubinstall
  1262. pressanykey
  1263. fi
  1264. nextblitem="${txtinstall//%1/bootloader}"
  1265. ;;
  1266. "${txtinstall//%1/bootloader}")
  1267. archgrubinstallbootloader
  1268. nextblitem="${txtinstall//%1/bootloader}"
  1269. ;;
  1270. esac
  1271. archbootloadergrubmenu "${nextblitem}"
  1272. fi
  1273. }
  1274. archgrubinstall(){
  1275. clear
  1276. echo "pacstrap /mnt grub"
  1277. pacstrap /mnt grub
  1278. pressanykey
  1279. if [ "${eficomputer}" == "1" ]; then
  1280. if [ "${efimode}" == "1" ]||[ "${efimode}" == "2" ]; then
  1281. if (whiptail --backtitle "${apptitle}" --title "${txtinstall//%1/efibootmgr}" --yesno "${txtefibootmgr}" 0 0) ; then
  1282. clear
  1283. echo "pacstrap /mnt efibootmgr"
  1284. pacstrap /mnt efibootmgr
  1285. pressanykey
  1286. fi
  1287. else
  1288. if (whiptail --backtitle "${apptitle}" --title "${txtinstall//%1/efibootmgr}" --yesno "${txtefibootmgr}" --defaultno 0 0) ; then
  1289. clear
  1290. echo "pacstrap /mnt efibootmgr"
  1291. pacstrap /mnt efibootmgr
  1292. pressanykey
  1293. fi
  1294. fi
  1295. fi
  1296. if [ "${luksroot}" = "1" ]; then
  1297. if (whiptail --backtitle "${apptitle}" --title "${txtinstall//%1/grub}" --yesno "${txtgrubluksdetected}" 0 0) ; then
  1298. clear
  1299. echo "sed -e \"s|GRUB_CMDLINE_LINUX=\\\"\\\"|GRUB_CMDLINE_LINUX=\\\"cryptdevice=/dev/disk/by-uuid/${luksrootuuid}:root\\\"|g\" -i /mnt/etc/default/grub"
  1300. sed -e "s|GRUB_CMDLINE_LINUX=\"\"|GRUB_CMDLINE_LINUX=\"cryptdevice=/dev/disk/by-uuid/${luksrootuuid}:root\"|g" -i /mnt/etc/default/grub
  1301. pressanykey
  1302. fi
  1303. fi
  1304. clear
  1305. archchroot grubinstall
  1306. pressanykey
  1307. }
  1308. archgrubinstallchroot(){
  1309. echo "mkdir /boot/grub"
  1310. echo "grub-mkconfig -o /boot/grub/grub.cfg"
  1311. mkdir /boot/grub
  1312. grub-mkconfig -o /boot/grub/grub.cfg
  1313. exit
  1314. }
  1315. archgrubinstallbootloader(){
  1316. device=$( selectdisk "${txtinstall//%1/bootloader}" )
  1317. if [ "$?" = "0" ]; then
  1318. if [ "${eficomputer}" == "1" ]; then
  1319. options=()
  1320. if [ "${efimode}" = "1" ]; then
  1321. options+=("EFI" "")
  1322. options+=("BIOS" "")
  1323. options+=("BIOS+EFI" "")
  1324. elif [ "${efimode}" = "2" ]; then
  1325. options+=("BIOS+EFI" "")
  1326. options+=("BIOS" "")
  1327. options+=("EFI" "")
  1328. else
  1329. options+=("BIOS" "")
  1330. options+=("EFI" "")
  1331. options+=("BIOS+EFI" "")
  1332. fi
  1333. sel=$(whiptail --backtitle "${apptitle}" --title "${txtinstall//%1/bootloader}" --menu "" --cancel-button "${txtback}" 0 0 0 \
  1334. "${options[@]}" \
  1335. 3>&1 1>&2 2>&3)
  1336. if [ "$?" = "0" ]; then
  1337. clear
  1338. case ${sel} in
  1339. "BIOS") archchroot grubbootloaderinstall "${device}";;
  1340. "EFI") archchroot grubbootloaderefiinstall "${device}";;
  1341. "BIOS+EFI") archchroot grubbootloaderefiusbinstall "${device}";;
  1342. esac
  1343. pressanykey
  1344. fi
  1345. else
  1346. clear
  1347. archchroot grubbootloaderinstall "${device}"
  1348. pressanykey
  1349. fi
  1350. fi
  1351. }
  1352. archgrubinstallbootloaderchroot(){
  1353. if [ ! "${1}" = "none" ]; then
  1354. echo "grub-install --target=i386-pc --recheck ${1}"
  1355. grub-install --target=i386-pc --recheck "${1}"
  1356. fi
  1357. exit
  1358. }
  1359. archgrubinstallbootloaderefichroot(){
  1360. if [ ! "${1}" = "none" ]; then
  1361. echo "grub-install --target=x86_64-efi --efi-directory=/boot --recheck ${1}"
  1362. grub-install --target=x86_64-efi --efi-directory=/boot --recheck "${1}"
  1363. isvbox=$(lspci | grep "VirtualBox G")
  1364. if [ "${isvbox}" ]; then
  1365. echo "VirtualBox detected, creating startup.nsh..."
  1366. printf '%s' '\EFI\arch\grubx64.efi' > /boot/startup.nsh
  1367. fi
  1368. fi
  1369. exit
  1370. }
  1371. archgrubinstallbootloaderefiusbchroot(){
  1372. if [ ! "${1}" = "none" ]; then
  1373. echo "grub-install --target=i386-pc --recheck ${1}"
  1374. grub-install --target=i386-pc --recheck "${1}"
  1375. echo "grub-install --target=x86_64-efi --efi-directory=/boot --removable --recheck ${1}"
  1376. grub-install --target=x86_64-efi --efi-directory=/boot --removable --recheck "${1}"
  1377. isvbox=$(lspci | grep "VirtualBox G")
  1378. if [ "${isvbox}" ]; then
  1379. echo "VirtualBox detected, creating startup.nsh..."
  1380. printf '%s' '\EFI\arch\grubx64.efi' > /boot/startup.nsh
  1381. fi
  1382. fi
  1383. exit
  1384. }
  1385. archbootloadersyslinuxbmenu(){
  1386. if [ "${1}" = "" ]; then
  1387. nextblitem="."
  1388. else
  1389. nextblitem=${1}
  1390. fi
  1391. options=()
  1392. options+=("${txtinstall//%1/syslinux}" "pacstrap syslinux (gptfdisk,mtools)")
  1393. options+=("${txtedit//%1/syslinux}" "(${txtoptional})")
  1394. options+=("${txtinstall//%1/bootloader}" "syslinux-install_update")
  1395. sel=$(whiptail --backtitle "${apptitle}" --title "${txtbootloadersyslinuxmenu}" --menu "" --cancel-button "${txtback}" --default-item "${nextblitem}" 0 0 0 \
  1396. "${options[@]}" \
  1397. 3>&1 1>&2 2>&3)
  1398. if [ "$?" = "0" ]; then
  1399. case ${sel} in
  1400. "${txtinstall//%1/syslinux}")
  1401. archsyslinuxinstall
  1402. nextblitem="${txtinstall//%1/bootloader}"
  1403. ;;
  1404. "${txtedit//%1/syslinux}")
  1405. ${EDITOR} /mnt/boot/syslinux/syslinux.cfg
  1406. nextblitem="${txtinstall//%1/bootloader}"
  1407. ;;
  1408. "${txtinstall//%1/bootloader}")
  1409. archsyslinuxinstallbootloader
  1410. nextblitem="${txtinstall//%1/bootloader}"
  1411. ;;
  1412. esac
  1413. archbootloadersyslinuxbmenu "${nextblitem}"
  1414. fi
  1415. }
  1416. archsyslinuxinstall(){
  1417. clear
  1418. if [ "${efimode}" == "1" ]||[ "${efimode}" == "2" ]; then
  1419. echo "${txtsyslinuxaddefibootmgr}"
  1420. additionalpkg=${additionalpkg}"efibootmgr "
  1421. fi
  1422. if [ "${isnvme}" = "1" ]; then
  1423. if [ "$(parted "${realrootdev::(-2)}" print|grep gpt)" != "" ]; then
  1424. echo "${txtsyslinuxaddgptfdisk}"
  1425. additionalpkg=${additionalpkg}"gptfdisk "
  1426. fi
  1427. else
  1428. if [ "$(parted "${realrootdev::8}" print|grep gpt)" != "" ]; then
  1429. echo "${txtsyslinuxaddgptfdisk}"
  1430. additionalpkg=${additionalpkg}"gptfdisk "
  1431. fi
  1432. fi
  1433. if [ "${bootdev}" != "" ]; then
  1434. if [ "$(parted "${bootdev}" print|grep fat)" != "" ]; then
  1435. echo "${txtsyslinuxaddmtools}"
  1436. additionalpkg=${additionalpkg}"mtools "
  1437. fi
  1438. fi
  1439. echo "pacstrap /mnt syslinux ${additionalpkg}"
  1440. # shellcheck disable=SC2086
  1441. pacstrap /mnt syslinux ${additionalpkg}
  1442. pressanykey
  1443. clear
  1444. echo "Updating /boot/syslinux/syslinux.cfg"
  1445. if [ "${luksroot}" = "1" ]; then
  1446. echo "sed -i \"/APPEND\ root=/c\ APPEND root=/dev/mapper/root cryptdevice=${realrootdev}:root rw\" /mnt/boot/syslinux/syslinux.cfg"
  1447. sed -i "/APPEND\ root=/c\ APPEND root=/dev/mapper/root cryptdevice=${realrootdev}:root\ rw" /mnt/boot/syslinux/syslinux.cfg
  1448. else
  1449. echo "sed -i \"/APPEND\ root=/c\ APPEND root=${rootdev} rw\" /mnt/boot/syslinux/syslinux.cfg"
  1450. sed -i "/APPEND\ root=/c\ APPEND root=${rootdev}\ rw" /mnt/boot/syslinux/syslinux.cfg
  1451. fi
  1452. pressanykey
  1453. }
  1454. archsyslinuxinstallbootloader(){
  1455. clear
  1456. if [ "${efimode}" == "1" ]||[ "${efimode}" == "2" ]; then
  1457. archchroot syslinuxbootloaderefiinstall "${bootdev}"
  1458. else
  1459. archchroot syslinuxbootloaderinstall "${bootdev}"
  1460. fi
  1461. pressanykey
  1462. }
  1463. archsyslinuxinstallbootloaderchroot(){
  1464. if [ ! "${1}" = "none" ]; then
  1465. echo "syslinux-install_update -i -a -m"
  1466. syslinux-install_update -i -a -m
  1467. fi
  1468. exit
  1469. }
  1470. archsyslinuxinstallbootloaderefichroot(){
  1471. if [ ! "${1}" = "none" ]; then
  1472. echo "cp -r /usr/lib/syslinux/efi64/* /boot/syslinux"
  1473. cp -r /usr/lib/syslinux/efi64/* /boot/syslinux
  1474. if [ "${1::8}" == "/dev/nvm" ]; then
  1475. echo "efibootmgr --create --disk ${1::(-2)} --part ${1:(-1)} --loader /syslinux/syslinux.efi --label \"Syslinux\" --verbose"
  1476. efibootmgr --create --disk "${1::(-2)}" --part "${1:(-1)}" --loader /syslinux/syslinux.efi --label "Syslinux" --verbose
  1477. else
  1478. echo "efibootmgr --create --disk ${1::8} --part ${1:(-1)} --loader /syslinux/syslinux.efi --label \"Syslinux\" --verbose"
  1479. efibootmgr --create --disk "${1::8}" --part "${1:(-1)}" --loader /syslinux/syslinux.efi --label "Syslinux" --verbose
  1480. fi
  1481. isvbox=$(lspci | grep "VirtualBox G")
  1482. if [ "${isvbox}" ]; then
  1483. echo "VirtualBox detected, creating startup.nsh..."
  1484. printf '%s' '\syslinux\syslinux.efi' > /boot/startup.nsh
  1485. fi
  1486. fi
  1487. exit
  1488. }
  1489. archbootloaderrefindmenu(){
  1490. if [ "${1}" = "" ]; then
  1491. nextblitem="."
  1492. else
  1493. nextblitem=${1}
  1494. fi
  1495. options=()
  1496. options+=("${txtinstall//%1/refind}" "pacstrap refind-efi")
  1497. options+=("${txtedit//%1/refind_linux.conf}" "(${txtoptional})")
  1498. sel=$(whiptail --backtitle "${apptitle}" --title "${txtbootloaderrefindmenu}" --menu "" --cancel-button "${txtback}" --default-item "${nextblitem}" 0 0 0 \
  1499. "${options[@]}" \
  1500. 3>&1 1>&2 2>&3)
  1501. if [ "$?" = "0" ]; then
  1502. case ${sel} in
  1503. "${txtinstall//%1/refind}")
  1504. archrefindinstall
  1505. nextblitem="${txtedit//%1/refind_linux.conf}"
  1506. ;;
  1507. "${txtedit//%1/refind_linux.conf}")
  1508. ${EDITOR} /mnt/boot/refind_linux.conf
  1509. nextblitem="${txtedit//%1/refind_linux.conf}"
  1510. ;;
  1511. esac
  1512. archbootloaderrefindmenu "${nextblitem}"
  1513. fi
  1514. }
  1515. archrefindinstall(){
  1516. clear
  1517. echo "pacstrap /mnt refind-efi"
  1518. echo "archchroot refindbootloaderinstall ${realrootdev}"
  1519. echo "echo \"\\\"Hyperbola GNU+Linux-libre \\\" \\\"root=UUID=${rootuuid} rw add_efi_memmap\\\"\" > /mnt/boot/refind_linux.conf"
  1520. echo "echo \"\\\"Hyperbola GNU+Linux-libre Fallback\\\" \\\"root=UUID=${rootuuid} rw add_efi_memmap initrd=/initramfs-linux-fallback.img\\\"\" >> /mnt/boot/refind_linux.conf"
  1521. pacstrap /mnt refind-efi
  1522. archchroot refindbootloaderinstall "${realrootdev}"
  1523. rootuuid=$(blkid -s UUID -o value "${realrootdev}")
  1524. echo "\"Hyperbola GNU+Linux-libre \" \"root=UUID=${rootuuid} rw add_efi_memmap\"" > /mnt/boot/refind_linux.conf
  1525. echo "\"Hyperbola GNU+Linux-libre Fallback\" \"root=UUID=${rootuuid} rw add_efi_memmap initrd=/initramfs-linux-fallback.img\"" >> /mnt/boot/refind_linux.conf
  1526. pressanykey
  1527. }
  1528. archrefindinstallchroot(){
  1529. #--usedefault /dev/sdXY --alldrivers
  1530. echo "refind-install"
  1531. refind-install
  1532. isvbox=$(lspci | grep "VirtualBox G")
  1533. if [ "${isvbox}" ]; then
  1534. echo "VirtualBox detected, creating startup.nsh..."
  1535. printf '%s' '\EFI\refind\refind_x64.efi' > /boot/startup.nsh
  1536. fi
  1537. }
  1538. archextrasmenu(){
  1539. pkgs=""
  1540. options=()
  1541. options+=("nano" "" on)
  1542. options+=("screen" "" on)
  1543. options+=("vim" "" on)
  1544. options+=("dhcpcd" "" on)
  1545. options+=("wpa_supplicant" "" on)
  1546. options+=("iw" "" on)
  1547. options+=("net-tools" "" on)
  1548. options+=("bind-tools" "" on)
  1549. sel=$(whiptail --backtitle "${apptitle}" --title "${txtextrasmenu}" --checklist "" 0 0 0 \
  1550. "${options[@]}" \
  1551. 3>&1 1>&2 2>&3)
  1552. if [ ! "$?" = "0" ]; then
  1553. return 1
  1554. fi
  1555. for itm in $sel; do
  1556. pkgs="$pkgs ${itm//\"/}"
  1557. done
  1558. clear
  1559. echo "pacstrap /mnt ${pkgs}"
  1560. # shellcheck disable=SC2086
  1561. pacstrap /mnt ${pkgs}
  1562. if [[ "${pkgs}" == *"dhcpcd"* ]]; then
  1563. archchroot enabledhcpcd
  1564. fi
  1565. if [[ "${pkgs}" == *"wpa_supplicant"* ]]; then
  1566. archchroot enablewpa_supplicant
  1567. fi
  1568. pressanykey
  1569. }
  1570. archenabledhcpcdchroot(){
  1571. echo "rc-update add dhcpcd default"
  1572. rc-update add dhcpcd default
  1573. exit
  1574. }
  1575. archenablewpa_supplicantchroot(){
  1576. echo "rc-update add wpa_supplicant default"
  1577. rc-update add wpa_supplicant default
  1578. exit
  1579. }
  1580. installhyperdi(){
  1581. txtinstallhyperdi="Hyperbola GNU+Linux-libre Desktop Install (hyperdi) is a second script who can help you to install a full workstation.\n\nYou can just launch the script or install it. Choose in the next menu.\n\nHyperbola GNU+Linux-libre Desktop Install as two dependencies : wget and libnewt.\n\npacstrap wget libnewt ?"
  1582. if(whiptail --backtitle "${apptitle}" --title "hyperdi" --yesno "${txtinstallhyperdi}" 0 0); then
  1583. clear
  1584. echo "pacstrap /mnt wget libnewt"
  1585. pacstrap /mnt wget libnewt
  1586. fi
  1587. if [ "$?" = "0" ]; then
  1588. options=()
  1589. options+=("${txthyperdiinstallandlaunch}" "")
  1590. options+=("${txthyperdilaunch}" "")
  1591. options+=("${txthyperdiinstall}" "")
  1592. sel=$(whiptail --backtitle "${apptitle}" --title "${txthyperdimenu}" --menu "" --cancel-button "${txtback}" 0 0 0 \
  1593. "${options[@]}" \
  1594. 3>&1 1>&2 2>&3)
  1595. if [ "$?" = "0" ]; then
  1596. case ${sel} in
  1597. "${txthyperdiinstallandlaunch}") archchroot hyperdiinstallandlaunch;;
  1598. "${txthyperdilaunch}") archchroot hyperdilaunch;;
  1599. "${txthyperdiinstall}")
  1600. clear
  1601. archchroot hyperdiinstall
  1602. pressanykey
  1603. ;;
  1604. esac
  1605. fi
  1606. fi
  1607. }
  1608. hyperdidownload(){
  1609. txtselectserver="Select source server :"
  1610. txtback="Back"
  1611. options=()
  1612. options+=("sourceforge.net" "recommended")
  1613. options+=("github.com" "")
  1614. sel=$(whiptail --backtitle "${apptitle}" --title "${txtselectserver}" --menu "" --cancel-button "${txtback}" 0 0 0 \
  1615. "${options[@]}" \
  1616. 3>&1 1>&2 2>&3)
  1617. if [ "$?" = "0" ]; then
  1618. case ${sel} in
  1619. "sourceforge.net")
  1620. hyperdiurl=hyperdi.sourceforge.net/hyperdi
  1621. ;;
  1622. "github.com")
  1623. hyperdiurl=matmoul.github.io/hyperdi >hyperdi
  1624. ;;
  1625. esac
  1626. fi
  1627. echo "curl -L ${hyperdiurl} >hyperdi"
  1628. curl -L "${hyperdiurl}" > hyperdi
  1629. }
  1630. hyperdiinstallandlaunchchroot(){
  1631. cd || return
  1632. hyperdidownload
  1633. sh hyperdi -i
  1634. hyperdi --chroot
  1635. exit
  1636. }
  1637. hyperdilaunchchroot(){
  1638. cd || return
  1639. hyperdidownload
  1640. sh hyperdi --chroot
  1641. rm hyperdi
  1642. exit
  1643. }
  1644. hyperdiinstallchroot(){
  1645. cd || return
  1646. hyperdidownload
  1647. sh hyperdi -i
  1648. exit
  1649. }
  1650. # --------------------------------------------------------
  1651. # --------------------------------------------------------
  1652. pressanykey(){
  1653. read -r -n1 -p "${txtpressanykey}"
  1654. }
  1655. loadstrings(){
  1656. locale=en_US.UTF-8
  1657. #font=
  1658. txtexit="Exit"
  1659. txtback="Back"
  1660. txtignore="Ignore"
  1661. txtselectserver="Select source server :"
  1662. txtmainmenu="Main Menu"
  1663. txtlanguage="Language"
  1664. txtsetkeymap="Set Keyboard Layout"
  1665. txteditor="Editor"
  1666. txtdiskpartmenu="Disk Partitions"
  1667. txtselectpartsmenu="Select Partitions and Install"
  1668. txthelp="Help"
  1669. txtchangelog="Changelog"
  1670. txtreboot="Reboot"
  1671. txtautoparts="Auto Partitions"
  1672. txteditparts="Edit Partitions"
  1673. txtautopartsconfirm="Selected device : %1\n\nAll data will be erased ! \n\nContinue ?"
  1674. txtautopartclear="Clear all partition data"
  1675. txtautopartcreate="Create %1 partition"
  1676. txthybridpartcreate="Set hybrid MBR"
  1677. txtselectdevice="Select %1 device :"
  1678. txtselecteddevices="Selected devices :"
  1679. txtformatmountmenu="Format and Mount"
  1680. txtformatdevices="Format Devices"
  1681. txtformatdevice="Format Device"
  1682. txtmount="Mount"
  1683. txtunmount="Unmount"
  1684. txtmountdesc="Install or Config"
  1685. txtformatdeviceconfirm="Warning, all data on selected devices will be erased ! \nFormat devices ?"
  1686. txtselectpartformat="Select partition format for %1 :"
  1687. txtformatingpart="Formatting partition %1 as"
  1688. txtcreateluksdevice="Create luks device :"
  1689. txtopenluksdevice="Open luks device :"
  1690. txtluksdevicecreated="luks device created !"
  1691. txtinstallmenu="Install Menu"
  1692. txthyperbolainstallmenu="Hyperbola Install Menu"
  1693. txtselectmirrorsbycountry="Select mirrors by country"
  1694. txtselectcountry="Select country"
  1695. txteditmirrorlist="Edit mirrorlist"
  1696. txteditpacmanconf="Edit pacman.conf"
  1697. txtinstallhyperbola="Install Hyperbola GNU+Linux-libre - "
  1698. txtinstallhyperbolakernel="Kernel"
  1699. txtinstallhyperbolafirmwares="Firmwares"
  1700. txtinstallhyperbolafilesystems="File Systems"
  1701. txtinstallhyperbolacustompackagelist="Custom Package List"
  1702. txtconfighyperbola="Config Hyperbola GNU+Linux-libre"
  1703. txtsethostname="Set Computer Name"
  1704. txtsetfont="Set Font"
  1705. txtsetlocale="Set Locale"
  1706. txtsettime="Set Time"
  1707. txtsetrootpassword="Set root password"
  1708. txthwclock="Hardware clock :"
  1709. txthwclockutc="UTC"
  1710. txthwclocklocal="Local"
  1711. txtbootloader="Bootloader"
  1712. txtbootloadermenu="Choose your bootloader"
  1713. txtefibootmgr="efibootmgr is required for EFI computers."
  1714. txtbootloadergrubmenu="Grub Install Menu"
  1715. txtrungrubmakeconfig="Run grub-mkconfig ?"
  1716. txtgrubluksdetected="Encrypted root partion !\n\nAdd cryptdevice= to GRUB_CMDLINE_LINUX in /etc/default/grub ?"
  1717. txtbootloadersyslinuxmenu="Syslinux Install Menu"
  1718. txtsyslinuxaddefibootmgr="EFI install require efibootmgr"
  1719. txtsyslinuxaddgptfdisk="GPT disk require gptfdisk"
  1720. txtsyslinuxaddmtools="FAT boot part require mtools"
  1721. txtbootloaderrefindmenu="rEFInd Install Menu"
  1722. txtextrasmenu="Extras"
  1723. txtoptional="Optional"
  1724. txtgenerate="Generate %1"
  1725. txtedit="Edit %1"
  1726. txtinstall="Install %1"
  1727. txtpressanykey="Press any key to continue."
  1728. txthyperdimenu="Hyperbola Desktop Install"
  1729. txthyperdidesc="Full desktop install script"
  1730. txtinstallhyperdi="Hyperbola GNU+Linux-libre Desktop Install (hyperdi) is a second script who can help you to install a full workstation.\n\nYou can just launch the script or install it. Choose in the next menu.\n\nHyperbola GNU+Linux-libre Desktop Install as two dependencies : wget and libnewt.\n\npacstrap wget libnewt ?"
  1731. txthyperdiinstallandlaunch="Install and run hyperdi"
  1732. txthyperdiinstall="Install hyperdi"
  1733. txthyperdilaunch="Launch hyperdi"
  1734. }
  1735. # --------------------------------------------------------
  1736. # --------------------------------------------------------
  1737. while (( "$#" )); do
  1738. case ${1} in
  1739. --help)
  1740. echo "hyperfi"
  1741. echo "------"
  1742. echo "-cpl | --custom-package-list url Set custom package list url"
  1743. echo "-sf | --skip-font Skip setfont from language files"
  1744. echo "-efiX -efi0 : disable EFI, -efi1 efi inst, -efi2 efi hybrid inst"
  1745. echo "-t | --test hypergit name branch Test hyperfi script and language"
  1746. exit 0
  1747. ;;
  1748. -cpl | --custom-package-list)
  1749. curl -L "${2}" > /tmp/hyperfi-custom-package-list
  1750. if [[ "$?" != "0" ]]; then
  1751. echo "Error downloading custom package list"
  1752. exit 0
  1753. fi
  1754. cpl=1
  1755. ;;
  1756. -sf | --skip-font) skipfont=1;;
  1757. -t | --test)
  1758. curl -o hyperfi "https://hgit.ga/${2}/hyperfi/raw/branch/${3}/hyperfi"
  1759. sh hyperfi -tt "${2}" "${3}"
  1760. exit 0
  1761. ;;
  1762. -tt) baseurl="https://hgit.ga/${2}/hyperfi/raw/branch/${3}";;
  1763. -efi0)
  1764. efimode=0
  1765. ;;
  1766. -efi1)
  1767. eficomputer=1
  1768. efimode=1
  1769. ;;
  1770. -efi2)
  1771. eficomputer=1
  1772. efimode=2
  1773. ;;
  1774. --chroot)
  1775. chroot=1
  1776. command=${2}
  1777. args=${3}
  1778. ;;
  1779. esac
  1780. shift
  1781. done
  1782. if [ "${chroot}" = "1" ]; then
  1783. case ${command} in
  1784. 'setrootpassword') archsetrootpasswordchroot;;
  1785. 'setlocale') archsetlocalechroot;;
  1786. 'settimeutc') archsettimeutcchroot;;
  1787. 'settimelocal') archsettimelocalchroot;;
  1788. 'genmkinitcpio') archgenmkinitcpiochroot;;
  1789. 'enabledhcpcd') archenabledhcpcdchroot;;
  1790. 'enablewpa_supplicant') archenablewpa_supplicantchroot;;
  1791. 'grubinstall') archgrubinstallchroot;;
  1792. 'grubbootloaderinstall') archgrubinstallbootloaderchroot "${args}";;
  1793. 'grubbootloaderefiinstall') archgrubinstallbootloaderefichroot "${args}";;
  1794. 'grubbootloaderefiusbinstall') archgrubinstallbootloaderefiusbchroot "${args}";;
  1795. 'syslinuxbootloaderinstall') archsyslinuxinstallbootloaderchroot "${args}";;
  1796. 'syslinuxbootloaderefiinstall') archsyslinuxinstallbootloaderefichroot "${args}";;
  1797. 'refindbootloaderinstall') archrefindinstallchroot "${args}";;
  1798. 'hyperdiinstallandlaunch') hyperdiinstallandlaunchchroot;;
  1799. 'hyperdiinstall') hyperdiinstallchroot;;
  1800. 'hyperdilaunch') hyperdilaunchchroot;;
  1801. esac
  1802. else
  1803. pacman -S --needed arch-install-scripts wget libnewt
  1804. dmesg |grep efi: > /dev/null
  1805. if [ "$?" == "1" ]; then
  1806. if [ "${eficomputer}" != "1" ]; then
  1807. eficomputer=0
  1808. fi
  1809. else
  1810. eficomputer=1
  1811. if [ "${efimode}" == "" ]; then
  1812. efimode=1
  1813. fi
  1814. fi
  1815. loadstrings
  1816. EDITOR=nano
  1817. mainmenu
  1818. fi
  1819. exit 0
  1820. # --------------------------------------------------------