Skip to content
Snippets Groups Projects
Commit 661ab522 authored by Recolic's avatar Recolic :house_with_garden:
Browse files

Merge branch 'dev' into 'master'

update example and bugfix

See merge request !3
parents 87acf0a9 0ed2d099
No related branches found
No related tags found
1 merge request!3update example and bugfix
......@@ -19,3 +19,7 @@ This project is to demonstrate a possibility to manage customization in a centra
## dependency
coreutils bash grep sudo
## TODO
init order? what is one init depends on another?
lc_assert_user_is_not root
# okay to stay inside lc_init() or outside
lc_fsmap files/config.fish $HOME/.config/fish/config.fish
lc_fsmap files/ssh_config $HOME/.ssh/config
lc_fsmap files/vimrc $HOME/.vimrc
......
# setup this linuxconf on fresh-installed archlinux
# ordered by filename. Explicit order your files if u don't like.
lc_include conf.d/*
example=conf
example vimrc
......@@ -12,6 +12,7 @@
# > conf.d/basic.sh should install pkgs, (possibly) create new user, (possibly) run `linuxconf register .` again with new user.
#
# order by filename
lc_include conf.d/*
# If you have multiple user.. You might need this in your config file.
......@@ -19,7 +20,7 @@ lc_assert_user_is root
lc_assert_user_is_not root
# I strongly suggest u design lc_init() as an idempotent operation. Just in case u accidentally run `linuxconf register` elsewhere.
function lc_init () {
lc_init () {
# as root / as user?
# Some helpful functions.. To stop running current script:
......@@ -30,33 +31,24 @@ function lc_init () {
gsettings set var=123
}
function lc_startup () {
lc_startup () {
# as root / as user?
# You want desktop env? Use lc_login()
# want some daemon in background?
lcf_bgrun /tmp/server.log my_server --arg1 123 --arg2 "hello world !"
lcf_bgrun /tmp/server.log auto_restart important_service --gg "example"
# Guaranteed! linuxconf dir is your current workdir.
lcf_bgrun /dev/null auto_restart important_service --config files/test.conf
}
function lc_login () {
lc_login () {
# Your desktop environment must implement "XDG autostart". Ref: https://wiki.archlinux.org/title/XDG_Autostart
# Otherwise... Use lc_init to your task into wherever u'd like.
#
# Warning: Could be called multiple times if user logout/login again.
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
# TODO: what if lc_fsmap depends on lc_init() ?? This is not recommended usage.
# e.g: 'git clone xxx $HOME/sh' and lc_fsmap $HOME/sh/something /usr/bin/fancy
# lc_fsmap should success even if $HOME/sh/something doesn't exist yet. (what if dest also not exist? let it fail...)
# watch out! does your user have access to target directory?
# okay to stay inside lc_init() or outside, okay if files/vimrc doesn't exist yet.
lc_fsmap files/vimrc $HOME/.vimrc
......@@ -57,15 +57,21 @@ function lc_include () {
return 0
}
function lci_fsmap () {
function lc_fsmap () {
# If existing symlink is correct, do nothing & return 0 (success).
# Otherwise, delete the existing symlink.
# If the existing item is file/folder, move to '$filename.linuxsync_backup'.
# If target folder doesn't exist, create it.
# Then create a symlink.
local content_path="$(realpath "$1")" || return $?
local content_path="$1"
local symlink_path="$2"
if [ ! -f "$content_path" ] && [[ "$content_path" == /* ]]; then
: # skip this specific failure case
else
content_path="$(realpath "$content_path")" || return $?
fi
if [ -L "$symlink_path" ]; then
if [ "$(readlink "$symlink_path")" = "$content_path" ]; then
......@@ -82,13 +88,6 @@ function lci_fsmap () {
ln -s "$content_path" "$symlink_path"
}
function lc_fsmap () {
lci_fsmap "$@"
local result=$?
[ $result = 0 ] || lcf_err "lc_fsmap returned error $result"
return $result
}
function lci_state_file_append () {
local fname="$1"
local prefix="$2"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment