From f67bcdfe2e8537a0ce50faaf2fcf09e94965ef2c Mon Sep 17 00:00:00 2001 From: xpamych Date: Sun, 2 Apr 2023 14:58:52 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B2=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82?= =?UTF-8?q?=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hlna-dev-git/postinstall.sh | 32 ++++++++++++++++++-------------- hlna-dev-git/postremove.sh | 0 2 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 hlna-dev-git/postremove.sh diff --git a/hlna-dev-git/postinstall.sh b/hlna-dev-git/postinstall.sh index a233679..c48ce9e 100644 --- a/hlna-dev-git/postinstall.sh +++ b/hlna-dev-git/postinstall.sh @@ -1,14 +1,18 @@ -if test -f /home/$SUDO_USER/.zshrc; then -echo "zshrc" -echo 'alias hlna="hlna.py"'>>/home/$SUDO_USER/.zshrc -echo 'alias hlna-bot="hlna-bot.py"'>>/home/$SUDO_USER/.zshrc -fi -if test -f /home/$SUDO_USER/.config/fish/config.fish; then -echo 'alias hlna="hlna.py"'>>/home/$SUDO_USER/.config/fish/config.fish -echo 'alias hlna-bot="hlna-bot.py"'>>/home/$SUDO_USER/.config/fish/config.fish -fi -if test -f /home/$SUDO_USER/.bashrc; then -echo 'alias hlna="hlna.py"'>>/home/$SUDO_USER/.bashrc -echo 'alias hlna-bot="hlna-bot.py"'>>/home/$SUDO_USER/.bashrc -source /home/$SUDO_USER/.bashrc -fi \ No newline at end of file +line_to_add='alias hlna="hlna.py"' +file_paths=( "/home/$SUDO_USER/.zshrc" "/home/$SUDO_USER/.bashrc" "/home/$SUDO_USER/.config/fish/config.fish" ) + +for file_path in "${file_paths[@]}" +do + if [ -f "$file_path" ]; then + # Check if the line is already in the file + grep -qF "$line_to_add" "$file_path" + if [ $? -ne 0 ]; then + echo "$line_to_add" >> "$file_path" + echo "Строка добавлена to $file_path" + else + echo "Строка уже существует in $file_path" + fi + else + echo "$file_path не существует" + fi +done \ No newline at end of file diff --git a/hlna-dev-git/postremove.sh b/hlna-dev-git/postremove.sh new file mode 100644 index 0000000..e69de29