Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 127e04e

Browse files
authored
Merge pull request #11 from darrenldl/dev
Updated README, fixing disk partitioning code
2 parents 544130f + bd6220e commit 127e04e

File tree

5 files changed

+93
-37
lines changed

5 files changed

+93
-37
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ script:
2222
- docker exec installer_builder bash -c 'cd ~; echo $(pwd)'
2323
- docker exec installer_builder bash -c 'cd ~; ls'
2424
- docker exec installer_builder bash -c 'cp -r ~/oali-master ~/oali'
25-
- docker exec installer_builder bash -c 'chmod u=rwx ~/llsh'
25+
- docker exec installer_builder bash -c 'chmod u=rwx ~/oali'
2626
- docker exec installer_builder bash -c 'eval $(opam env); cd ~/oali/installer_ml; make'
2727
- docker cp installer_builder:/home/opam/oali/installer_ml/_build/default/src/installer.exe ./installer
2828
- strip installer

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Darren Ldl
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 55 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,84 @@
11
# OCaml Arch Linux Installer
22
[![Build Status](https://travis-ci.org/darrenldl/oali.svg?branch=master)](https://travis-ci.org/darrenldl/oali)
33

4-
### Description
4+
## Warning
5+
Oali is still extremely early in development, and still WIP
6+
7+
It is difficult to test an installer targeting a live CD automatically, so right now it's still a lot of manual testing
8+
9+
Please do **NOT** use it for anything serious yet
10+
11+
## Description
512
Oali is an installer written in OCaml which sets up a Arch Linux installation with following variations
613
- 3 disk layouts
714
- Single system disk (installer does partitioning for you)
8-
- You pick the partitions for `/boot` `/` etc manually
15+
- You pick the partitions for `/boot`, `/` etc manually
916
- Single system partition (you pick an existing partition on a disk) + USB key (partitioned by installer)
1017
- Optional full disk encryption
1118
- Optional `linux-hardened` kernel installation
1219

1320
Oali aims to be smart and hassle free, so following features are included as a result
1421
- Automatic adjustment of dialogues and settings based on whether the live CD is running in UEFI or BIOS mode
1522

16-
### Encryption specifics
17-
In all disk layouts, system partition (i.e. `/`) is protected by a keyfile
18-
19-
The keyfile is stored in within the initramfs in boot partition, which is protected by a user provided passphrase
20-
21-
LUKS setup is used for all encrypted partitions.
22-
23-
If in UEFI mode, the ESP partition will be present but is not (and cannot be) encrypted.
24-
25-
### Post-install notes
26-
After installation, several files will be present in `/root/llsh_pack` (all of the files are to be accessed/executed by root)
27-
- `salt_exec.sh` allows you start the saltstack setup, present only if you answered yes to using saltstack for your further setup
28-
- `oli_setup_note` contains description of the files
29-
- `usb_key_mount.sh` allows you to mount your USB key easily and reliably
30-
- `usb_key_umount.sh` allows you to unmount your USB key easily and reliably
31-
- `useradd_helper_restructed.sh` and `useradd_helper_as_powerful.sh` allow you to add more users in the same manner as used by setup.sh
32-
33-
### Misc. notes
34-
Saltstack files related
35-
- currently linux-lts is enabled in the salt state files as a measure to avoid lock out due to kernel updates
36-
37-
### Prerequisites
23+
## Prerequisites
3824
- Working internet connection
3925
- Partitioning done for system partition
4026
- USB key (data will be lost)
4127

42-
### Space requirement
28+
## Space requirement
4329
- USB key (if you intend to use disk layout that utilises a USB key)
4430
- 1 GiB USB drive will be very sufficient
4531
- System drive
4632
- Current salt states download/install around 10 GiB of data
4733

48-
### Instructions
34+
## Instructions
4935
The OCaml code is not self contained, thus if you choose to compile it yourself, you will need to install various dependencies.
5036

5137
For deployment purposes, it is recommended that you use the static binaries provided, which you can download via [GitHub releases](https://github.com/darrenldl/ocaml-linux-installer/releases)
5238

5339
The static binaries of the installer are built via Travis CI using `ocaml/opam2:alpine` Docker image, and should be able to run on Arch Linux live CD without any further setup
5440

55-
### License
41+
## Specifics
42+
43+
#### Disk layout choices
44+
**Single system disk** - Oali slices the disks into ESP (if in EFI mode), boot and root partitions automatically
45+
46+
**Manual picking** - Oali just uses the choices you provide
47+
48+
**Single system partition + USB key** - Oali installs ESP (if in EFI mode), boot partitions on USB key, and root partition on the provided system partition
49+
50+
Oali will handle encryption along with other chores automatically with the disk layout you picked in mind, such as
51+
- `/etc/crypttab` is set up only if the disk layout doesn't involve USB key
52+
- `/etc/fstab` is adjusted to disable USB key partitions if disk layout uses USB key
53+
54+
#### Encryption specifics
55+
Oali uses `cryptsetup` for LUKS setup, and allows you to toggle boot and root partition encryption separately
56+
57+
Note that it will ask for confirmation if you choose to encrypt boot but not root (which is a silly setup, but it'll oblige if you insist)
58+
59+
Oali will ask if you want to change the key iteration time (in millisec) and key size
60+
61+
#### Boot partitions
62+
If in UEFI mode, the ESP partition will be present but is never (and cannot be) encrypted
63+
64+
If boot partition encryption is enabled, then it is protected by a passphrase
65+
66+
#### System partition
67+
If system/root partition encryption is enabled, then it is protected by a keyfile
68+
69+
The keyfile is stored in within the initramfs in boot partition
70+
71+
#### Post-install notes
72+
After installation, several files will be present in `/root/oali_pack` (all of the files are to be accessed/executed by root)
73+
- `salt_exec.sh` allows you start the saltstack setup, present only if you answered yes to using saltstack for your further setup
74+
- `oli_setup_note` contains description of the files
75+
- `usb_key_mount.sh` allows you to mount your USB key easily and reliably
76+
- `usb_key_umount.sh` allows you to unmount your USB key easily and reliably
77+
- `useradd_helper_restructed.sh` and `useradd_helper_as_powerful.sh` allow you to add more users in the same manner as used by setup.sh
78+
79+
#### Misc. notes
80+
Saltstack files related
81+
- currently linux-lts is enabled in the salt state files as a measure to avoid lock out due to kernel updates
82+
83+
## License
5684
MIT

installer_ml/src/installer.ml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ let () =
256256
exec
257257
(Printf.sprintf "parted -a optimal %s mkpart primary %dMB %d%%"
258258
disk boot_part_end_MB
259-
(int_of_float Config.total_disk_usage_frac));
259+
(frac_to_perc Config.total_disk_usage_frac));
260260
exec (Printf.sprintf "parted %s set 1 boot on" disk);
261261
Disk_utils.sync ();
262262
let parts = Disk_utils.parts_of_disk disk in
@@ -279,9 +279,9 @@ let () =
279279
(Printf.sprintf "parted -a optimal %s mkpart primary 0%% %dMB"
280280
disk boot_part_end_MB);
281281
exec
282-
(Printf.sprintf "parted -a optimal %s mkpart primary %dMB %dMB"
282+
(Printf.sprintf "parted -a optimal %s mkpart primary %dMB %d%%"
283283
disk boot_part_end_MB
284-
(int_of_float Config.total_disk_usage_frac));
284+
(frac_to_perc Config.total_disk_usage_frac));
285285
exec (Printf.sprintf "parted %s set 1 boot on" disk);
286286
Disk_utils.sync ();
287287
let parts = Disk_utils.parts_of_disk disk in
@@ -891,12 +891,16 @@ let () =
891891
ask_yn "Do you want to enable SSH server?" = Yes
892892
in
893893
{config with enable_ssh_server = Some enable_ssh_server});
894-
reg ~name:"Enabling SSH server" (fun config ->
895-
Arch_chroot.exec "systemctl enable sshd";
896-
config);
894+
reg ~name:"Installing SSH server" (fun config ->
895+
Arch_chroot.install ["openssh"];
896+
config
897+
);
897898
reg ~name:"Copying sshd_config over" (fun config ->
898899
FileUtil.cp [Config.sshd_config_path_in_repo] Config.etc_ssh_dir_path;
899900
config);
901+
reg ~name:"Enabling SSH server" (fun config ->
902+
Arch_chroot.exec "systemctl enable sshd";
903+
config);
900904
reg ~name:"Setting up SSH key directory" (fun config ->
901905
let user_name = Option.get config.user_name in
902906
let user_ssh_dir_path =

installer_ml/src/misc_utils.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ type yn =
1414
| Yes
1515
| No
1616

17+
let not_empty s = s <> ""
18+
1719
let retry (f : unit -> 'a retry) : 'a =
1820
let rec aux f = match f () with Stop x -> x | Retry -> aux f in
1921
aux f
@@ -30,7 +32,8 @@ let ask_string ?(is_valid = fun _ -> true) prompt =
3032
let ask_yn prompt =
3133
retry (fun () ->
3234
let s =
33-
ask_string (Printf.sprintf "%s y/n" prompt) |> String.lowercase_ascii
35+
ask_string ~is_valid:not_empty (Printf.sprintf "%s y/n" prompt)
36+
|> String.lowercase_ascii
3437
in
3538
let len = String.length s in
3639
let yes = "yes" in
@@ -124,8 +127,6 @@ let print_boxed_msg s =
124127
let line = String.concat "" ["+"; String.make (len - 2) '-'; "+"] in
125128
print_endline line; Printf.printf "| %s |\n" s; print_endline line
126129
127-
let not_empty s = s <> ""
128-
129130
let concat_file_names names =
130131
let splits =
131132
names
@@ -144,3 +145,5 @@ let calc_frac ~max_frac ~value ~total =
144145
assert (max_frac >= 0.0);
145146
assert (max_frac <= 1.0);
146147
min (value /. total) max_frac
148+
149+
let frac_to_perc frac : int = int_of_float (Float.round (frac *. 100.0))

0 commit comments

Comments
 (0)