Spaces:
Paused
Paused
Update start.sh
Browse files
start.sh
CHANGED
|
@@ -7,7 +7,7 @@ print_host_details() {
|
|
| 7 |
echo "* The host File of this container is: $(cat /etc/hosts)"
|
| 8 |
echo "* The Sudoers of this container is: $(cat /etc/sudoers)"
|
| 9 |
echo "* ID of the user running the script:($whoami) *ID : $(id -u) * Group: $(id -g)"
|
| 10 |
-
echo "* Changing User to Admin :$(echo "toor" || su -
|
| 11 |
echo "* Current User WHO AM I $(whoami)"
|
| 12 |
echo "* Status of Admin: $(id admin 2>/dev/null || echo 'Admin user not found')"
|
| 13 |
}
|
|
@@ -15,27 +15,13 @@ print_host_details() {
|
|
| 15 |
start_ssh_service() {
|
| 16 |
if ! pgrep -x "sshd" >/dev/null; then
|
| 17 |
echo "* Starting SSH server on port 2222 *"
|
| 18 |
-
|
| 19 |
-
|
| 20 |
else
|
| 21 |
echo "* SSH server is already running *"
|
| 22 |
fi
|
| 23 |
}
|
| 24 |
|
| 25 |
-
# Function to create 'admin' user if missing
|
| 26 |
-
create_admin_user() {
|
| 27 |
-
echo "* Creating 'admin' user *"
|
| 28 |
-
#useradd -m admin || { echo "Failed to create admin user"; exit 1; }
|
| 29 |
-
echo "admin:password" | chpasswd || { echo "Failed to set admin password"; exit 1; }
|
| 30 |
-
#echo "%sudo ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers || { echo "Failed to update sudoers"; exit 1; }
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
# Function to fix permissions for 'admin' user
|
| 34 |
-
fix_admin_permissions() {
|
| 35 |
-
echo "* Fixing permissions for 'admin' user *"
|
| 36 |
-
#chown -R admin:admin /home/admin || { echo "Failed to change ownership"; exit 1; }
|
| 37 |
-
chmod -R 777 /home/* || { echo "Failed to set permissions"; exit 1; }
|
| 38 |
-
}
|
| 39 |
|
| 40 |
# Function to activate virtual environment
|
| 41 |
activate_virtual_env() {
|
|
|
|
| 7 |
echo "* The host File of this container is: $(cat /etc/hosts)"
|
| 8 |
echo "* The Sudoers of this container is: $(cat /etc/sudoers)"
|
| 9 |
echo "* ID of the user running the script:($whoami) *ID : $(id -u) * Group: $(id -g)"
|
| 10 |
+
echo "* Changing User to Admin :$(echo "toor" || su - admin)"
|
| 11 |
echo "* Current User WHO AM I $(whoami)"
|
| 12 |
echo "* Status of Admin: $(id admin 2>/dev/null || echo 'Admin user not found')"
|
| 13 |
}
|
|
|
|
| 15 |
start_ssh_service() {
|
| 16 |
if ! pgrep -x "sshd" >/dev/null; then
|
| 17 |
echo "* Starting SSH server on port 2222 *"
|
| 18 |
+
#/usr/sbin/sshd -p 2222 || { echo "Failed to start SSH server"; exit 1; }
|
| 19 |
+
/usr/sbin/sshd -D || { echo "Failed to start SSH server"; exit 1; }
|
| 20 |
else
|
| 21 |
echo "* SSH server is already running *"
|
| 22 |
fi
|
| 23 |
}
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
# Function to activate virtual environment
|
| 27 |
activate_virtual_env() {
|