mirror of
https://github.com/kevinveenbirkenbach/linux-image-manager.git
synced 2024-11-22 07:01:03 +01:00
Optimized analyziation
This commit is contained in:
parent
7f629205ef
commit
76f1a35a46
6
scripts/analyze/client/big_files.sh
Normal file
6
scripts/analyze/client/big_files.sh
Normal file
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
# @author Kevin Veen-Birkenbach
|
||||
# shellcheck source=/dev/null # Deactivate SC1090
|
||||
source "$(dirname "$(readlink -f "${0}")")/../../base.sh" || (echo "Loading base.sh failed." && exit 1)
|
||||
info "Searching for files which are in \"$HOME\" and bigger then 100MB..."
|
||||
find ~ -type f -size +100M -exec ls -lh {} \;
|
6
scripts/analyze/client/false_chown.sh
Normal file
6
scripts/analyze/client/false_chown.sh
Normal file
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
# @author Kevin Veen-Birkenbach
|
||||
# shellcheck source=/dev/null # Deactivate SC1090
|
||||
source "$(dirname "$(readlink -f "${0}")")/../../base.sh" || (echo "Loading base.sh failed." && exit 1)
|
||||
info "Searching for files which are in \"$HOME\" but don't belong to user \"$USER\"..."
|
||||
sudo find "$HOME" ! -user "$USER"
|
6
scripts/analyze/client/file_duplicates.sh
Normal file
6
scripts/analyze/client/file_duplicates.sh
Normal file
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
# @author Kevin Veen-Birkenbach
|
||||
# shellcheck source=/dev/null # Deactivate SC1090
|
||||
source "$(dirname "$(readlink -f "${0}")")/../../base.sh" || (echo "Loading base.sh failed." && exit 1)
|
||||
info "Checking relevant home folders for duplicated files..."
|
||||
fdupes -r "$HOME/Documents/" "$HOME/Downloads/" "$HOME/Images/" "$HOME/Desktop/" "$HOME/Music/" "$HOME/Pictures/" "$HOME/Videos"
|
6
scripts/analyze/client/java_versions.sh
Normal file
6
scripts/analyze/client/java_versions.sh
Normal file
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
# @author Kevin Veen-Birkenbach
|
||||
# shellcheck source=/dev/null # Deactivate SC1090
|
||||
source "$(dirname "$(readlink -f "${0}")")/../../base.sh" || (echo "Loading base.sh failed." && exit 1)
|
||||
info "Showing the installed Java versions..." &&
|
||||
archlinux-java status
|
5
scripts/analyze/client/linux_kernel.sh
Normal file
5
scripts/analyze/client/linux_kernel.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
# @author Kevin Veen-Birkenbach
|
||||
# shellcheck source=/dev/null # Deactivate SC1090
|
||||
source "$(dirname "$(readlink -f "${0}")")/../../base.sh" || (echo "Loading base.sh failed." && exit 1)
|
||||
info "Linux-Kernel: $(uname -r)"
|
37
scripts/analyze/system/dd_optimal_bs_test.sh
Normal file
37
scripts/analyze/system/dd_optimal_bs_test.sh
Normal file
@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
# Wrong scripped but good as a base to optimize later. See http://blog.tdg5.com/tuning-dd-block-size/
|
||||
# Since we're dealing with dd, abort if any errors occur
|
||||
set -e
|
||||
|
||||
TEST_FILE=${1:-dd_obs_testfile}
|
||||
[ -e "$TEST_FILE" ]; TEST_FILE_EXISTS=$?
|
||||
TEST_FILE_SIZE=134217728
|
||||
|
||||
# Header
|
||||
PRINTF_FORMAT="%8s : %s\n"
|
||||
printf "$PRINTF_FORMAT" 'block size' 'transfer rate'
|
||||
|
||||
# Block sizes of 512b 1K 2K 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M
|
||||
for BLOCK_SIZE in 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864
|
||||
do
|
||||
# Calculate number of segments required to copy
|
||||
COUNT=$(($TEST_FILE_SIZE / $BLOCK_SIZE))
|
||||
|
||||
if [ $COUNT -le 0 ]; then
|
||||
echo "Block size of $BLOCK_SIZE estimated to require $COUNT blocks, aborting further tests."
|
||||
break
|
||||
fi
|
||||
|
||||
# Create a test file with the specified block size
|
||||
DD_RESULT=$(dd if=/dev/zero of=$TEST_FILE bs=$BLOCK_SIZE count=$COUNT 2>&1 1>/dev/null)
|
||||
|
||||
echo $DD_RESULT
|
||||
# Extract the transfer rate from dd's STDERR output
|
||||
TRANSFER_RATE=$(echo $DD_RESULT | \grep --only-matching -E '[0-9.]+ ([MGk]?B|bytes)/s(ec)?')
|
||||
|
||||
# Clean up the test file if we created one
|
||||
[ $TEST_FILE_EXISTS -ne 0 ] && rm $TEST_FILE
|
||||
|
||||
# Output the result
|
||||
printf "$PRINTF_FORMAT" "$BLOCK_SIZE" "$TRANSFER_RATE"
|
||||
done
|
@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
# @author Kevin Veen-Birkenbach
|
||||
# shellcheck source=/dev/null # Deactivate SC1090
|
||||
source "$(dirname "$(readlink -f "${0}")")/../base.sh" || (echo "Loading base.sh failed." && exit 1)
|
||||
echo "System check - Shows things which can be optimized:"
|
||||
echo
|
||||
info "Linux-Kernel: $(uname -r)"
|
||||
info "Checking relevant home folders for duplicated files..."
|
||||
fdupes -r "$HOME/Documents/" "$HOME/Downloads/" "$HOME/Images/" "$HOME/Desktop/" "$HOME/Music/" "$HOME/Pictures/" "$HOME/Videos"
|
||||
info "Searching for files which are in \"$HOME\" but don't belong to user \"$USER\"..."
|
||||
sudo find "$HOME" ! -user "$USER"
|
||||
info "Searching for files which are in \"$HOME\" and bigger then 100MB..."
|
||||
find ~ -type f -size +100M -exec ls -lh {} \;
|
||||
info "Showing the installed Java versions..." &&
|
||||
archlinux-java status
|
@ -1,5 +1,6 @@
|
||||
#!/bin/bash
|
||||
source "$(dirname "$(readlink -f "${0}")")/base.sh" || (echo "Loading base.sh failed." && exit 1)
|
||||
echo "Mounting encrypted storage..."
|
||||
echo "Mounts encrypted storages"
|
||||
|
||||
set_device_mount_and_mapper_paths
|
||||
|
||||
|
45
scripts/encryption/storage/mount_on_boot.sh
Normal file
45
scripts/encryption/storage/mount_on_boot.sh
Normal file
@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
source "$(dirname "$(readlink -f "${0}")")/base.sh" || (echo "Loading base.sh failed." && exit 1)
|
||||
echo "Automount encrypted storages"
|
||||
echo
|
||||
set_device_mount_and_mapper_paths
|
||||
|
||||
secret_key_path="/etc/luks-keys/$mapper""_name_secret_key" &&
|
||||
info "Generate secret key under: $secret_key_path" &&
|
||||
dd if=/dev/urandom of=$secret_key_path bs=512 count=8 &&
|
||||
sudo cryptsetup -v luksAddKey $device_path $secret_key_path ||
|
||||
error
|
||||
|
||||
info "Opening and closing device to verify that that everything works fine..." &&
|
||||
sudo cryptsetup -v luksOpen $device_path $mapper_name --key-file=$secret_key_path &&
|
||||
sudo cryptsetup -v luksClose $mapper_name ||
|
||||
error
|
||||
|
||||
uuid_line=$(sudo cryptsetup luksDump $device_path | grep "UUID")
|
||||
uuid=$(uuid_line "${test/UUID:/""}"|sed -e "s/[[:space:]]\+//g")
|
||||
crypttab_path="/etc/crypttab"
|
||||
if grep -q "$uuid" "$crypttab_path"; then
|
||||
error "File $crypttab_path contains allready a string with the UUID:$uuid"
|
||||
fi
|
||||
"$mapper_name UUID=$uuid $secret_key_path luks" >> $crypttab_path
|
||||
|
||||
info "The file $crypttab_path contains the following:" &&
|
||||
sudo cat $crypttab_path ||
|
||||
error
|
||||
|
||||
info "Verifying crypttab configuration..." &&
|
||||
sudo cryptdisks_start $mapper_name ||
|
||||
error
|
||||
|
||||
fstab_path="/etc/fstab"
|
||||
if grep -q "$uuid" "f$stab_path"; then
|
||||
error "File $fstab_path contains allready a string with the UUID:$uuid"
|
||||
fi
|
||||
"$mapper_path $mount_path btrfs defaults 0 2" >> $fstab_path ||
|
||||
error
|
||||
|
||||
info "The file $crypttab_path contains the following:" &&
|
||||
sudo cat $crypttab_path ||
|
||||
error
|
||||
|
||||
success "Installation finished. Please restart :)"
|
Loading…
Reference in New Issue
Block a user