Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions compact_ini_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/bash

INPUT_DIR=/media/fat/ini/source
OUTPUT_DIR=/media/fat/ini/compacted

if [ -d "$OUTPUT_DIR" ]; then rm "$OUTPUT_DIR"/*; else mkdir "$OUTPUT_DIR"; fi

while IFS='' read -r -d '' INI_FILE_NAME; do
echo "Compacting: $INI_FILE_NAME"
sed -e 's/\r$//g; s/[\t ]*;.*$//g' "$INPUT_DIR/$INI_FILE_NAME" | grep -vx -F '' | sed -e 's/$/\r/g' > "$OUTPUT_DIR/$INI_FILE_NAME"
done < <(cd $INPUT_DIR; find * -maxdepth 1 -type f -name "*.ini" -print0)
17 changes: 9 additions & 8 deletions make_linux_nice.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ set -e

echo "Making Linux nice..."

this_dir="$(cd "$(dirname "$0")" && pwd -P)"
THIS_DIR="$(cd "$(dirname "$0")" && pwd -P)"

echo " - Modifying root user settings..."
cp -f "$this_dir/nice-linux/.bashrc" /root/
cp -f "$this_dir/nice-linux/.bash_aliases" /root/
cp -f "$this_dir/nice-linux/.bash_logout" /root/
cp -f "$this_dir/nice-linux/.bash_prompt" /root/
cp -f "$this_dir/nice-linux/.profile" /root/
cp -f "$this_dir/nice-linux/.vimrc" /root/
cp -rf "$this_dir/nice-linux/.ssh" /root/
cp -f "$THIS_DIR/nice-linux/.bashrc" /root/
cp -f "$THIS_DIR/nice-linux/.bash_aliases" /root/
cp -f "$THIS_DIR/nice-linux/.bash_functions" /root/
cp -f "$THIS_DIR/nice-linux/.bash_logout" /root/
cp -f "$THIS_DIR/nice-linux/.bash_prompt" /root/
cp -f "$THIS_DIR/nice-linux/.profile" /root/
cp -f "$THIS_DIR/nice-linux/.vimrc" /root/
cp -rf "$THIS_DIR/nice-linux/.ssh" /root/

echo " - Configuring ssh KeepAlive settings..."
sed -i -E 's|^#[[:blank:]]*ClientAliveInterval[[:blank:]]*.*$|ClientAliveInterval 60|g; s|^#[[:blank:]]*ClientAliveCountMax[[:blank:]]*.*$|ClientAliveCountMax 10|g' /etc/ssh/sshd_config
Expand Down
5 changes: 5 additions & 0 deletions nice-linux/.bash_functions
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function vimini() {
vim "$*"
compact_ini_files.sh
}

6 changes: 6 additions & 0 deletions nice-linux/.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ fi
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_functions ]; then
. ~/.bash_functions
fi

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
Expand All @@ -56,3 +60,5 @@ if ! shopt -oq posix; then
. /etc/bash_completion
fi
fi

cd /media/fat/
29 changes: 16 additions & 13 deletions update_sample_ini.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@

set -e

echo "Updating MiSTer_sample.ini..."
pushd /media/fat/ > /dev/null
SAMPLE_DIR=/media/fat/ini/sample
NEW_FILE=$SAMPLE_DIR/MiSTer.ini
OLD_FILE=$SAMPLE_DIR/MiSTer.ini.old
DIFF_FILE=$SAMPLE_DIR/$(date +%Y%m%d_%H%M%S).diff

curl -k -o ./MiSTer_sample.ini.NEW https://raw.githubusercontent.com/MiSTer-devel/Main_MiSTer/master/MiSTer.ini
echo "Updating: ${NEW_FILE}"

TIMESTAMP=$(date +%Y%m%d_%H%M%S)
CHANGES_FILE=./MiSTer_sample.ini.CHANGES_$TIMESTAMP
mv "${NEW_FILE}" "${OLD_FILE}"
curl --silent -k https://raw.githubusercontent.com/MiSTer-devel/Main_MiSTer/master/MiSTer.ini | sed -e 's/\r//g' > "${NEW_FILE}"

if [ -f ./MiSTer_sample.ini ]; then
diff -b -B -w -d -U 0 ./MiSTer_sample.ini ./MiSTer_sample.ini.NEW >> $CHANGES_FILE
if [ $(stat -c %s $CHANGES_FILE) -eq 0 ]; then
rm -f $CHANGES_FILE
if [ -f "${NEW_FILE}" ]; then
diff -b -B -w -d -U 0 "${OLD_FILE}" "${NEW_FILE}" | unix2dos > "${DIFF_FILE}" || true
if [ $(stat -c %s "${DIFF_FILE}") -eq 0 ]; then
rm -f "${DIFF_FILE}"
else
echo "Diff saved to ${DIFF_FILE}."
fi
else
mv "${OLD_FILE}" "${NEW_FILE}"
fi

mv -f ./MiSTer_sample.ini.NEW ./MiSTer_sample.ini

popd > /dev/null
echo "Done."
rm "${OLD_FILE}"