Created
June 5, 2022 06:03
-
-
Save moismailzai/1dec33977fdc78fe97b894e7ecc542f0 to your computer and use it in GitHub Desktop.
Export your current linux system for use with WSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -eux | |
if [ "$(whoami)" != "root" ] | |
then | |
sudo su -s "$0" | |
exit | |
fi | |
# truncate any logs that have built up during the install | |
find /var/log -type f -exec truncate --size=0 {} \; | |
# clear bash history | |
unset HISTFILE | |
> /root/.bash_history | |
> /root/.viminfo | |
for USER_HOME in /home/*; do | |
if [ -d "$USER_HOME" ]; then | |
[ -f "$USER_HOME"/.bash_history ] && truncate "$USER_HOME"/.bash_history --size 0 | |
[ -f "$USER_HOME"/.viminfo ] && truncate "$USER_HOME"/.viminfo --size 0 | |
fi | |
done | |
CURRENT_HOST=$(hostname -f) | |
cat << EOF > /etc/wsl.conf | |
# see https://docs.microsoft.com/en-us/windows/wsl/wsl-config | |
[boot] | |
command="service apache2 start; service apport start; service atop start; service atopacct start; service binfmt-support start; service blk-availability start; service cron start; service containerd start; service console-setup start; service dbus start; service finalrd start; service firewalld start; service irqbalance start; service keyboard-setup start; service kmod-static-nodes start; service ModemManager start; service multipathd start; service mysql start; service nfs-server start; service nfs-mountd start; service nfs-idmapd start; service nfsdcld start; service php8.1-fpm start; service postfix start; service postgresql start; service rpc-statd-notify start; service rpc-statd start; service rpcbind start; service rsyslog start; service snapd.seeded start; service snapd start; service ssh start; service supervisor start; service ufw start; service udisks2 start;" | |
[user] | |
default=vagrant | |
[automount] | |
mountFsTab=false | |
[network] | |
hostname=${CURRENT_HOST} | |
EOF | |
# export for WFS distro | |
tar czf /install.tar.gz \ | |
--exclude=/install.tar.gz \ | |
--exclude=/.autorelabel \ | |
--exclude=/dev \ | |
--exclude=/lost+found \ | |
--exclude=/media \ | |
--exclude=/mnt \ | |
--exclude=/proc \ | |
--exclude=/run \ | |
--exclude=/swap.img \ | |
--exclude=/sys \ | |
--exclude=/tmp \ | |
/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment