-
-
Notifications
You must be signed in to change notification settings - Fork 572
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
13 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,9 @@ | ||
#!/bin/sh | ||
|
||
post_install() { | ||
set -e | ||
echo " | ||
=================================================================== | ||
POWERSHELL EMPIRE DATABASE INITIALIZATION | ||
=================================================================== | ||
" | ||
# Find the PIDs of processes using port 3306, and remove duplicates | ||
pids=$(sudo ss -tulnp | grep ':3306' | awk '{print $7}' | cut -d',' -f2 | cut -d'=' -f2 | sort -u) | ||
|
||
# Check if any PIDs were found | ||
if [ -n "$pids" ]; then | ||
echo "Found processes using port 3306: $pids" | ||
for pid in $pids; do | ||
echo "Killing process with PID $pid..." | ||
sudo kill -9 "$pid" | ||
echo "Process $pid has been killed." | ||
done | ||
fi | ||
echo "Initializing MariaDB..." | ||
sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql | ||
echo "Enabling mariadb systemctl service..." | ||
sudo systemctl enable --now mariadb | ||
echo "Creating empire_user..." | ||
sudo mariadb -u root -e "CREATE USER IF NOT EXISTS 'empire_user'@'localhost' IDENTIFIED BY 'empire_password';" || true | ||
sudo mariadb -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'empire_user'@'localhost' WITH GRANT OPTION;" || true | ||
sudo mariadb -u root -e "FLUSH PRIVILEGES;" || true | ||
} | ||
|
||
post_upgrade() { | ||
post_install "$@" | ||
} | ||
post_remove() { | ||
# Check if the directory exists to avoid errors if it doesn't | ||
if [[ -d /usr/share/empire ]]; then | ||
rm -rf /usr/share/empire | ||
echo "Removed /usr/share/empire" | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters