+ initial files

This commit is contained in:
tuxwarrior
2024-04-30 07:40:24 -05:00
parent 36779c4cbd
commit 95057f3f16
11 changed files with 1169 additions and 1 deletions

65
scripts/99_dots.sh Normal file
View File

@@ -0,0 +1,65 @@
#!/usr/bin/env bash
# klevstul
echo "<< 99_dots.sh >>"
user=poq
base_url=https://git.mz.fo/fro/lnx-arch/raw/branch/master
targz_url=https://git.mz.fo/fro/lnx-arch/archive/master.tar.gz
clone_trg=/tmp
dots_trg=${clone_trg}/lnx-arch/dots
if [ "$EUID" -ne 0 ]
then echo "error: run as 'root'"
exit
fi
this_file_name=`basename "$0"`
if [ $# -lt 1 ]; then
echo "usage: '$this_file_name {all}'"
exit 1
fi
operation=$1
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
# helper function
download_repo() {
# make clone target directory, if it doesn't exist
mkdir -p ${clone_trg}
# instead of doing a git clone (like `git clone ${clone_url} ${clone_trg}`),
# where i would have emptied the target dir each time, i download the
# source as a tar.gz.
wget --show-progress ${targz_url} -O ${clone_trg}/tmp.tar.gz
tar -xzf ${clone_trg}/tmp.tar.gz -C ${clone_trg}
rm ${clone_trg}/tmp.tar.gz
}
# download all dots (dot files) from repo
if [ ${operation} == "all" ] ; then
echo "***** ${operation} *****"
download_repo
tree ${clone_trg}/lnx-arch
target_file_name=hyprland.conf
target_file_path=/home/${user}/.config/hypr/${target_file_name}
cp -f ${dots_trg}/hyprland/${target_file_name} ${target_file_path}
chown ${user}:${user} ${target_file_path}
ls -al ${target_file_path}
target_file_name=hyprpaper.conf
target_file_path=/home/${user}/.config/hypr/${target_file_name}
cp -f ${dots_trg}/hyprpaper/${target_file_name} ${target_file_path}
chown ${user}:${user} ${target_file_path}
ls -al ${target_file_path}
fi

142
scripts/99_software.sh Normal file
View File

@@ -0,0 +1,142 @@
#!/usr/bin/env bash
# klevstul
# https://wiki.archlinux.org/title/pacman
echo "<< 99_software.sh >>"
if [ "$EUID" -ne 0 ]
then echo "error: run as 'root'"
exit
fi
this_file_name=`basename "$0"`
if [ $# -lt 1 ]; then
echo "error: $# arguments given"
echo "usage: '$this_file_name [operation] [argument?]'"
exit 1
fi
operation=$1
parameter=$2
param_check() {
parameter=$1
error_msg=$2
if [ -z "${parameter}" ] ; then
echo "error: ${error_msg}" ; exit 1
fi
}
# -----
# always update the system
# -----
sudo pacman -Syu
echo "-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-"
# -----
# setup all packages for given host
# -----
if [ ${operation} == "setup" ] ; then
param_check "${parameter}" "no host name given"
package_list_url=https://git.mz.fo/fro/lnx-arch/raw/branch/master/dots/archinstall/${parameter}/packages.txt
trg_file=/tmp/packages.txt
wget -q ${package_list_url} -O ${trg_file}
if ! [ -s ${trg_file} ] ; then
echo "error: packages.txt is empty"
echo ""
echo "attempted to to download 'packages.txt' from:
echo '${package_list_url}'"
echo "'${parameter}' might be an invalid hostname, or 'packages.txt' might be created for given host."
exit 1
fi
# https://stackoverflow.com/questions/30988586/creating-an-array-from-a-text-file-in-bash
mapfile -t packages < ${trg_file}
installed=$(pacman -Qq)
list=()
for x in ${packages[@]}
do
if [[ $installed == *$x* ]]
then
echo "Skipping (1) $x"
elif [[ $installed != *$x* ]]
then
if [[ $(echo "$installed" | grep -E -o "^$x$") != $x ]]
then
echo "Adding $x to list"
list+="$x "
else
echo "Skipping (2) $x"
fi
fi
done
if [[ -n "$list" ]]
then
pacman -S --needed --noconfirm $list
else
echo "Nothing to install"
fi
fi
# -----
# install package
# -----
if [ ${operation} == "install" ] ; then
param_check "${parameter}" "no package name given"
pacman -S ${parameter}
fi
# -----
# search for package
# -----
if [ ${operation} == "search" ] ; then
param_check "${parameter}" "no package name given"
# search in name and description
pacman -Ss "^${parameter}-"
fi
# -----
# remove orphaned packages (packages which are no longer needed)
# -----
if [ ${operation} == "orphans" ] ; then
echo "- - - - -"
echo "if no orphans to be removed were found, the following error will be displayed:"
echo "\"error: argument '-' specified with empty stdin\""
echo "- - - - -"
echo "removing orphans..."
pacman -Qtdq | pacman -Rns -
fi
# -----
# remove orphaned packages (packages which are no longer needed)
# -----
if [ ${operation} == "uninstall" ] ; then
param_check "${parameter}" "no package name given"
# uninstall program and remove orphans
pacman -Rns ${parameter}
fi

View File

@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# klevstul
echo "<< archinstall_config_prepare.sh >>"
src_file_conf=user_configuration.json
src_file_cred=user_credentials.json
src_base_url=https://git.mz.fo/fro/lnx-arch/raw/branch/master/dots/archinstall/
trg_dir=/tmp
if [ "$EUID" -ne 0 ]
then echo "error: run as 'root'"
exit
fi
# ---------------------------------
# download user_configuration.json
# ---------------------------------
echo "enter host name:"
read user_input
host_name=${user_input}
src_url=${src_base_url}/${host_name}/${src_file_conf}
curl -o ${trg_dir}/${src_file_conf} ${src_url}
# ---------------------------------
# download user_credentials.json
# ---------------------------------
src_url=${src_base_url}/common/${src_file_cred}
curl -o ${trg_dir}/${src_file_cred} ${src_url}
echo "enter password for user:"
read -s user_input # -s for silent mode (do not display input in cli)
password=${user_input}
sed -i -e "s/<PASSWORD>/${password}/g" ${trg_dir}/${src_file_cred}

181
scripts/curae.sh Normal file
View File

@@ -0,0 +1,181 @@
#!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# what: curae is latin an means to take care. this script takes care
# of the system (adjusted for arch linux).
# author: fk
# started: may 2024
#
# nifty: https://github.com/dylanaraps/pure-bash-bible
#
# requires: tree, wget
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#############################################################################
#
# WARNING: EXAMINE THE CONTENT BEFORE EXECUTION. RUN AT YOUR OWN RISK.
#
#############################################################################
echo "<< curae.sh >>"
base_url=https://git.mz.fo/fro/lnx-arch/raw/branch/master
scripts_url=${base_url}/scripts
home_dir=/home/.curae
this_file=curae.sh
if [ "$EUID" -ne 0 ]
then echo "error: run as 'root'"
exit
fi
this_file_name=`basename "$0"`
if [ $# -lt 1 ]; then
echo "usage: '$this_file_name { dots | uf / upd-full [host] | sw / software [host] | us / upd-self }'"
exit 1
fi
operation=$1
parameter_1=$2
parameter_2=$3
shopt -s extglob
case $operation in
!(dots|uf|upd-full|sw|software|us|upd-self))
echo "error: unknown operation '$operation'"
exit
;;
esac
shopt -u extglob
# helper function
execute_script() {
file=$1
parameter_1=$2
parameter_2=$3
echo "execute: ${file} ${parameter_1} ${parameter_2}"
wget -q ${scripts_url}/${file} -O /tmp/${file}
chmod 755 /tmp/*.sh
/tmp/${file} ${parameter_1} ${parameter_2}
}
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
# build package
#shopt -s extglob
#if [ $operation == "pkg-build" ] ; then
#
# if [ -z "${extra_parameter}" ]; then
# echo "error: missing package name"
# exit 1
# fi
#
# package_dir=${pkgs_dir}/${extra_parameter}
#
# if ! [ -d "${package_dir}" ] ; then
# echo "invalid path: '${package_dir}'"
# exit 1
# fi
#
# echo "building package with path: '${package_dir}'"
# cd ${package_dir}
# nix-build -A ${extra_parameter}
# cd -
#
#fi
#shopt -u extglob
# update cfg/dot files
#shopt -s extglob
#if [ $operation == "u" ] || [ $operation == "upd-dots" ] ; then
#
# execute_script 10_download_files.sh "dots-all"
#
# tree -D /etc/nixos
#
#fi
#shopt -u extglob
# update dot files
shopt -s extglob
if [ $operation == "dots" ] ; then
execute_script 99_dots.sh ${parameter_1}
fi
shopt -u extglob
# install software (update system)
shopt -s extglob
if [ $operation == "sw" ] || [ $operation == "software" ] ; then
execute_script 99_software.sh ${parameter_1} ${parameter_2}
fi
shopt -u extglob
# self update, by re-downloading and overwriting itself
shopt -s extglob
if [ $operation == "us" ] || [ $operation == "upd-self" ] ; then
wget -v ${base_url}/scripts/${this_file} -O ${home_dir}/${this_file}.tmp
cp ${home_dir}/${this_file}.tmp ${home_dir}/${this_file}
rm ${home_dir}/${this_file}.tmp
chmod 755 ${home_dir}/*.sh
fi
shopt -u extglob
# full update: install software and update dots
shopt -s extglob
if [ $operation == "uf" ] || [ $operation == "upd-full" ] ; then
if [ -z "${parameter_1}" ]; then
parameter_1=$HOSTNAME
fi
if [ -z "${parameter_1}" ]; then
echo "error: missing host name"
exit 1
fi
${home_dir}/${this_file} software setup ${parameter_1}
${home_dir}/${this_file} dots all
fi
shopt -u extglob
# update and rebuild (all) without hostname
#shopt -s extglob
#if [ $operation == "ur" ] || [ $operation == "upd-rebuild" ] ; then
#
# ${home_dir}/${this_file} upd-dots
# ${home_dir}/${this_file} rebuild ${extra_parameter}
#
#fi
#shopt -u extglob
# rebuild system with hostname
#shopt -s extglob
#if [ $operation == "rh" ] || [ $operation == "rebuildh" ] ; then
#
# if [ -z "${extra_parameter}" ]; then
# echo "error: missing host name"
# exit 1
# fi
#
# nixos-rebuild switch -v --show-trace --flake /etc/nixos#${extra_parameter}
#
#fi
#shopt -u extglob
# rebuild system without hostname
#shopt -s extglob
#if [ $operation == "r" ] || [ $operation == "rebuild" ] ; then
#
# nixos-rebuild switch -v --show-trace
#
#fi
#shopt -u extglob

31
scripts/curae_setup.sh Normal file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# klevstul
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# how to download this script (as root):
#
# cd /tmp
# wget tinyurl.com/fk-arc3 # same as `wget https://git.mz.fo/fro/lnx-arch/raw/branch/master/scripts/curae_setup.sh`
# cat fk-arc3 # verify the downloaded script (IMPORTANT!)
# chmod 755 fk-arc3 # make the script executable
# ./fk-arc3 # run the script
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
echo "<< genesis.sh >>"
if [ "$EUID" -ne 0 ]
then echo "error: run as 'root'"
exit
fi
base_url=https://git.mz.fo/fro/lnx-arch/raw/branch/master
src_url=${base_url}/scripts/curae.sh
home_dir=/home/.curae
this_file_name=fk-arc3
mkdir -p ${home_dir}
cd ${home_dir}
wget -q ${src_url} -O ${home_dir}/curae.sh
chmod 755 curae.sh
echo "a fresh copy of curae.sh is now located at '${home_dir}/curae.sh'"