From 6d037e00b8d9258db78589801fe197faa84c1ea7 Mon Sep 17 00:00:00 2001 From: Recolic <git@me.recolic.net> Date: Wed, 19 Mar 2025 21:11:57 -0700 Subject: [PATCH] .add-example --- examples/README.md | 3 +- examples/archlinux-gnome/conf.d/pkgs.sh | 17 +++++++++++ examples/archlinux-gnome/linuxconf.wrapper | 4 +++ examples/archlinux-gnome/masterconf.sh | 34 ++++++++++++++++++++++ linuxconf | 3 +- 5 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 examples/archlinux-gnome/conf.d/pkgs.sh create mode 100755 examples/archlinux-gnome/linuxconf.wrapper create mode 100644 examples/archlinux-gnome/masterconf.sh diff --git a/examples/README.md b/examples/README.md index fb7e7a2..be74091 100644 --- a/examples/README.md +++ b/examples/README.md @@ -3,5 +3,6 @@ |Example|Note| |---|---| |[template](template)|Complete documented empty config| -|[archlinux-gnome](archlinux-gnome)|An example config for archlinux and gnome| +|[archlinux-gnome](archlinux-gnome)|An example config with archlinux and gnome| +|[ubuntu-server](ubuntu-server)|An example config for someone's ubuntu server| diff --git a/examples/archlinux-gnome/conf.d/pkgs.sh b/examples/archlinux-gnome/conf.d/pkgs.sh new file mode 100644 index 0000000..362c0cc --- /dev/null +++ b/examples/archlinux-gnome/conf.d/pkgs.sh @@ -0,0 +1,17 @@ +lc_assert_user_is root + +lc_init () { + # my favorite package + pacman -Sy --noconfirm fish dhcpcd vim sudo openssh + pacman -Sy --noconfirm --asdeps openssl + + pacman -Sy --noconfirm gnome networkmanager power-profiles-daemon nextcloud-client firefox + + # add primary user + useradd --create-home --shell /usr/bin/fish rtest + echo 'rtest ALL=(ALL) NOPASSWD: ALL' | EDITOR='tee -a' visudo + usermod --password $(echo testpass | openssl passwd -1 -stdin) rtest + + systemctl enable gdm NetworkManager power-profiles-daemon +} + diff --git a/examples/archlinux-gnome/linuxconf.wrapper b/examples/archlinux-gnome/linuxconf.wrapper new file mode 100755 index 0000000..dc8517c --- /dev/null +++ b/examples/archlinux-gnome/linuxconf.wrapper @@ -0,0 +1,4 @@ +#!/bin/bash + +TODO: this is a wrapper. it should download & install real linuxconf binary. + diff --git a/examples/archlinux-gnome/masterconf.sh b/examples/archlinux-gnome/masterconf.sh new file mode 100644 index 0000000..6e19c12 --- /dev/null +++ b/examples/archlinux-gnome/masterconf.sh @@ -0,0 +1,34 @@ +# setup this linuxconf on fresh-installed archlinux + +lc_include conf.d/* + +lc_assert_user_is root + +# I strongly suggest u design lc_init() as an idempotent operation. Just in case u accidentally run `linuxconf register` elsewhere. +function lc_init () { + # as root / as user? + + # note: in demo, append /etc/profile for PATH +} + +function lc_startup () { + # as root / as user? + # with desktop env? (not supported yet) + +} + +function lc_login () { + # warning: less useful. happens again if user logout/login again. + # (no plan to support in first ver) + lc_login_is_x11? +} + +function lc_cron () { + # hourly / daily / weekly / monthly? + # as root / as user? + +} + +# Warning: watch out for unintended user +lc_fsmap files/vimrc $LC_USER_HOME/.vimrc + diff --git a/linuxconf b/linuxconf index da44f98..7a74443 100755 --- a/linuxconf +++ b/linuxconf @@ -25,11 +25,12 @@ function lc_include () { # print the return code of the eval-ed function to stderr, but this function should always return success. for script in "$@"; do + echo2 "$script -- $LCI_SUBSHELL_OP started as $(whoami), at $(pwd)" ( source "$script" eval "$LCI_SUBSHELL_OP" ) - echo2 "$script -- $LCI_SUBSHELL_OP completed. return_val = $return_code" + echo2 "$script -- $LCI_SUBSHELL_OP completed with status $return_code" done return 0 -- GitLab