-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathinstall_LSW.sh
More file actions
executable file
·138 lines (124 loc) · 4.33 KB
/
install_LSW.sh
File metadata and controls
executable file
·138 lines (124 loc) · 4.33 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
# only root can run this script
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
echo "=== Linux Subsystem for Windows Installation ==="
echo ""
# Detect package manager and install dependencies
echo "Installing required dependencies..."
if command -v pacman >/dev/null 2>&1; then
# Arch-based system (CachyOS, Manjaro, etc.)
echo "Detected Arch-based system, using pacman..."
pacman -Sy --noconfirm virtualbox wmctrl
echo "Dependencies installed successfully!"
elif command -v apt >/dev/null 2>&1; then
# Debian-based system (Ubuntu, etc.)
echo "Detected Debian-based system, using apt..."
apt update
apt install -y virtualbox wmctrl
echo "Dependencies installed successfully!"
elif command -v dnf >/dev/null 2>&1; then
# Fedora-based system
echo "Detected Fedora-based system, using dnf..."
dnf install -y VirtualBox wmctrl
echo "Dependencies installed successfully!"
else
echo "Warning: Could not detect package manager. Please install virtualbox and wmctrl manually."
fi
echo ""
echo "Copying files and setting permissions..."
# copying files + setting permissions
rm -f /usr/bin/windows.sh
ln -s "$(pwd)/windows.sh" /usr/bin/windows.sh
chmod +x /usr/bin/windows.sh
# Always create a fresh Windows.desktop with correct Exec line
# Use new icons for launchers
# Get the actual script directory (where the files are located)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Set icon paths to use only icons/ subfolder
WINDOWS_ICON="$SCRIPT_DIR/icons/windows.png"
POWERSHELL_ICON="$SCRIPT_DIR/icons/powershell.png"
# Create Windows launcher
cat > /usr/share/applications/Windows.desktop <<EOF
[Desktop Entry]
Version=1.0
Type=Application
Name=Windows
Comment=Open with Windows VM
Exec=/usr/bin/windows.sh %f
Icon=$WINDOWS_ICON
Path=
Terminal=false
StartupNotify=false
Categories=Utility
EOF
chmod +x /usr/share/applications/Windows.desktop
\cp ./savewindows.sh /usr/bin/
chmod +x /usr/bin/savewindows.sh
\cp ./SaveWindows.desktop /usr/share/applications/
chmod +x /usr/share/applications/SaveWindows.desktop
\cp ./umountRoot.sh /usr/bin/
chmod +x /usr/bin/umountRoot.sh
\cp ./UmountRoot.desktop /usr/share/applications/
chmod +x /usr/share/applications/UmountRoot.desktop
# Copy PowerShell helper scripts
\cp ./powershell-as-admin.cmd /usr/bin/
chmod +x /usr/bin/powershell-as-admin.cmd
\cp ./powershell.cmd /usr/bin/
chmod +x /usr/bin/powershell.cmd
# Create Powershell in Windows launcher
cat > /usr/share/applications/PowershellInWindows.desktop <<EOF
[Desktop Entry]
Version=1.0
Type=Application
Name=Powershell in Windows
Comment=Open Powershell in Windows VM
Exec=wmctrl -xa Windows || /usr/bin/windows.sh "$SCRIPT_DIR/powershell.cmd"
Icon=$POWERSHELL_ICON
Path=
Terminal=false
StartupNotify=false
Categories=Utility
EOF
chmod +x /usr/share/applications/PowershellInWindows.desktop
# Create Powershell as Admin in Windows launcher
cat > /usr/share/applications/PowershellAsAdminInWindows.desktop <<EOF
[Desktop Entry]
Version=1.0
Type=Application
Name=Powershell as Admin in Windows
Comment=Open Powershell as Administrator in Windows VM
Exec=wmctrl -xa Windows || /usr/bin/windows.sh "$SCRIPT_DIR/powershell-as-admin.cmd"
Icon=$POWERSHELL_ICON
Path=
Terminal=false
StartupNotify=false
Categories=Utility
EOF
chmod +x /usr/share/applications/PowershellAsAdminInWindows.desktop
# Update Apps without logout
update-desktop-database /usr/share/applications/
echo "Files installed successfully!"
# Check for password file
echo ""
echo "Checking password file..."
if [ ! -f "vm_password.txt" ]; then
echo "Password file 'vm_password.txt' not found."
echo "Please create this file with your VM password before using the system."
echo "Example: echo 'your_password_here' > vm_password.txt"
else
echo "Password file found."
fi
echo ""
echo "Skipping VirtualBox VM configuration in base install."
echo "Run ./configure_virtualbox.sh to set up VM integration (shared folder, seamless mode, taskbar)."
echo ""
echo "=== Installation completed successfully! ==="
echo ""
echo "Next steps:"
echo "1. Create vm_password.txt with your VM password if not already done"
echo "2. Right-click any file and select 'Open with Windows' to test"
echo "3. Use 'SaveWindows' app to save VM state when not in use"
echo "4. Use 'UmountRoot' to temporarily unmount the root directory for security"