Skip to content

Commit 7a5666e

Browse files
author
Jonas Erbe
committed
Setup is working. Some messages are wrong or missing. README is not completed.
1 parent f0e6885 commit 7a5666e

File tree

19 files changed

+998
-2
lines changed

19 files changed

+998
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

.gitmodules

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[submodule "lib"]
2+
path = lib
3+
url = ssh://jonas-erbe.synology.me/volume1/git/projects/script-libs
4+
branch = master
5+
[submodule "script-libs"]
6+
path = script-libs
7+
url = ssh://jonas-erbe.synology.me/volume1/git/projects/script-libs

LICENSE.MD

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Jonas Erbe
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,22 @@
1-
# WSL-setup-script-with-onboarding
2-
A script for linux beginners, that is setting up the windows subsystem for linux, which is explaining the single setup steps.
1+
This repository contains a setup script doing the initial setup of the [*Windows Subsystem for Linux*](https://de.wikipedia.org/wiki/Windows_Subsystem_for_Linux). After the installtion you will be provided with a functioning Ubuntu installation able to launch applications with a GUI. The windows of the applications running within Ubuntu seamlessly integrate within your Windows System. During the setup process the script prints short descriptions about what the setup is doing in each particular setup step.
2+
3+
# Usage
4+
5+
1. [Install Ubuntu](https://www.microsoft.com/de-de/p/ubuntu/9nblggh4msv6?rtc=1&activetab=pivot%3Aoverviewtab)
6+
1. [Download the script](https://github.com/jason076/wsl-onboarding/releases/download/v0.2.0/wsl-onboarding.zip)
7+
1. *Optional but* **strongly recommended**: This script uses admin permissions, thus the script has the permission to alter your system files. For that reason you should ensure that the files you have downloaded have not been altered.
8+
1. Open the directory containing the downloaded zip file in the explorer
9+
1. Hold shift and right click on to the white space next to the listed files
10+
1. Click on the context menu entry *Start Powershell here*
11+
1. Enter the following command: `Get-FileHash .\wsl-onboarding.zip -Algorithm MD5`
12+
1. Compare the output with this [hash](https://github.com/jason076/wsl-onboarding/releases/download/v0.2.0/wsl-onboarding.md5) (can be opened with a texteditor)
13+
1. IF THE HASHES DO NOT MATCH DON'T RUN THE SCRIPT. IT HAS BEEN ALTERED AND IS MAYBE CONTAINING MALICIOUS CODE.
14+
1. Extract the zip archive
15+
1. Open the extracted directory, right click on *run-setup.ps1* and click on *Run with Powershell*
16+
17+
# Work in Progress
18+
This project uses libraries from https://github.com/jason076/script-libs
19+
## Contributing
20+
## Further Reading
21+
22+

bin/setup.sh

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
#!/bin/sh
2+
3+
# WSL onboarding script
4+
# Does the initial setup for wsl using VcXsrv as a XServer.
5+
# Install Ubuntu using the windows store and enable WSL in "Windows optional features"
6+
# As an alternative to enable the WSL manually you can start this script with the
7+
# bundeled powershell script. Consult the README for more information.
8+
9+
# AUTHOR: Jonas Erbe
10+
# GITHUB: https://github.com/jason076
11+
# REPOSITORY: https://github.com/jason076/wsl-onboarding
12+
13+
# throw error if an unset variable is used
14+
set -u
15+
16+
# constants
17+
18+
# Global variables
19+
LANGUAGE="de"
20+
export LANGUAGE
21+
22+
23+
#######################################
24+
# Load language file
25+
# Globals:
26+
# LANGUAGE
27+
# Arguments:
28+
# none
29+
# Returns:
30+
# 0: language loaded successfully
31+
# 1: language does not exist
32+
#######################################
33+
load_language() {
34+
35+
# TODO(jonas): choose language dialog
36+
37+
# load language file
38+
lang_file=share/language/"${LANGUAGE}".sh
39+
if [ -f "${lang_file}" ]; then
40+
. "${lang_file}"
41+
return 0
42+
else
43+
return 1
44+
fi
45+
}
46+
47+
#######################################
48+
# Install default WSL config files
49+
# Globals:
50+
# None
51+
# Arguments:
52+
# None
53+
# Returns:
54+
# None
55+
#######################################
56+
57+
install_default_config() {
58+
# TODO(jason076): Check for errors and return appropriate value
59+
cp -b ./share/default-config/xinitrc ~/.xinitrc
60+
61+
# TODO(jason076): Check Ubuntu standard files and include them
62+
cp -b ./share/default-config/profile ~/.profile
63+
64+
# TODO(jason076): Add wsl.conf to message
65+
sudo cp -b ./share/default-config/wsl.conf /etc/wsl.conf
66+
67+
# binaries
68+
if [ ! -d ~/.local/bin ]; then
69+
mkdir -p ~/.local/bin
70+
fi
71+
72+
cp -b ./share/default-config/startX.sh ~/.local/bin/startX.sh
73+
}
74+
75+
#######################################
76+
# Create scaleable fonts according to Xming Documentation:
77+
# http://www.straightrunning.com/XmingNotes/fonts.php
78+
# Globals:
79+
# None
80+
# Arguments:
81+
# None
82+
# Returns:
83+
# None
84+
#######################################
85+
86+
# TODO(jason076): Useless remove in future
87+
create_scalable_fonts() {
88+
# assuming that 64-bit Xming is installed
89+
# index fonts for XServer
90+
cd "/mnt/c/Program Files/Xming"
91+
./mkfontscale.exe 'C:\Windows\Fonts' 2>/dev/null
92+
./mkfontscale.exe -b -f -l 'C:\Windows\Fonts' 2>/dev/null
93+
94+
# Add windows fonts to the font dirs of xming
95+
if grep -i 'C:\\Windows\\Fonts' "/mnt/c/Program Files/Xming/font-dirs"; then
96+
return 0
97+
else
98+
if echo 'C:\Windows\Fonts' >> "/mnt/c/Program Files/Xming/font-dirs"; then
99+
return 0
100+
else
101+
return 1
102+
fi
103+
fi
104+
105+
# TODO(jason076) Add additonal fonts
106+
107+
# Will be removed
108+
#if depmgmt__need "fontconfig"; then
109+
# make fonts available to applications
110+
#if [ ! -L /usr/local/share/fonts/windows ]; then
111+
# sudo ln -s /mnt/c/Windows/Fonts /usr/local/share/fonts/windows
112+
#fi
113+
#echo "Indexing fonts may take a while. Please wait ..."
114+
#fc-cache -rf
115+
#else
116+
# return 1
117+
#fi
118+
}
119+
120+
121+
main() {
122+
123+
PATH="${PATH}:`pwd`/bin"
124+
125+
. `pwd`/lib/libmgmt.sh
126+
127+
# load language
128+
load_language
129+
if [ $? -ne 0 ]; then
130+
echo "Failed loading language file! Exit!"
131+
exit 1
132+
fi
133+
134+
echo "${WSL_DIALOG}"
135+
136+
# load script libraries
137+
libmgmt__load "io"
138+
libmgmt__load "wsl"
139+
libmgmt__load "depmgmt"
140+
141+
142+
io__init 'TRUE' 0 0
143+
io__message "${WSL_WELCOME}"
144+
io__message "${WSL_INFO}"
145+
146+
# upgrade system
147+
io__message "${WSL_SYS_UPGRADE}"
148+
sudo apt update
149+
sudo apt full-upgrade
150+
io__message "${WSL_SYS_UPGRADE_FINISHED}"
151+
152+
# only continue if ubuntu is running in admin mode
153+
if wsl__is_winadmin; then
154+
:
155+
else
156+
io__message "${WSL_NO_ADMIN}"
157+
exit 1
158+
fi
159+
160+
# install default config files
161+
io__message "${WSL_INSTALL_CONFIG}"
162+
install_default_config
163+
164+
# install VcXsrv
165+
# TODO(jason076): Change message to VcXsrc
166+
io__message "${WSL_INSTALL_XMING}"
167+
./bin/vcxsrv-installer.exe
168+
169+
#io__message "${WSL_CREATE_SCALEABLE_FONT}"
170+
#
171+
#if create_scalable_fonts; then
172+
# :
173+
#else
174+
# io__message "${WSL_SCALEABLE_FAILED}"
175+
# exit 1
176+
#fi
177+
178+
# TODO(jason076): Add a fix for blurry fonts caused by dpi scaling
179+
# Dialog for choosing a gdk_scale factor
180+
181+
# TODO(jason076): Add message
182+
# Install dbus-x11
183+
if depmgmt__need dbus-x11; then
184+
:
185+
else
186+
exit 1
187+
fi
188+
189+
# TODO(jason076): Add message
190+
# Install gtk2-engines-pixbuf
191+
if depmgmt__need gtk2-engines-pixbuf; then
192+
:
193+
else
194+
exit 1
195+
fi
196+
197+
# Install terminator
198+
io__message "${WSL_INSTALL_TERMINATOR}"
199+
if depmgmt__need terminator; then
200+
:
201+
else
202+
io__message "${WSL_INSTALL_TERMINATOR_FAILED}"
203+
exit 1
204+
fi
205+
206+
# TODO(jason076): Add message
207+
# Install firefox
208+
if depmgmt__need firefox; then
209+
:
210+
else
211+
exit 1;
212+
fi
213+
214+
# Setup succesfull
215+
io__message "${WSL_SUCCESSFULL}"
216+
exit 0
217+
}
218+
219+
main "$@"

bin/vcxsrv-installer.exe

39.6 MB
Binary file not shown.

0 commit comments

Comments
 (0)