forked from p4lang/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create release and development VMs (p4lang#439)
* vm: trim trailing whitespace Signed-off-by: Radostin Stoyanov <[email protected]> * Create dev and release VMs Signed-off-by: Radostin Stoyanov <[email protected]>
- Loading branch information
Showing
7 changed files
with
213 additions
and
142 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
# Print commands and exit on errors | ||
set -xe | ||
|
||
useradd -m -d /home/p4 -s /bin/bash p4 | ||
echo "p4:p4" | chpasswd | ||
echo "p4 ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/99_p4 | ||
chmod 440 /etc/sudoers.d/99_p4 | ||
usermod -aG vboxsf p4 | ||
|
||
# Install p4 logo as wallpaper | ||
mv /home/vagrant/p4-logo.png /usr/share/lubuntu/wallpapers/lubuntu-default-wallpaper.png | ||
|
||
# 2021-Mar-06 this command failed with an error that the file did not exist. | ||
#sed -i s@#background=@background=/usr/share/lubuntu/wallpapers/1604-lubuntu-default-wallpaper.png@ /etc/lightdm/lightdm-gtk-greeter.conf | ||
# The following command will hopefully cause the P4 logo to be normal | ||
# size and centered on the initial desktop image, rather than scaled | ||
# and stretched and cropped horribly. | ||
#sed -i s@wallpaper_mode=crop@wallpaper_mode=center@ /etc/xdg/pcmanfm/lubuntu/desktop-items-0.conf | ||
|
||
# If that does not have the desired effect, another possibility is | ||
# executing that command to edit the same string in file | ||
# /etc/xdg/pcmanfm/lubuntu/pcmanfm.conf | ||
|
||
# TBD: Ubuntu 20.04 does not have the light-locker package, so it | ||
# fails if you try to remove it. Probably enabling auto-login | ||
# requires a different modification than is done below with the cat << | ||
# EOF command. | ||
|
||
# Disable screensaver | ||
#apt-get -y remove light-locker | ||
|
||
# Automatically log into the P4 user | ||
#cat << EOF | tee -a /etc/lightdm/lightdm.conf.d/10-lightdm.conf | ||
#[SeatDefaults] | ||
#autologin-user=p4 | ||
#autologin-user-timeout=0 | ||
#user-session=Lubuntu | ||
#EOF |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
# Print commands and exit on errors | ||
set -xe | ||
|
||
export DEBIAN_FRONTEND=noninteractive | ||
|
||
# Atom install steps came from this page on 2020-May-11: | ||
# https://flight-manual.atom.io/getting-started/sections/installing-atom/#platform-linux | ||
|
||
echo "deb [arch=amd64] https://packagecloud.io/AtomEditor/atom/any/ any main" | sudo tee /etc/apt/sources.list.d/atom.list | ||
wget -qO - https://packagecloud.io/AtomEditor/atom/gpgkey | apt-key add - | ||
|
||
# Add repository with P4 packages | ||
# https://build.opensuse.org/project/show/home:p4lang | ||
|
||
echo "deb http://download.opensuse.org/repositories/home:/p4lang/xUbuntu_20.04/ /" | sudo tee /etc/apt/sources.list.d/home:p4lang.list | ||
wget -qO - "http://download.opensuse.org/repositories/home:/p4lang/xUbuntu_20.04/Release.key" | apt-key add - | ||
|
||
apt-get update -qq | ||
|
||
apt-get -qq -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade | ||
apt-get install -qq -y --no-install-recommends --fix-missing\ | ||
atom \ | ||
ca-certificates \ | ||
curl \ | ||
emacs \ | ||
git \ | ||
iproute2 \ | ||
lubuntu-desktop \ | ||
net-tools \ | ||
python3 \ | ||
python3-pip \ | ||
tcpdump \ | ||
unzip \ | ||
valgrind \ | ||
vim \ | ||
wget \ | ||
xcscope-el \ | ||
xterm \ | ||
p4lang-p4c \ | ||
p4lang-bmv2 \ | ||
p4lang-pi | ||
|
||
sudo pip3 install -U scapy ipaddr ptf psutil grpcio |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/bash | ||
|
||
# Print script commands and exit on errors. | ||
set -xe | ||
|
||
# --- Mininet --- # | ||
git clone git://github.com/mininet/mininet mininet | ||
cd mininet | ||
PATCH_DIR="${HOME}/patches" | ||
patch -p1 < "${PATCH_DIR}/mininet-dont-install-python2.patch" || echo "Errors while attempting to patch mininet, but continuing anyway ..." | ||
cd .. | ||
# TBD: Try without installing openvswitch, i.e. no '-v' option, to see | ||
# if everything still works well without it. | ||
sudo ./mininet/util/install.sh -nw | ||
|
||
find /usr/lib /usr/local $HOME/.local | sort > $HOME/usr-local-7-after-mininet-install.txt | ||
|
||
# --- Tutorials --- # | ||
git clone https://github.com/p4lang/tutorials | ||
sudo mv tutorials /home/p4 | ||
sudo chown -R p4:p4 /home/p4/tutorials | ||
|
||
# --- Emacs --- # | ||
sudo cp p4_16-mode.el /usr/share/emacs/site-lisp/ | ||
sudo mkdir /home/p4/.emacs.d/ | ||
echo "(autoload 'p4_16-mode' \"p4_16-mode.el\" \"P4 Syntax.\" t)" > init.el | ||
echo "(add-to-list 'auto-mode-alist '(\"\\.p4\\'\" . p4_16-mode))" | tee -a init.el | ||
sudo mv init.el /home/p4/.emacs.d/ | ||
sudo ln -s /usr/share/emacs/site-lisp/p4_16-mode.el /home/p4/.emacs.d/p4_16-mode.el | ||
sudo chown -R p4:p4 /home/p4/.emacs.d/ | ||
|
||
# --- Vim --- # | ||
cd ~ | ||
mkdir .vim | ||
cd .vim | ||
mkdir ftdetect | ||
mkdir syntax | ||
echo "au BufRead,BufNewFile *.p4 set filetype=p4" >> ftdetect/p4.vim | ||
echo "set bg=dark" >> ~/.vimrc | ||
sudo mv ~/.vimrc /home/p4/.vimrc | ||
cp ~/p4.vim syntax/p4.vim | ||
cd ~ | ||
sudo mv .vim /home/p4/.vim | ||
sudo chown -R p4:p4 /home/p4/.vim | ||
sudo chown p4:p4 /home/p4/.vimrc | ||
|
||
# --- Adding Desktop icons --- # | ||
DESKTOP=/home/${USER}/Desktop | ||
mkdir -p ${DESKTOP} | ||
|
||
cat > ${DESKTOP}/Terminal.desktop << EOF | ||
[Desktop Entry] | ||
Encoding=UTF-8 | ||
Type=Application | ||
Name=Terminal | ||
Name[en_US]=Terminal | ||
Icon=konsole | ||
Exec=/usr/bin/x-terminal-emulator | ||
Comment[en_US]= | ||
EOF | ||
|
||
cat > ${DESKTOP}/Wireshark.desktop << EOF | ||
[Desktop Entry] | ||
Encoding=UTF-8 | ||
Type=Application | ||
Name=Wireshark | ||
Name[en_US]=Wireshark | ||
Icon=wireshark | ||
Exec=/usr/bin/wireshark | ||
Comment[en_US]= | ||
EOF | ||
|
||
sudo mkdir -p /home/p4/Desktop | ||
sudo mv /home/${USER}/Desktop/* /home/p4/Desktop | ||
sudo chown -R p4:p4 /home/p4/Desktop/ | ||
|
||
# Do this last! | ||
sudo reboot |
Oops, something went wrong.