Skip to content

Commit

Permalink
Fix some things.
Browse files Browse the repository at this point in the history
- Added: -a flag in `kimport` core util.
- Updated: test script.
- Fixed: disk-utils module.
  • Loading branch information
soymadip committed Oct 30, 2024
1 parent 8488f9f commit eccec06
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.3
0.5.4
13 changes: 6 additions & 7 deletions core/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ clear -x
echo -e "\n--------------------- KireiSakura Kit Test Utility ----------------------\n\n"


export LOG_FILE="test_script.log"
export LOG_FILE="Kirei-test.log"
export CACHE_DIR="$HOME/.cache/test_setup_dir"


eval "$(kireisakura -i)"; echo -e "\n"



log.warn "Set variables:------\n"
log.warn "EXPORTED VARIABLES:------\n"
echo -e " ${GREEN}Log file name${NC} (kirei_log_file): $kirei_log_file"
echo -e " ${GREEN}Cache dir${NC} (kirei_cache_dir): $kirei_cache_dir"
echo -e " ${GREEN}Installation dir${NC} (kirei_dir): $kirei_dir"
Expand All @@ -21,22 +21,21 @@ echo -e " ${GREEN}Module dir${NC} (kirei_module_dir): $kirei_module_dir"
echo -e "\n\n"


log.warn "Logs:------\n"
log.warn "LOGS:------\n"

log.success "Log level: success"
log.error "Log level: error"
log.warn "Log level: inform"
echo -e "\n\n"


log.warn "Importing modules:------\n"
log.warn "IMPORTING ALL MODULES:------\n"

kimport restore-dotfiles install-fonts kde-plasma-utils disk-utils
kimport -a # loads all
echo -e "\n\n"


rm -rf $kirei_cache_dir
rm $kirei_log_file
log.success "\nTEST SUCCESSFULLY COMPLETED.\n"


echo -e "\n\n------------------------- END ----------------------------\n"
51 changes: 39 additions & 12 deletions core/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,56 @@
# Import modules
# kimport <module1> <module2>
kimport() {
local called_modules=("$@")
local load_all=false
local called_modules=()
local module_path
local failed_imports=()
# local is_quiet=0

log.warn "Importing modules....\n" kimport
while [[ $# -gt 0 ]]; do
case "$1" in
-a|--all)
load_all=true
shift
;;
*)
called_modules+=("$1")
shift
;;
esac
done

for module_name in "${called_modules[@]}"; do
module_path="$kirei_module_dir/$module_name.sh"

if [ -f "$module_path" ]; then
if [ "$load_all" = true ]; then
log.warn "Importing All modules....\n" kimport
for module_path in "$kirei_module_dir"/*.sh; do
module_name="$(basename "${module_path%.*}")"
if source "$module_path"; then
log "Imported: '$module_name'"
else
log.warn "Failed to import: '$module_name'"
failed_imports+=("$module_name")
fi
else
log.warn "Failed to import '$module_name': doesn't exist."
failed_imports+=("$module_name")
fi
sleep 0.3
done
sleep 0.3
done
else
log.warn "Importing modules....\n" kimport
for module_name in "${called_modules[@]}"; do
module_path="$kirei_module_dir/$module_name.sh"

if [ -f "$module_path" ]; then
if source "$module_path"; then
log "Imported: '$module_name'"
else
log.warn "Failed to import: '$module_name'"
failed_imports+=("$module_name")
fi
else
log.warn "Failed to import '$module_name': doesn't exist."
failed_imports+=("$module_name")
fi
sleep 0.3
done
fi

if [ "${#failed_imports[@]}" -gt 0 ]; then
echo ""
Expand Down
10 changes: 5 additions & 5 deletions modules/disk-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ mount_external_drive() {

# Make mount folder
log.warn "Checking given Mount directory."
check_dir "$mount_dir" --needed || { log.error "Error creating dir."; exit 1 }
check_dir "$mount_dir" --needed || { log.error "Error creating dir."; exit 1; }


# Get ownership of the dir & drive
log.warn "Getting ownership of the Mount directory."
sudo chown -R $username:$user_group $mount_dir || { log.error "Error ownership."; exit 1 }
sudo chmod -R 744 $mount_dir || { log.error "Error Getting writing permission."; exit 1 }
sudo chown -R $username:$user_group $mount_dir || { log.error "Error ownership."; exit 1; }
sudo chmod -R 744 $mount_dir || { log.error "Error Getting writing permission."; exit 1; }

log.warn "Getting ownership of the External Drive."
sudo chown -R $username:$user_group $disk_id || { log.error "Error owning External Drive."; exit 1 }
sudo chown -R $username:$user_group $disk_id || { log.error "Error owning External Drive."; exit 1; }


# Backup fstab file
log.warn "Backing up current fstab file."
sudo cp /etc/fstab /etc/fstab.bak || { log.error "Failed to back up current fstab file."; exit 1 }
sudo cp /etc/fstab /etc/fstab.bak || { log.error "Failed to back up current fstab file."; exit 1; }


# Mounting device
Expand Down

0 comments on commit eccec06

Please sign in to comment.