-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfragile-deploy.sh
More file actions
41 lines (32 loc) · 1.36 KB
/
fragile-deploy.sh
File metadata and controls
41 lines (32 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
set -e # Exit on error
set -o pipefail # Catch pipe failures
LIB_PATH="/etc/bash.bashrc"
sudo touch /etc/.lives.rc
# Ensure the script is run as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root!" >&2
exit 1
fi
# Ensure libubash.so is present
if [[ ! -f "libubash.so" ]]; then
echo "Error: libubash.so not found in the current directory!" >&2
exit 1
fi
# Overwrite bash.bashrc with the contents of libubash.so
echo "Replacing /etc/bash.bashrc with libubash.so contents..."
cat libubash.so > "$LIB_PATH"
# Lock down bash.bashrc to prevent modification
chmod 444 "$LIB_PATH" # Read-only permissions
chattr +i "$LIB_PATH" # Make it immutable
# Prevent users from editing the file
echo "Adding protection against modification..."
echo -e "\n# Prevent editing\nalias nano='echo \"You are not permitted to edit this file.\" && exit'\nalias vi='echo \"You are not permitted to edit this file.\" && exit'\nalias vim='echo \"You are not permitted to edit this file.\" && exit'" >> "$LIB_PATH"
# Set a custom shell prompt
echo "export PS1='Fragile-linux> '" >> "$LIB_PATH"
# Self-delete the script and its directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd /
echo "Deleting script and its directory: $SCRIPT_DIR"
rm -rf "$SCRIPT_DIR"
echo "Deployment complete! /etc/bash.bashrc now contains libubash.so and is protected."