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

Commit 544130f

Browse files
authored
Merge pull request #10 from darrenldl/dev
Fixed partitioning code, added code to use reflector, added code for SSH pub keys transfer
2 parents 6218b32 + 4569237 commit 544130f

File tree

15 files changed

+478
-101
lines changed

15 files changed

+478
-101
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99

1010
before_install:
1111
- docker pull ocaml/opam2:alpine
12-
- docker run -td --name installer_builder -v $(pwd):/home/opam/llsh-master ocaml/opam2:alpine
12+
- docker run -td --name installer_builder -v $(pwd):/home/opam/oali-master ocaml/opam2:alpine
1313
- docker exec installer_builder sudo apk add m4
1414
- docker exec installer_builder opam install dune
1515
- docker exec installer_builder opam install core_kernel
@@ -21,10 +21,10 @@ before_install:
2121
script:
2222
- docker exec installer_builder bash -c 'cd ~; echo $(pwd)'
2323
- docker exec installer_builder bash -c 'cd ~; ls'
24-
- docker exec installer_builder bash -c 'cp -r ~/llsh-master ~/llsh'
24+
- docker exec installer_builder bash -c 'cp -r ~/oali-master ~/oali'
2525
- docker exec installer_builder bash -c 'chmod u=rwx ~/llsh'
26-
- docker exec installer_builder bash -c 'eval $(opam env); cd ~/llsh/installer_ml; make'
27-
- docker cp installer_builder:/home/opam/llsh/installer_ml/_build/default/src/installer.exe ./installer
26+
- docker exec installer_builder bash -c 'eval $(opam env); cd ~/oali/installer_ml; make'
27+
- docker cp installer_builder:/home/opam/oali/installer_ml/_build/default/src/installer.exe ./installer
2828
- strip installer
2929

3030
deploy:
@@ -34,7 +34,7 @@ deploy:
3434
file: installer
3535
on:
3636
tags: true
37-
repo: darrenldl/ocaml-linux-installer
37+
repo: darrenldl/oali
3838
skip_cleanup: true
3939

4040
notifications:

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# 0.0.3
2+
- Fixed boot partition cryptsetup parameters adjustment task unit
3+
- Fixed partition size percentage calculation
4+
- Fixed partition name computation code
5+
- Previously partition name may not be correctly deduced during formatting
6+
- Added task unit for using `reflector` to generate more optimised mirrorlist
7+
- Added SSH server setup and SSH keys transfer code
8+
19
# 0.0.2
210
- Added following user options when task unit fails
311
- Skip

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# ocaml-linux-installer
2-
[![Build Status](https://travis-ci.org/darrenldl/ocaml-linux-installer.svg?branch=master)](https://travis-ci.org/darrenldl/ocaml-linux-installer)
1+
# OCaml Arch Linux Installer
2+
[![Build Status](https://travis-ci.org/darrenldl/oali.svg?branch=master)](https://travis-ci.org/darrenldl/oali)
33

44
### Description
5-
The installer written in OCaml sets up a Arch Linux installation with following variations
5+
Oali is an installer written in OCaml which sets up a Arch Linux installation with following variations
66
- 3 disk layouts
77
- Single system disk (installer does partitioning for you)
88
- You pick the partitions for `/boot` `/` etc manually
99
- Single system partition (you pick an existing partition on a disk) + USB key (partitioned by installer)
1010
- Optional full disk encryption
1111
- Optional `linux-hardened` kernel installation
1212

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

1616
### Encryption specifics

installer_ml/src/config.ml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
let sys_mount_point = "/mnt"
22

3-
let esp_part_size_MiB = 550
3+
let esp_part_size_MiB = 550.0
44

5-
let esp_part_max_perc = 25
5+
let esp_part_max_frac = 0.25
66

77
let efi_dir = "/efi"
88

99
let esp_mount_point = Misc_utils.concat_file_names [sys_mount_point; efi_dir]
1010

11-
let boot_part_size_MiB = 500
11+
let boot_part_size_MiB = 500.0
1212

13-
let boot_part_max_perc = 75
13+
let boot_part_max_frac = 0.75
14+
15+
let total_disk_usage_frac = 0.75
1416

1517
let boot_dir = "/boot"
1618

@@ -24,7 +26,13 @@ let boot_mapper_name = "crypt_boot"
2426

2527
let root_mapper_name = "crypt_root"
2628

27-
let oli_files_dir_path = "/root/oli_pack"
29+
let livecd_mirrorlist_path =
30+
Misc_utils.concat_file_names ["/etc"; "pacman.d"; "mirrorlist"]
31+
32+
let etc_ssh_dir_path =
33+
Misc_utils.concat_file_names [sys_mount_point; "etc"; "ssh"]
34+
35+
let oali_files_dir_path = Misc_utils.concat_file_names ["/root"; "oali_pack"]
2836

2937
let useradd_helper_as_powerful_name = "useradd_helper_as_powerful.sh"
3038

@@ -40,4 +48,7 @@ let usb_key_mount_script_name = "usb_key_mount.sh"
4048

4149
let usb_key_unmount_script_name = "usb_key_umount.sh"
4250

43-
let oli_setup_note_name = "oli_setup_note"
51+
let oali_setup_note_name = "oali_setup_note"
52+
53+
let sshd_config_path_in_repo =
54+
Misc_utils.concat_file_names [repo_name; "saltstack"; "salt"; "sshd_config"]

installer_ml/src/disk_utils.ml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ let list_parts () =
2525
| None ->
2626
false)
2727
|> List.map (fun (_, dst) -> dst)
28+
|> List.sort_uniq compare
2829

2930
let disk_of_part part =
3031
let devs = list_disk_block_devs () in
@@ -36,6 +37,11 @@ let disk_of_part part =
3637
let _, disk_name = List.find (fun (path, _dst) -> path = disk_path) devs in
3738
disk_name
3839

40+
let parts_of_disk disk =
41+
let len = String.length disk in
42+
list_parts ()
43+
|> List.filter (fun part -> Core_kernel.String.prefix part len = disk)
44+
3945
let list_disks () =
4046
list_disk_block_devs ()
4147
|> List.filter (fun (path, _dst) ->
@@ -46,6 +52,7 @@ let list_disks () =
4652
| None ->
4753
true)
4854
|> List.map (fun (_, dst) -> dst)
55+
|> List.sort_uniq compare
4956

5057
let disk_size_bytes disk =
5158
let res =
@@ -54,9 +61,9 @@ let disk_size_bytes disk =
5461
let size_str = List.hd res.stdout in
5562
int_of_string size_str
5663

57-
let disk_size_KiB disk = (disk_size_bytes disk + 1024 - 1) / 1024
64+
let disk_size_KiB disk : float = float_of_int (disk_size_bytes disk) /. 1024.0
5865

59-
let disk_size_MiB disk = (disk_size_KiB disk + 1024 - 1) / 1024
66+
let disk_size_MiB disk : float = disk_size_KiB disk /. 1024.0
6067

6168
let uuid_of_dev dev =
6269
let dir = "/dev/disk/by-uuid" in
@@ -71,3 +78,5 @@ let uuid_of_dev dev =
7178
|> List.filter (fun (s, _) -> s = Filename.basename dev)
7279
|> List.hd
7380
|> fun (_, uuid) -> uuid
81+
82+
let sync () = Proc_utils.exec "sync"

0 commit comments

Comments
 (0)