diff --git a/hlna-git/lure.sh b/hlna-git/lure.sh index b302d2d..7a1fbb4 100644 --- a/hlna-git/lure.sh +++ b/hlna-git/lure.sh @@ -1,4 +1,5 @@ -name='hlna-git' + + ['postremove']='postremove.sh'name='hlna-git' version='latest' release='1' desc='Этот инструмент позволяет управлять выделенным сервером ARK: Survival Evolved на Linux. Он предоставляет множество функций, чтобы получить полный список, ознакомьтесь с разделом использования. (находится в разарботке и может содержать ошибки)' @@ -22,6 +23,7 @@ version() { scripts=( ['postinstall']='postinstall.sh' + ['postremove']='postremove.sh' ) prepare() { diff --git a/hlna-git/postinstall.sh b/hlna-git/postinstall.sh old mode 100755 new mode 100644 index a233679..6d46d01 --- a/hlna-git/postinstall.sh +++ b/hlna-git/postinstall.sh @@ -1,14 +1,28 @@ -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 +line1_to_add='alias hlna="hlna.py"' +line2_to_add='alias hlna-bot="hlna-bot.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 lines are already in the file + grep -qF "$line1_to_add" "$file_path" + if [ $? -ne 0 ]; then + echo "$line1_to_add" >> "$file_path" + echo "Alias hlna добавлен в $file_path" + else + echo "Alias hlna уже есть в файле $file_path" + fi + + grep -qF "$line2_to_add" "$file_path" + if [ $? -ne 0 ]; then + echo "$line2_to_add" >> "$file_path" + echo "Alias hlna-bot добавлен в $file_path" + else + echo "Alias hlna-bot уже есть в файле $file_path" + fi + + else + echo "$file_path не существует" + fi +done \ No newline at end of file diff --git a/hlna-git/postremove.sh b/hlna-git/postremove.sh new file mode 100644 index 0000000..ea8a779 --- /dev/null +++ b/hlna-git/postremove.sh @@ -0,0 +1,27 @@ +line1_to_remove='alias hlna="hlna.py"' +line2_to_remove='alias hlna-bot="hlna-bot.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 in the file + grep -qF "$line1_to_remove" "$file_path" + if [ $? -eq 0 ]; then + sed -i "/$line1_to_remove/d" "$file_path" + echo "Alias hlna удалён из $file_path" + else + echo "Alias hlna нет в $file_path" + fi + + grep -qF "$line2_to_remove" "$file_path" + if [ $? -eq 0 ]; then + sed -i "/$line2_to_remove/d" "$file_path" + echo "Alias hlna-bot удалён из $file_path" + else + echo "Alias hlna-bot нет в $file_path" + fi + else + echo "$file_path не существует" + fi +done \ No newline at end of file