Improved gui
This commit is contained in:
28
gui/dialog_share_create.sh
Executable file
28
gui/dialog_share_create.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
TMP_FILE=$(mktemp)
|
||||
|
||||
# Ask for username
|
||||
dialog --backtitle "Create SMB share" --inputbox "Enter share name:" 10 40 2>"$TMP_FILE"
|
||||
SHARE_NAME=$(<"$TMP_FILE")
|
||||
|
||||
# Ask for password (input will be hidden)
|
||||
dialog --backtitle "Create SMB share" --inputbox "Enter associated username:" 10 40 2>"$TMP_FILE"
|
||||
USERNAME=$(<"$TMP_FILE")
|
||||
|
||||
|
||||
|
||||
# 3) Call the external script and capture output
|
||||
# adjust the path (“../add_smb_user.sh”) as needed
|
||||
TMP_OUT=$(mktemp)
|
||||
bash ./../create_user_share.sh "$SHARE_NAME" "$USERNAME" >"$TMP_OUT" 2>&1
|
||||
|
||||
# 4) Display the result (use --msgbox for short, --textbox for multiline)
|
||||
dialog --backtitle "Create SMB share" \
|
||||
--title "Result" \
|
||||
--textbox "$TMP_OUT" 20 60
|
||||
|
||||
rm -f "$TMP_OUT"
|
||||
|
||||
|
||||
rm -f "$TMP_FILE"
|
||||
30
gui/dialog_user_add.sh
Executable file
30
gui/dialog_user_add.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
TMP_FILE=$(mktemp)
|
||||
|
||||
# Ask for username
|
||||
dialog --backtitle "Add User" --inputbox "Enter new username:" 10 40 2>"$TMP_FILE"
|
||||
USERNAME=$(<"$TMP_FILE")
|
||||
|
||||
# Ask for password (input will be hidden)
|
||||
dialog --backtitle "Add User" --insecure --passwordbox "Enter password for $USERNAME:" 10 40 2>"$TMP_FILE"
|
||||
PASSWORD=$(<"$TMP_FILE")
|
||||
|
||||
|
||||
|
||||
# 3) Call the external script and capture output
|
||||
# adjust the path (“../add_smb_user.sh”) as needed
|
||||
TMP_OUT=$(mktemp)
|
||||
bash ./../add_smb_user.sh "$USERNAME" "$PASSWORD" >"$TMP_OUT" 2>&1
|
||||
|
||||
# 4) Display the result (use --msgbox for short, --textbox for multiline)
|
||||
dialog --backtitle "Add SMB User" \
|
||||
--title "Result" \
|
||||
--textbox "$TMP_OUT" 20 60
|
||||
|
||||
rm -f "$TMP_OUT"
|
||||
|
||||
|
||||
# dialog --msgbox "User '$USERNAME' with given password would be created." 8 50
|
||||
|
||||
rm -f "$TMP_FILE"
|
||||
20
gui/dialog_user_list.sh
Executable file
20
gui/dialog_user_list.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
TMP_FILE=$(mktemp)
|
||||
|
||||
# 3) Call the external script and capture output
|
||||
# adjust the path (“../add_smb_user.sh”) as needed
|
||||
TMP_OUT=$(mktemp)
|
||||
bash ./../list_smb_users.sh >"$TMP_OUT" 2>&1
|
||||
|
||||
# 4) Display the result (use --msgbox for short, --textbox for multiline)
|
||||
dialog --backtitle "SMB Users" \
|
||||
--title "SMB Users" \
|
||||
--textbox "$TMP_OUT" 20 60
|
||||
|
||||
rm -f "$TMP_OUT"
|
||||
|
||||
|
||||
# dialog --msgbox "User '$USERNAME' with given password would be created." 8 50
|
||||
|
||||
rm -f "$TMP_FILE"
|
||||
26
gui/dialog_user_remove.sh
Executable file
26
gui/dialog_user_remove.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
TMP_FILE=$(mktemp)
|
||||
|
||||
# Ask for username
|
||||
dialog --backtitle "Remove SMB User" --inputbox "Enter username to be removed:" 10 40 2>"$TMP_FILE"
|
||||
USERNAME=$(<"$TMP_FILE")
|
||||
|
||||
|
||||
|
||||
# 3) Call the external script and capture output
|
||||
# adjust the path (“../add_smb_user.sh”) as needed
|
||||
TMP_OUT=$(mktemp)
|
||||
bash ./../remove_smb_user.sh "$USERNAME" >"$TMP_OUT" 2>&1
|
||||
|
||||
# 4) Display the result (use --msgbox for short, --textbox for multiline)
|
||||
dialog --backtitle "Remove SMB User" \
|
||||
--title "Result" \
|
||||
--textbox "$TMP_OUT" 20 60
|
||||
|
||||
rm -f "$TMP_OUT"
|
||||
|
||||
|
||||
# dialog --msgbox "User '$USERNAME' with given password would be created." 8 50
|
||||
|
||||
rm -f "$TMP_FILE"
|
||||
49
gui/main.sh
Executable file
49
gui/main.sh
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
TMP_FILE=$(mktemp)
|
||||
TITLE="System Administration Tool"
|
||||
|
||||
while true; do
|
||||
dialog --clear \
|
||||
--backtitle "$TITLE" \
|
||||
--title "Main Menu" \
|
||||
--menu "Choose an action:" 15 50 6 \
|
||||
1 "Add User" \
|
||||
2 "Remove User" \
|
||||
3 "List Users" \
|
||||
4 "Create Share" \
|
||||
5 "Remove Share" \
|
||||
6 "Exit" 2>"$TMP_FILE"
|
||||
|
||||
CHOICE=$(<"$TMP_FILE")
|
||||
|
||||
case $CHOICE in
|
||||
1)
|
||||
./dialog_user_add.sh
|
||||
;;
|
||||
2)
|
||||
./dialog_user_remove.sh
|
||||
;;
|
||||
3)
|
||||
./dialog_user_list.sh
|
||||
;;
|
||||
4)
|
||||
./dialog_share_create.sh
|
||||
;;
|
||||
5)
|
||||
dialog --inputbox "Enter share name to remove:" 10 40 2>"$TMP_FILE"
|
||||
SHARE=$(<"$TMP_FILE")
|
||||
dialog --msgbox "Share '$SHARE' would be removed." 8 40
|
||||
;;
|
||||
6)
|
||||
break
|
||||
;;
|
||||
*)
|
||||
dialog --msgbox "Invalid option." 8 30
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
clear
|
||||
rm -f "$TMP_FILE"
|
||||
echo "Exited."
|
||||
Reference in New Issue
Block a user