Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorYash Tripathi <tripathiyash97@gmail.com>2021-05-20 01:01:58 +0530
committerGitHub <noreply@github.com>2021-05-19 21:31:58 +0200
commitbbb4599165a644bbd81b085fb3210cd0e497d503 (patch)
tree3ba10fc59c955032ff948571cdbce158bbdf3ec2 /examples
parent49e6cbdc545402e066bdc2daf6054abf6c1bf977 (diff)
Added support for getting configuration from a config file (#364)
* added support for ingesting config * fixed condition to check key in dictionary * Removed redundant code, profile and desktop keys are now optional * Added base-config.json and support for pulling credentials from .env * added base config file and env file for users credentials * added silent install switch * added python-dotenv as a dependency * Updated Readme to include argparse changes as well as config ingestion * Updated Readme to include argparse changes as well as config ingestion * fixed typo in pyproject.toml * Replaced the magic __builtin__ global variable. This should fix mypy complaints while still retaining the same functionality, kinda. It's less automatic but it's also less of dark magic, which makes sense for anyone but me. * Fixes string index error. * Quotation error. * fixed initializing --script argument * added python-dotenv as a dependency * Installation can't be silent if config is not passed * fixed silent install help * fixed condition for ask_user_questions * reverted to creating profile object properly * Cleaned up and incorporated suggestions * added Profile import * added condition if Profile is null * fixed condition * updated parsing vars from argparse * removed loading users from .env * Reworking SysCommand & Moving to localectl for locale related activities (#4) * Moving to `localectl` rather than local file manipulation *(both for listing locales and setting them)*. * Swapped `loadkeys` for localectl. * Renamed `main` to `maim` in awesome profile. * Created `archinstall.Boot(<installation>)` which spawns a `systemd-nspawn` container against the installation target. * Exposing systemd.py's internals to archinstall global scope. * Re-worked `SysCommand` completely, it's now a wrapper for `SysCommandWorker` which supports interacting with the process in a different way. `SysCommand` should behave just like the old one, for backwards compatibility reasons. This fixes #68 and #69. * `SysCommand()` now has a `.decode()` function that defaults to `UTF-8`. * Adding back peak_output=True to pacstrap. Co-authored-by: Anton Hvornum <anton.feeds@gmail.com> Co-authored-by: Dylan Taylor <dylan@dylanmtaylor.com> Co-authored-by: Anton Hvornum <anton@hvornum.se> Co-authored-by: Anton Hvornum <anton.feeds@gmail.com> * fixed indent * removed redundant import * removed duplicate import * removed duplicate import Co-authored-by: Anton Hvornum <anton.feeds@gmail.com> Co-authored-by: Anton Hvornum <anton@hvornum.se> Co-authored-by: Dylan M. Taylor <dylan@dylanmtaylor.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/config-sample.json35
-rw-r--r--examples/guided.py38
2 files changed, 62 insertions, 11 deletions
diff --git a/examples/config-sample.json b/examples/config-sample.json
new file mode 100644
index 00000000..55bdf04b
--- /dev/null
+++ b/examples/config-sample.json
@@ -0,0 +1,35 @@
+{
+ "!root-password": "<root_password>",
+ "audio": null,
+ "bootloader": "systemd-bootctl",
+ "filesystem": "btrfs",
+ "harddrive": {
+ "path": "/dev/sda"
+ },
+ "hostname": "box",
+ "kernels": [
+ "linux"
+ ],
+ "keyboard-language": "us",
+ "mirror-region": {
+ "Worldwide": {
+ "https://mirror.rackspace.com/archlinux/$repo/os/$arch": true
+ }
+ },
+ "nic": {
+ "NetworkManager": true
+ },
+ "packages": [],
+ "profile": null,
+ "superusers": {
+ "<username>": {
+ "!password": "<password>"
+ }
+ },
+ "timezone": "UTC",
+ "users": {
+ "<username>": {
+ "!password": "<password>"
+ }
+ }
+} \ No newline at end of file
diff --git a/examples/guided.py b/examples/guided.py
index b9b06a64..f0d0db7a 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -1,11 +1,12 @@
import json
import logging
-import time
import os
+import time
import archinstall
from archinstall.lib.hardware import has_uefi
from archinstall.lib.networking import check_mirror_reachable
+from archinstall.lib.profiles import Profile
if archinstall.arguments.get('help'):
print("See `man archinstall` for help.")
@@ -243,7 +244,8 @@ def perform_installation_steps():
archinstall.log(json.dumps(archinstall.arguments, indent=4, sort_keys=True, cls=archinstall.JSON), level=logging.INFO)
print()
- input('Press Enter to continue.')
+ if not archinstall.arguments.get('silent'):
+ input('Press Enter to continue.')
"""
Issue a final warning before we continue with something un-revertable.
@@ -261,7 +263,6 @@ def perform_installation_steps():
mode = archinstall.GPT
if has_uefi() is False:
mode = archinstall.MBR
-
with archinstall.Filesystem(archinstall.arguments['harddrive'], mode) as fs:
# Wipe the entire drive if the disk flag `keep_partitions`is False.
if archinstall.arguments['harddrive'].keep_partitions is False:
@@ -297,7 +298,7 @@ def perform_installation_steps():
fs.find_partition('/').mount(archinstall.storage.get('MOUNT_POINT', '/mnt'))
if has_uefi():
- fs.find_partition('/boot').mount(archinstall.storage.get('MOUNT_POINT', '/mnt')+'/boot')
+ fs.find_partition('/boot').mount(archinstall.storage.get('MOUNT_POINT', '/mnt') + '/boot')
perform_installation(archinstall.storage.get('MOUNT_POINT', '/mnt'))
@@ -381,12 +382,13 @@ def perform_installation(mountpoint):
exit(1)
installation.log("For post-installation tips, see https://wiki.archlinux.org/index.php/Installation_guide#Post-installation", fg="yellow")
- choice = input("Would you like to chroot into the newly created installation and perform post-installation configuration? [Y/n] ")
- if choice.lower() in ("y", ""):
- try:
- installation.drop_to_shell()
- except:
- pass
+ if not archinstall.arguments.get('silent'):
+ choice = input("Would you like to chroot into the newly created installation and perform post-installation configuration? [Y/n] ")
+ if choice.lower() in ("y", ""):
+ try:
+ installation.drop_to_shell()
+ except:
+ pass
# For support reasons, we'll log the disk layout post installation (crash or no crash)
archinstall.log(f"Disk states after installing: {archinstall.disk_layouts()}", level=logging.DEBUG)
@@ -397,5 +399,19 @@ if not check_mirror_reachable():
archinstall.log(f"Arch Linux mirrors are not reachable. Please check your internet connection and the log file '{log_file}'.", level=logging.INFO, fg="red")
exit(1)
-ask_user_questions()
+if archinstall.arguments.get('silent', None) is None:
+ ask_user_questions()
+else:
+ # Workarounds if config is loaded from a file
+ # The harddrive section should be moved to perform_installation_steps, where it's actually being performed
+ # Blockdevice object should be created in perform_installation_steps
+ # This needs to be done until then
+ archinstall.arguments['harddrive'] = archinstall.BlockDevice(path=archinstall.arguments['harddrive']['path'])
+ # Temporarily disabling keep_partitions if config file is loaded
+ archinstall.arguments['harddrive'].keep_partitions = False
+ # Temporary workaround to make Desktop Environments work
+ archinstall.storage['_desktop_profile'] = archinstall.arguments.get('desktop', None)
+ if archinstall.arguments.get('profile', None):
+ archinstall.arguments['profile'] = Profile(installer=None, path=archinstall.arguments['profile']['path'])
+
perform_installation_steps()