mirror of https://github.com/01-edu/public.git
Frenchris
5 years ago
committed by
GitHub
44 changed files with 1245 additions and 85 deletions
@ -0,0 +1,64 @@
|
||||
# Ubuntu |
||||
|
||||
## OS Installation |
||||
|
||||
Download and boot the [last Ubuntu release](http://releases.ubuntu.com/19.04/ubuntu-19.04-desktop-amd64.iso). |
||||
|
||||
Follow the steps : |
||||
|
||||
![img1](https://user-images.githubusercontent.com/32063953/56804679-85867580-681e-11e9-8965-e87c6a89fac0.png) |
||||
![img2](https://user-images.githubusercontent.com/32063953/56963599-3eb3bb00-6b51-11e9-9778-4f3bb9993c74.png) |
||||
![img3](https://user-images.githubusercontent.com/32063953/56963600-3eb3bb00-6b51-11e9-94cc-279406f37def.png) |
||||
|
||||
The partitioning is : |
||||
|
||||
- 256 MB : EFI partition |
||||
- 20 GB : system partition |
||||
- 32 GB : unused partition (will be used later) |
||||
- rest : unused partition (will be used later) |
||||
|
||||
![img4](https://user-images.githubusercontent.com/32063953/56963602-3eb3bb00-6b51-11e9-8977-38e4e67d6ce1.png) |
||||
![img5](https://user-images.githubusercontent.com/32063953/56963603-3f4c5180-6b51-11e9-9349-46ab90287691.png) |
||||
![img6](https://user-images.githubusercontent.com/32063953/56963604-3f4c5180-6b51-11e9-8df2-5016771e6e07.png |
||||
) |
||||
|
||||
Remove the installation disk and then reboot. |
||||
|
||||
Skip the welcoming window. |
||||
|
||||
Don't install updates if Ubuntu asks to. The scripts will. |
||||
|
||||
![img8](https://user-images.githubusercontent.com/32063953/56804701-8d461a00-681e-11e9-8825-dfc69f8268bf.png) |
||||
![img9](https://user-images.githubusercontent.com/32063953/56804703-8d461a00-681e-11e9-840c-498ccab7d911.png) |
||||
![img10](https://user-images.githubusercontent.com/32063953/56804704-8ddeb080-681e-11e9-96ff-6c8783c5aacc.png) |
||||
![img11](https://user-images.githubusercontent.com/32063953/56804706-8ddeb080-681e-11e9-85e1-20c5b6956a36.png) |
||||
|
||||
## OS configuration |
||||
|
||||
```shell |
||||
student@tmp-hostname:~$ wget github.com/01-edu/public/archive/master.zip |
||||
student@tmp-hostname:~$ unzip master.zip |
||||
student@tmp-hostname:~$ cd public-master/scripts |
||||
student@tmp-hostname:~$ sudo ./install_client.sh |
||||
[...] |
||||
Ask for student user password (will be removed later) |
||||
[...] |
||||
Ask to set the root password |
||||
[...] |
||||
Long installation/configuration process |
||||
[...] |
||||
student@tmp-hostname:~$ cat dconfig.txt | dconf load / |
||||
student@tmp-hostname:~$ reboot |
||||
``` |
||||
|
||||
The system is now read-only, every data is written to a temporary partition. |
||||
|
||||
The session is password-less. |
||||
|
||||
To gain a superuser terminal with read/write access to the filesystem, type these commands: |
||||
|
||||
```shell |
||||
student@tmp-hostname:~$ su - |
||||
Password: |
||||
root@tmp-hostname:~# overlayroot-chroot |
||||
``` |
@ -0,0 +1,59 @@
|
||||
#!/bin/bash |
||||
|
||||
# Configure Terminal |
||||
|
||||
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" |
||||
cd $SCRIPT_DIR |
||||
. set.sh |
||||
|
||||
# Makes bash case-insensitive |
||||
cat <<EOF>> /etc/inputrc |
||||
set completion-ignore-case On |
||||
EOF |
||||
|
||||
# Enhance Linux prompt |
||||
cat <<EOF> /etc/issue |
||||
Kernel build: \v |
||||
Kernel package: \r |
||||
Date: \d \t |
||||
IP address: \4 |
||||
Terminal: \l@\n.\O |
||||
|
||||
EOF |
||||
|
||||
# Enable Bash completion |
||||
apt-get -y install bash-completion |
||||
|
||||
cat <<EOF>> /etc/bash.bashrc |
||||
if ! shopt -oq posix; then |
||||
if [ -f /usr/share/bash-completion/bash_completion ]; then |
||||
. /usr/share/bash-completion/bash_completion |
||||
elif [ -f /etc/bash_completion ]; then |
||||
. /etc/bash_completion |
||||
fi |
||||
fi |
||||
EOF |
||||
|
||||
# Set-up all users |
||||
for DIR in $(ls -1d /root /home/* 2>/dev/null || true) |
||||
do |
||||
# Hide login informations |
||||
touch $DIR/.hushlogin |
||||
|
||||
# Add convenient aliases & behaviors |
||||
cat <<-'EOF'>> $DIR/.bashrc |
||||
HISTCONTROL=ignoreboth |
||||
export HISTFILESIZE= |
||||
export HISTSIZE= |
||||
export HISTTIMEFORMAT="%F %T " |
||||
alias l="ls $LS_OPTIONS -al --si" |
||||
alias df="df --si" |
||||
alias du="du -cs --si" |
||||
alias free="free -h --si" |
||||
alias pstree="pstree -palU" |
||||
EOF |
||||
|
||||
# Fix rights |
||||
USR=$(echo "$DIR" | rev | cut -d/ -f1 | rev) |
||||
chown -R $USR:$USR $DIR || true |
||||
done |
@ -0,0 +1,55 @@
|
||||
#!/bin/bash |
||||
|
||||
# Clean system |
||||
|
||||
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" |
||||
cd $SCRIPT_DIR |
||||
. set.sh |
||||
|
||||
# Purge useless packages |
||||
apt-get -y autoremove --purge |
||||
apt-get autoclean |
||||
apt-get clean |
||||
apt-get install |
||||
|
||||
rm -rf /root/.local |
||||
|
||||
# Remove connection logs |
||||
> /var/log/lastlog |
||||
> /var/log/wtmp |
||||
> /var/log/btmp |
||||
|
||||
# Remove machine ID |
||||
> /etc/machine-id |
||||
|
||||
# Remove logs |
||||
cd /var/log |
||||
rm -rf alternatives.log* |
||||
rm -rf apt/* |
||||
rm -rf auth.log |
||||
rm -rf dpkg.log* |
||||
rm -rf gpu-manager.log |
||||
rm -rf installer |
||||
rm -rf journal/d6e982aa8c9d4c1dbcbdcff195642300 |
||||
rm -rf kern.log |
||||
rm -rf syslog |
||||
rm -rf sysstat |
||||
|
||||
# Remove random seeds |
||||
rm -rf /var/lib/systemd/random-seed |
||||
rm -rf /var/lib/NetworkManager/secret_key |
||||
|
||||
# Remove network configs |
||||
rm -rf /etc/NetworkManager/system-connections/* |
||||
rm -rf /var/lib/bluetooth/* |
||||
rm -rf /var/lib/NetworkManager/* |
||||
|
||||
# Remove caches |
||||
rm -rf /var/lib/gdm3/.cache/* |
||||
rm -rf /root/.cache |
||||
rm -rf /home/student/.cache |
||||
|
||||
rm -rf /home/student/.sudo_as_admin_successful /home/student/.bash_logout |
||||
|
||||
rm -rf /tmp/* |
||||
rm -rf /tmp/.* || true |
@ -0,0 +1,64 @@
|
||||
apache2-utils |
||||
apt-utils |
||||
arp-scan |
||||
autossh |
||||
bash-completion |
||||
binutils |
||||
build-essential |
||||
console-data |
||||
console-setup |
||||
cron |
||||
curl |
||||
dialog |
||||
dmidecode |
||||
dnsutils |
||||
file |
||||
firmware-linux-nonfree |
||||
git |
||||
hdparm |
||||
iftop |
||||
ifupdown |
||||
iotop |
||||
iptables |
||||
iputils-ping |
||||
isc-dhcp-client |
||||
isc-dhcp-common |
||||
jq |
||||
less |
||||
linux-headers-amd64 |
||||
linux-image-amd64 |
||||
lm-sensors |
||||
locales |
||||
lsb-release |
||||
lshw |
||||
lsof |
||||
lzop |
||||
man |
||||
mc |
||||
mdadm |
||||
moreutils |
||||
nano |
||||
net-tools |
||||
nmap |
||||
ntpdate |
||||
nvme-cli |
||||
pciutils |
||||
psmisc |
||||
python |
||||
python3 |
||||
rsync |
||||
rsyslog |
||||
ssh |
||||
stress |
||||
sudo |
||||
sysstat |
||||
telnet |
||||
tig |
||||
traceroute |
||||
tree |
||||
tzdata |
||||
unzip |
||||
usbutils |
||||
wget |
||||
zerofree |
||||
zip |
@ -0,0 +1,131 @@
|
||||
[org/gnome/desktop/calendar] |
||||
show-weekdate=true |
||||
|
||||
[org/gnome/desktop/wm/preferences] |
||||
resize-with-right-button=true |
||||
|
||||
[org/gnome/desktop/peripherals/keyboard] |
||||
delay=uint32 350 |
||||
|
||||
[desktop/ibus/panel/emoji] |
||||
unicode-hotkey=@as [] |
||||
hotkey=@as [] |
||||
|
||||
[org/gnome/desktop/peripherals/touchpad] |
||||
two-finger-scrolling-enabled=true |
||||
disable-while-typing=false |
||||
|
||||
[org/gnome/login-screen] |
||||
enable-smartcard-authentication=false |
||||
enable-fingerprint-authentication=false |
||||
|
||||
[org/gnome/desktop/privacy] |
||||
report-technical-problems=false |
||||
remember-recent-files=false |
||||
|
||||
[org/gnome/desktop/screensaver] |
||||
lock-enabled=false |
||||
|
||||
[org/gnome/desktop/search-providers] |
||||
disable-external=true |
||||
|
||||
[org/gnome/desktop/interface] |
||||
gtk-im-module='gtk-im-context-simple' |
||||
clock-show-seconds=true |
||||
enable-animations=false |
||||
cursor-blink=false |
||||
clock-show-weekday=true |
||||
gtk-theme='Yaru-dark' |
||||
|
||||
[org/gnome/terminal/legacy] |
||||
menu-accelerator-enabled=false |
||||
|
||||
[org/gnome/desktop/media-handling] |
||||
automount-open=false |
||||
automount=false |
||||
autorun-never=true |
||||
|
||||
[org/gnome/terminal/legacy/keybindings] |
||||
reset-and-clear='<Primary>l' |
||||
|
||||
[org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9] |
||||
allow-bold=false |
||||
default-size-rows=48 |
||||
bold-is-bright=true |
||||
audible-bell=false |
||||
scrollback-lines=2147483647 |
||||
cursor-shape='ibeam' |
||||
default-size-columns=160 |
||||
|
||||
[org/gnome/desktop/background] |
||||
show-desktop-icons=false |
||||
|
||||
[org/gnome/desktop/peripherals/mouse] |
||||
accel-profile='flat' |
||||
|
||||
[org/gnome/settings-daemon/plugins/color] |
||||
night-light-enabled=true |
||||
night-light-schedule-automatic=true |
||||
|
||||
[org/gnome/desktop/lockdown] |
||||
disable-print-setup=true |
||||
disable-printing=true |
||||
disable-user-switching=true |
||||
user-administration-disabled=true |
||||
|
||||
[org/gnome/settings-daemon/plugins/media-keys] |
||||
custom-keybindings=['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/'] |
||||
screensaver='' |
||||
|
||||
[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0] |
||||
binding='<Super>l' |
||||
command='lock_screen' |
||||
name='Lock screen' |
||||
|
||||
[org/gnome/settings-daemon/plugins/smartcard] |
||||
active=false |
||||
|
||||
[org/gnome/settings-daemon/plugins/remote-display] |
||||
active=false |
||||
|
||||
[org/gnome/settings-daemon/plugins/sharing] |
||||
active=false |
||||
|
||||
[org/gnome/settings-daemon/plugins/screensaver-proxy] |
||||
active=false |
||||
|
||||
[org/gnome/settings-daemon/plugins/gsdwacom] |
||||
active=false |
||||
|
||||
[org/gnome/settings-daemon/plugins/power] |
||||
sleep-inactive-ac-type='nothing' |
||||
sleep-inactive-ac-timeout=0 |
||||
|
||||
[org/gnome/shell] |
||||
enable-hot-corners=true |
||||
favorite-apps=['firefox.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.Terminal.desktop', 'sublime_text.desktop', 'vscodium.desktop', 'org.gnome.Calculator.desktop', 'gnome-control-center.desktop', 'org.gnome.tweaks.desktop', 'lock_screen.desktop', 'suspend_session.desktop', 'yelp.desktop'] |
||||
|
||||
[org/gnome/system/location] |
||||
enabled=false |
||||
|
||||
[org/gnome/desktop/session] |
||||
idle-delay=uint32 0 |
||||
|
||||
[org/gnome/mutter] |
||||
center-new-windows=true |
||||
|
||||
[org/gnome/calculator] |
||||
source-currency='' |
||||
source-units='degree' |
||||
button-mode='advanced' |
||||
word-size=64 |
||||
show-zeroes=false |
||||
base=10 |
||||
angle-units='degrees' |
||||
accuracy=9 |
||||
show-thousands=false |
||||
window-position=(1906, 826) |
||||
refresh-interval=604800 |
||||
target-units='radian' |
||||
number-format='fixed' |
||||
target-currency='' |
@ -0,0 +1,15 @@
|
||||
#!/bin/bash |
||||
|
||||
# Install firewall |
||||
|
||||
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" |
||||
cd $SCRIPT_DIR |
||||
. set.sh |
||||
|
||||
SSH_PORT=${1:-521} |
||||
|
||||
apt-get -y install ufw |
||||
|
||||
ufw logging off |
||||
ufw allow in "$SSH_PORT"/tcp |
||||
ufw --force enable |
@ -0,0 +1,9 @@
|
||||
#!/bin/bash |
||||
|
||||
# Install FX: command-line JSON processing tool (https://github.com/antonmedv/fx) |
||||
|
||||
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" |
||||
cd $SCRIPT_DIR |
||||
. set.sh |
||||
|
||||
npm install -g fx |
@ -0,0 +1,24 @@
|
||||
#!/bin/bash |
||||
|
||||
# Install Go |
||||
|
||||
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" |
||||
cd $SCRIPT_DIR |
||||
. set.sh |
||||
|
||||
apt-get -y install golang |
||||
|
||||
# Set-up all users |
||||
for DIR in $(ls -1d /root /home/* 2>/dev/null || true) |
||||
do |
||||
# Add convenient aliases & behaviors |
||||
cat <<-'EOF'>> $DIR/.bashrc |
||||
GOPATH=$HOME/go |
||||
PATH=$PATH:$GOPATH/bin |
||||
alias gobuild='CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w"' |
||||
EOF |
||||
|
||||
# Fix rights |
||||
USR=$(echo "$DIR" | rev | cut -d/ -f1 | rev) |
||||
chown -R $USR:$USR $DIR || true |
||||
done |
@ -0,0 +1,25 @@
|
||||
#!/bin/bash |
||||
|
||||
# Install Grub |
||||
|
||||
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" |
||||
cd $SCRIPT_DIR |
||||
. set.sh |
||||
|
||||
DISK=$1 |
||||
|
||||
apt-get -y install grub-efi-amd64 |
||||
|
||||
sed -i -e 's/message=/message_null=/g' /etc/grub.d/10_linux |
||||
|
||||
cat <<EOF>> /etc/default/grub |
||||
GRUB_TIMEOUT=0 |
||||
GRUB_RECORDFAIL_TIMEOUT=0 |
||||
GRUB_TERMINAL=console |
||||
GRUB_DISTRIBUTOR=`` |
||||
GRUB_DISABLE_OS_PROBER=true |
||||
GRUB_DISABLE_SUBMENU=y |
||||
EOF |
||||
|
||||
update-grub |
||||
grub-install $DISK |
@ -0,0 +1,87 @@
|
||||
#!/bin/bash |
||||
|
||||
# Configure Z01 client |
||||
|
||||
# Log stdout & stderr |
||||
exec > >(tee -i /tmp/install_client.log) |
||||
exec 2>&1 |
||||
|
||||
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" |
||||
cd $SCRIPT_DIR |
||||
. set.sh |
||||
|
||||
# Set root password |
||||
passwd root |
||||
|
||||
# Remove user password |
||||
passwd -d student |
||||
cp /etc/shadow /etc/shadow- |
||||
|
||||
SSH_PORT=521 |
||||
DISK=$(lsblk -o tran,kname,hotplug,type,fstype -pr | |
||||
grep -e nvme -e sata | |
||||
grep '0 disk' | |
||||
cut -d' ' -f2 | |
||||
sort | |
||||
head -n1) |
||||
|
||||
apt-get update |
||||
apt-get -y upgrade |
||||
apt-get -y autoremove --purge |
||||
|
||||
. bash_tweaks.sh |
||||
. ssh.sh |
||||
. firewall.sh |
||||
. ubuntu_tweaks.sh |
||||
. grub.sh "$DISK" |
||||
. go.sh |
||||
. nodejs.sh |
||||
. fx.sh |
||||
. sublime.sh |
||||
. vscode.sh |
||||
|
||||
# Install additional packages |
||||
PKGS=" |
||||
emacs |
||||
f2fs-tools |
||||
golang-mode |
||||
vim |
||||
xfsprogs |
||||
" |
||||
|
||||
apt-get -y install $PKGS |
||||
|
||||
# Remove fsck because the system partition will be read-only (overlayroot) |
||||
rm /usr/share/initramfs-tools/hooks/fsck |
||||
|
||||
# Copy system files |
||||
|
||||
cp -r system /tmp |
||||
cd /tmp/system |
||||
sed -i -e "s|::DISK::|$DISK|g" etc/udev/rules.d/10-local.rules |
||||
|
||||
# Fourth local partition |
||||
PART=$(lsblk -o tran,kname,hotplug,type,fstype -pr | |
||||
grep -v usb | |
||||
grep '0 part' | |
||||
cut -d' ' -f2 | |
||||
sort | |
||||
head -n4 | |
||||
tail -n1) |
||||
sed -i -e "s|::PART::|$PART|g" usr/share/initramfs-tools/scripts/init-premount/reformat |
||||
|
||||
apt-get -y install overlayroot |
||||
echo overlayroot=\"device:dev=$PART,recurse=0\" >> /etc/overlayroot.conf |
||||
|
||||
# Fix permissions |
||||
find . -type d -exec chmod 755 {} \; |
||||
find . -type f -exec chmod 644 {} \; |
||||
find . -type f -exec /bin/sh -c "file {} | grep -q 'shell script' && chmod +x {}" \; |
||||
cp --preserve=mode -RT . / |
||||
|
||||
cd $SCRIPT_DIR |
||||
rm -rf /tmp/system |
||||
|
||||
update-initramfs -u |
||||
|
||||
. clean.sh |
@ -0,0 +1,10 @@
|
||||
#!/bin/bash |
||||
|
||||
# Install Node.js |
||||
|
||||
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" |
||||
cd $SCRIPT_DIR |
||||
. set.sh |
||||
|
||||
curl -sL https://deb.nodesource.com/setup_10.x | bash - |
||||
apt-get -y install nodejs |
@ -0,0 +1,34 @@
|
||||
#!/bin/bash |
||||
|
||||
# Set scripting variables |
||||
|
||||
# Treat unset variables as an error when substituting. |
||||
set -u |
||||
|
||||
# Exit immediately if a command exits with a non-zero status. |
||||
set -e |
||||
|
||||
# Set the variable corresponding to the return value of a pipeline is the status |
||||
# of the last command to exit with a non-zero status, or zero if no command |
||||
# exited with a non-zero status |
||||
set -o pipefail |
||||
|
||||
# Separate tokens on newlines only |
||||
IFS=' |
||||
' |
||||
|
||||
# The value of this parameter is expanded like PS1 and the expanded value is the |
||||
# prompt printed before the command line is echoed when the -x option is set |
||||
# (see The Set Builtin). The first character of the expanded value is replicated |
||||
# multiple times, as necessary, to indicate multiple levels of indirection. |
||||
# \D{%F %T} prints date like this : 2019-12-31 23:59:59 |
||||
PS4='-\D{%F %T} ' |
||||
|
||||
# Print commands and their arguments as they are executed. |
||||
set -x |
||||
|
||||
# Skip dialogs during apt-get install commands |
||||
export DEBIAN_FRONTEND=noninteractive # DEBIAN_PRIORITY=critical |
||||
|
||||
export LC_ALL=C LANG=C |
||||
export SHELL=/bin/bash |
@ -0,0 +1,25 @@
|
||||
#!/bin/bash |
||||
|
||||
# Install OpenSSH |
||||
|
||||
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" |
||||
cd $SCRIPT_DIR |
||||
. set.sh |
||||
|
||||
SSH_PORT=${1:-521} |
||||
|
||||
# Install dependencies |
||||
apt-get -y install ssh |
||||
|
||||
cat <<EOF>> /etc/ssh/sshd_config |
||||
Port $SSH_PORT |
||||
PasswordAuthentication no |
||||
AllowUsers root |
||||
EOF |
||||
|
||||
mkdir -p /root/.ssh |
||||
chmod -f 700 /root/.ssh |
||||
# echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH30lZP4V26RVWWvAW91jM7UBSN68+xkuJc5cRionpMc' >> /root/.ssh/authorized_keys |
||||
chmod -f 600 /root/.ssh/authorized_keys || true |
||||
|
||||
systemctl restart sshd.service |
@ -0,0 +1,17 @@
|
||||
#!/bin/bash |
||||
|
||||
# Install Sublime Text & Sublime Merge |
||||
|
||||
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" |
||||
cd $SCRIPT_DIR |
||||
. set.sh |
||||
|
||||
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | apt-key add - |
||||
apt-get install -y apt-transport-https |
||||
|
||||
cat <<EOF> /etc/apt/sources.list.d/sublime-text.list |
||||
deb https://download.sublimetext.com/ apt/stable/ |
||||
EOF |
||||
|
||||
apt-get update |
||||
apt-get install -y sublime-text sublime-merge libgtk2.0-0 |
@ -0,0 +1,74 @@
|
||||
#!/bin/bash |
||||
|
||||
# Mount home as an overlay filesystem |
||||
|
||||
# Log stdout & stderr |
||||
exec > >(tee -i /tmp/gdm3_postlogin.log) |
||||
exec 2>&1 |
||||
|
||||
# Treat unset variables as an error when substituting. |
||||
set -u |
||||
|
||||
# Exit immediately if a command exits with a non-zero status. |
||||
set -e |
||||
|
||||
# Separate tokens on newlines only |
||||
IFS=' |
||||
' |
||||
|
||||
# The value of this parameter is expanded like PS1 and the expanded value is the |
||||
# prompt printed before the command line is echoed when the -x option is set |
||||
# (see The Set Builtin). The first character of the expanded value is replicated |
||||
# multiple times, as necessary, to indicate multiple levels of indirection. |
||||
# \D{%F %T} prints date like this : 2019-12-31 23:59:59 |
||||
PS4='-\D{%F %T} ' |
||||
|
||||
# Print commands and their arguments as they are executed. |
||||
set -x |
||||
|
||||
sleep 0.5 |
||||
|
||||
# Find the first removable F2FS partition |
||||
PART=$(lsblk -o tran,kname,hotplug,type,fstype -pr | |
||||
grep -e '1 part f2fs' -e '1 disk f2fs' | |
||||
cut -d' ' -f2 | |
||||
sort | |
||||
head -n1) |
||||
|
||||
# Make sure the mountpoints are free |
||||
( |
||||
lsof -t $HOME | xargs kill -9 |
||||
umount $HOME |
||||
umount /mnt |
||||
) || true |
||||
|
||||
if test "$PART" |
||||
then |
||||
mount -o noatime "$PART" /mnt |
||||
else |
||||
# No removable F2FS partition found, use the third local partition instead |
||||
PART=$(lsblk -o tran,kname,hotplug,type,fstype -pr | |
||||
grep -v usb | |
||||
grep '0 part' | |
||||
cut -d' ' -f2 | |
||||
sort | |
||||
head -n3 | |
||||
tail -n1) |
||||
|
||||
if test -z "$PART" |
||||
then |
||||
# No local partition found, error |
||||
exit 1 |
||||
fi |
||||
|
||||
# We don't care about data consistency since the partition is temporary |
||||
/sbin/mke2fs -t ext4 -O ^has_journal -F "$PART" |
||||
mount -o noatime,nobarrier "$PART" /mnt |
||||
fi |
||||
|
||||
USER_PATH=/mnt/.01/$USER |
||||
TEMP_PATH=/mnt/.01/tmp |
||||
|
||||
mkdir -p $USER_PATH $TEMP_PATH |
||||
chown -R $USER:$USER $USER_PATH $TEMP_PATH |
||||
mount -t overlay -o lowerdir=$HOME,upperdir=$USER_PATH,workdir=$TEMP_PATH overlay $HOME |
@ -0,0 +1,25 @@
|
||||
#!/bin/bash |
||||
|
||||
# Log stdout & stderr |
||||
exec > >(tee -i /tmp/gdm3_postsession.log) |
||||
exec 2>&1 |
||||
|
||||
# Exit immediately if a command exits with a non-zero status. |
||||
set -e |
||||
|
||||
# The value of this parameter is expanded like PS1 and the expanded value is the |
||||
# prompt printed before the command line is echoed when the -x option is set |
||||
# (see The Set Builtin). The first character of the expanded value is replicated |
||||
# multiple times, as necessary, to indicate multiple levels of indirection. |
||||
# \D{%F %T} prints date like this : 2019-12-31 23:59:59 |
||||
PS4='-\D{%F %T} ' |
||||
|
||||
# Print commands and their arguments as they are executed. |
||||
set -x |
||||
|
||||
passwd -d $USER |
||||
sync |
||||
sleep 0.5 |
||||
lsof -t $HOME | xargs kill || true |
||||
umount -l $HOME |
||||
umount -l /mnt |
@ -0,0 +1 @@
|
||||
KERNEL=="::DISK::*", ENV{UDISKS_IGNORE}="1" |
@ -0,0 +1,8 @@
|
||||
[Desktop Entry] |
||||
Name=Lock Screen |
||||
Comment=Sets a password if needed and then lock screen |
||||
Exec=/usr/local/bin/lock_screen |
||||
Icon=system-lock-screen |
||||
Terminal=false |
||||
Type=Application |
||||
StartupNotify=true |
@ -0,0 +1,8 @@
|
||||
[Desktop Entry] |
||||
Name=Suspend session |
||||
Comment=Sets a password if needed and then suspend session |
||||
Exec=/usr/local/bin/suspend_session |
||||
Icon=media-playback-pause |
||||
Terminal=false |
||||
Type=Application |
||||
StartupNotify=true |
@ -0,0 +1,22 @@
|
||||
#!/bin/sh |
||||
|
||||
set -e |
||||
|
||||
PREREQ="" |
||||
|
||||
prereqs () { |
||||
echo "${PREREQ}" |
||||
} |
||||
|
||||
case "${1}" in |
||||
prereqs) |
||||
prereqs |
||||
exit 0 |
||||
;; |
||||
esac |
||||
|
||||
. /usr/share/initramfs-tools/hook-functions |
||||
|
||||
copy_exec /sbin/mke2fs /bin |
||||
|
||||
exit 0 |
@ -0,0 +1,20 @@
|
||||
#!/bin/sh |
||||
|
||||
PREREQ="" |
||||
prereqs() |
||||
{ |
||||
echo "$PREREQ" |
||||
} |
||||
|
||||
case $1 in |
||||
prereqs) |
||||
prereqs |
||||
exit 0 |
||||
;; |
||||
esac |
||||
|
||||
. /scripts/functions |
||||
|
||||
/bin/mke2fs -F -t ext4 -O ^has_journal ::PART:: > /dev/null 2>&1 |
||||
|
||||
exit 0 |
@ -0,0 +1,118 @@
|
||||
#!/bin/bash |
||||
|
||||
# Configure ubuntu desktop systems |
||||
|
||||
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" |
||||
cd "$SCRIPT_DIR" |
||||
. set.sh |
||||
|
||||
# Install dependencies |
||||
apt-get -y install lz4 |
||||
|
||||
# Change ext4 default mount options |
||||
sed -i -e 's/ errors=remount-ro/ noatime,nodelalloc,errors=remount-ro/g' /etc/fstab |
||||
|
||||
# Disable GTK hidden scroll bars |
||||
echo GTK_OVERLAY_SCROLLING=0 >> /etc/environment |
||||
|
||||
# Reveal boot messages |
||||
sed -i -e 's/TTYVTDisallocate=yes/TTYVTDisallocate=no/g' /etc/systemd/system/getty.target.wants/getty@tty1.service |
||||
|
||||
# Speedup boot |
||||
sed -i 's/MODULES=most/MODULES=dep/g' /etc/initramfs-tools/initramfs.conf |
||||
sed -i 's/COMPRESS=gzip/COMPRESS=lz4/g' /etc/initramfs-tools/initramfs.conf |
||||
|
||||
# Reveal autostart services |
||||
sed -i 's/NoDisplay=true/NoDisplay=false/g' /etc/xdg/autostart/*.desktop |
||||
|
||||
# Remove password complexity constraints |
||||
sed -i 's/ obscure / minlen=1 /g' /etc/pam.d/common-password |
||||
|
||||
# Remove splash screen (plymouth) and hide kernel output |
||||
sed -i 's/quiet splash/quiet vt.global_cursor_default=0 console=ttyS0/g' /etc/default/grub |
||||
|
||||
update-initramfs -u |
||||
update-grub |
||||
|
||||
# Disable swapfile |
||||
swapoff /swapfile || true |
||||
rm -f /swapfile |
||||
sed -i '/swapfile/d' /etc/fstab |
||||
|
||||
# Prevent gnome-shell segfault from happening |
||||
sed -i 's/#WaylandEnable=false/WaylandEnable=false/g' /etc/gdm3/custom.conf |
||||
|
||||
# Purge unused Ubuntu packages |
||||
PKGS=" |
||||
apport |
||||
bind9 |
||||
bolt |
||||
cups* |
||||
exim* |
||||
fprintd |
||||
friendly-recovery |
||||
gnome-initial-setup |
||||
gnome-online-accounts |
||||
gnome-power-manager |
||||
gnome-software |
||||
gnome-software-common |
||||
memtest86+ |
||||
orca |
||||
popularity-contest |
||||
python3-update-manager |
||||
secureboot-db |
||||
snapd |
||||
spice-vdagent |
||||
ubuntu-report |
||||
ubuntu-software |
||||
unattended-upgrades |
||||
update-inetd |
||||
update-manager-core |
||||
update-notifier |
||||
update-notifier-common |
||||
whoopsie |
||||
xdg-desktop-portal |
||||
" |
||||
|
||||
apt-get -y purge $PKGS |
||||
apt-get -y autoremove --purge |
||||
|
||||
SERVICES=" |
||||
apt-daily-upgrade.timer |
||||
apt-daily.timer |
||||
console-setup.service |
||||
keyboard-setup.service |
||||
motd-news.timer |
||||
remote-fs.target |
||||
" |
||||
systemctl disable $SERVICES |
||||
|
||||
SERVICES=" |
||||
grub-common.service |
||||
NetworkManager-wait-online.service |
||||
plymouth-quit-wait.service |
||||
" |
||||
systemctl mask $SERVICES |
||||
|
||||
# Install packages |
||||
PKGS="$(cat common_packages.txt) |
||||
baobab |
||||
blender |
||||
chromium-browser |
||||
dconf-editor |
||||
firefox |
||||
gimp |
||||
gnome-calculator |
||||
gnome-system-monitor |
||||
gnome-tweaks |
||||
i3lock |
||||
mpv |
||||
zenity |
||||
" |
||||
|
||||
# Replace debian packages with ubuntu's |
||||
PKGS=${PKGS/linux-image-amd64/linux-image-generic} |
||||
PKGS=${PKGS/linux-headers-amd64/linux-headers-generic} |
||||
PKGS=${PKGS/firmware-linux-nonfree} |
||||
|
||||
apt-get -y install $PKGS |
@ -0,0 +1,35 @@
|
||||
#!/bin/bash |
||||
|
||||
# Install VSCode |
||||
|
||||
SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" |
||||
cd $SCRIPT_DIR |
||||
. set.sh |
||||
|
||||
wget -qO - https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg | apt-key add - |
||||
echo 'deb https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/repos/debs/ vscodium main' > /etc/apt/sources.list.d/vscodium.list |
||||
apt-get update && apt-get -y install vscodium |
||||
|
||||
# Set-up all users |
||||
for DIR in $(ls -1d /home/* 2>/dev/null || true) |
||||
do |
||||
# Disable most of the telemetry and auto-updates |
||||
mkdir -p $DIR/.config/VSCodium/User |
||||
cat <<-'EOF'> $DIR/.config/VSCodium/User/settings.json |
||||
{ |
||||
"telemetry.enableCrashReporter": false, |
||||
"update.enableWindowsBackgroundUpdates": false, |
||||
"update.mode": "none", |
||||
"update.showReleaseNotes": false, |
||||
"extensions.autoCheckUpdates": false, |
||||
"extensions.autoUpdate": false, |
||||
"workbench.enableExperiments": false, |
||||
"workbench.settings.enableNaturalLanguageSearch": false, |
||||
"npm.fetchOnlinePackageInfo": false |
||||
} |
||||
EOF |
||||
|
||||
# Fix rights |
||||
USR=$(echo "$DIR" | rev | cut -d/ -f1 | rev) |
||||
chown -R $USR:$USR $DIR || true |
||||
done |
@ -0,0 +1,37 @@
|
||||
## brainfuck |
||||
|
||||
### Instructions |
||||
|
||||
Write a Brainfuck interpreter program. |
||||
The source code will be given as first parameter. |
||||
The code will always be valid, with no more than 4096 operations. |
||||
Brainfuck is a minimalist language. It consists of an array of bytes |
||||
(in our case, let's say 2048 bytes) initialized to zero, |
||||
and a pointer to its first byte. |
||||
|
||||
Every operator consists of a single character : |
||||
|
||||
- '>' increment the pointer ; |
||||
- '<' decrement the pointer ; |
||||
- '+' increment the pointed byte ; |
||||
- '-' decrement the pointed byte ; |
||||
- '.' print the pointed byte on standard output ; |
||||
- '[' go to the matching ']' if the pointed byte is 0 (while start) ; |
||||
- ']' go to the matching '[' if the pointed byte is not 0 (while end). |
||||
|
||||
Any other character is a comment. |
||||
|
||||
Examples of outputs : |
||||
|
||||
```console |
||||
student@ubuntu:~/student/brainfuck$ go build |
||||
student@ubuntu:~/student/brainfuck$ ./brainfuck "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>." | cat -e |
||||
Hello World!$ |
||||
student@ubuntu:~/student/brainfuck$ ./brainfuck "+++++[>++++[>++++H>+++++i<<-]>>>++\n<<<<-]>>--------.>+++++.>." | cat -e |
||||
Hi$ |
||||
student@ubuntu:~/student/brainfuck$ ./brainfuck "++++++++++[>++++++++++>++++++++++>++++++++++<<<-]>---.>--.>-.>++++++++++." | cat -e |
||||
abc$ |
||||
student@ubuntu:~/student/brainfuck$ ./brainfuck | cat -e |
||||
$ |
||||
student@ubuntu:~/student/brainfuck$ |
||||
``` |
@ -1,28 +0,0 @@
|
||||
## doop |
||||
|
||||
### Instructions |
||||
|
||||
Write a program that takes three strings: |
||||
|
||||
- The first and the third one are representations of base-10 signed integers that fit in an int. |
||||
|
||||
- The second one is an arithmetic operator chosen from: `+ - * / %` |
||||
|
||||
- The program must display the result of the requested arithmetic operation, followed by a newline. If the number of parameters is not 3, the program just displays a newline. |
||||
|
||||
- You can assume the string have no mistakes or extraneous characters. Negative numbers, in input or output, will have one and only one leading `-`. The result of the operation fits in an int. |
||||
|
||||
Example of output : |
||||
|
||||
```console |
||||
student@ubuntu:~/piscine/test$ go build |
||||
student@ubuntu:~/piscine/test$ ./test "123" "*" 456 |
||||
56088 |
||||
student@ubuntu:~/piscine/test$ ./test "9828" "/" 234 |
||||
42 |
||||
student@ubuntu:~/piscine/test$ ./test "10" "+" "-43" |
||||
33 |
||||
student@ubuntu:~/piscine/test$ ./test |
||||
|
||||
student@ubuntu:~/piscine/test$ |
||||
``` |
@ -0,0 +1,28 @@
|
||||
## expandstr |
||||
|
||||
### Instructions |
||||
|
||||
Write a program that takes a string and displays it with exactly three spaces |
||||
between each word, with no spaces or tabs at either the beginning nor the end. |
||||
|
||||
The string will be followed by a newline. |
||||
|
||||
A word is a sequence of alphanumerical characters. |
||||
|
||||
If the number of parameters is not 1, or if there are no words, the program displays |
||||
a newline. |
||||
|
||||
Examples of outputs : |
||||
|
||||
```console |
||||
student@ubuntu:~/student/expandstr$ go build |
||||
student@ubuntu:~/student/expandstr$ ./expandstr "you see it's easy to display the same thing" | cat -e |
||||
you see it's easy to display the same thing$ |
||||
student@ubuntu:~/student/expandstr$ ./expandstr " only it's harder " | cat -e |
||||
only it's harder$ |
||||
student@ubuntu:~/student/expandstr$ ./expandstr " how funny it is" "did you hear, Mathilde ?" | cat -e |
||||
$ |
||||
student@ubuntu:~/student/expandstr$ ./expandstr | cat -e |
||||
$ |
||||
student@ubuntu:~/student/expandstr$ |
||||
``` |
@ -0,0 +1,28 @@
|
||||
## hiddenp |
||||
|
||||
### Instructions |
||||
|
||||
Write a program named hiddenp that takes two strings and that, if the first string is hidden in the second one, displays 1 |
||||
followed by a newline, otherwise it displays 0 followed by a newline. |
||||
|
||||
Let s1 and s2 be strings. It is considered that s1 is hidden in s2 if it is possible to |
||||
find each character from s1 in s2, **in the same order as they appear in s1.** |
||||
|
||||
If s1 is an empty string it is considered hidden in any string. |
||||
|
||||
If the number of parameters is not 2, the program displays a newline. |
||||
|
||||
Example of output : |
||||
|
||||
```console |
||||
student@ubuntu:~/student/hiddenp$ go build |
||||
student@ubuntu:~/student/hiddenp$ ./hiddenp "fgex.;" "tyf34gdgf;'ektufjhgdgex.;.;rtjynur6" | cat -e |
||||
1$ |
||||
student@ubuntu:~/student/hiddenp$ ./hiddenp "abc" "2altrb53c.sse" | cat -e |
||||
1$ |
||||
student@ubuntu:~/student/hiddenp$ ./hiddenp "abc" "btarc" | cat -e |
||||
0$ |
||||
student@ubuntu:~/student/hiddenp$ ./hiddenp | cat -e |
||||
$ |
||||
student@ubuntu:~/student/hiddenp$ |
||||
``` |
@ -0,0 +1,15 @@
|
||||
## itoa |
||||
|
||||
### Instructions |
||||
|
||||
- Write a function that simulates the behaviour of the `Itoa` function in Go. `Itoa` transforms a number represented as an`int` in a number represented as a `string`. |
||||
|
||||
- For this exercise the handling of the signs + or - **does have** to be taken into account. |
||||
|
||||
## Expected function |
||||
|
||||
```go |
||||
func Itoa(n int) string { |
||||
|
||||
} |
||||
``` |
@ -0,0 +1,24 @@
|
||||
## itoabase |
||||
|
||||
### Instructions |
||||
|
||||
Write a function that: |
||||
|
||||
- converts an integer value to a string using the specified base in the argument |
||||
- and then returns this string |
||||
|
||||
The base is expressed as an integer, from 2 to 16. The characters comprising |
||||
the base are the digits from 0 to 9, followed by uppercase letters from A to F. |
||||
|
||||
For example, the base `4` would be the equivalent of "0123" and the base `16` would be the equivalent of "0123456789ABCDEF". |
||||
|
||||
If the value is negative, the resulting string has to be preceded with a |
||||
minus sign `-`. |
||||
|
||||
### Expected function |
||||
|
||||
```go |
||||
func ItoaBase(value, base int) string { |
||||
|
||||
} |
||||
``` |
@ -0,0 +1,21 @@
|
||||
## paramcount |
||||
|
||||
### Instructions |
||||
|
||||
Write a program that displays the number of arguments passed to it. This number will be followed by |
||||
a newline. |
||||
|
||||
If there are no arguments, just display a 0 followed by a newline. |
||||
|
||||
Examples of outputs : |
||||
|
||||
```console |
||||
student@ubuntu:~/student/paramcount$ go build |
||||
student@ubuntu:~/student/paramcount$ ./paramcount 1 2 3 5 7 24 |
||||
6 |
||||
student@ubuntu:~/student/paramcount$ ./paramcount 6 12 24 | cat -e |
||||
3$ |
||||
student@ubuntu:~/student/paramcount$ ./paramcount | cat -e |
||||
0$ |
||||
student@ubuntu:~/student/paramcount$ |
||||
``` |
@ -0,0 +1,24 @@
|
||||
## range |
||||
|
||||
### Instructions |
||||
|
||||
Write the function Range which must: |
||||
|
||||
- allocate (with make()) an array of integers. |
||||
- fill it with consecutive values that begin at `start` and end at `end` (Including `start` and `end` !) |
||||
- finally return that array. |
||||
|
||||
### Expected function |
||||
|
||||
```go |
||||
func Range(start, end int) []int { |
||||
|
||||
} |
||||
``` |
||||
|
||||
Examples of outputs : |
||||
|
||||
- With (1, 3) you will return an array containing 1, 2 and 3. |
||||
- With (-1, 2) you will return an array containing -1, 0, 1 and 2. |
||||
- With (0, 0) you will return an array containing 0. |
||||
- With (0, -3) you will return an array containing 0, -1, -2 and -3. |
@ -1,20 +0,0 @@
|
||||
## range |
||||
|
||||
### Instructions |
||||
|
||||
Write the following functions : |
||||
|
||||
```go |
||||
func Range(start, end int) []int{ |
||||
|
||||
} |
||||
``` |
||||
|
||||
It must allocate (with malloc()) an array of integers, fill it with consecutive values that begin at start and end at end (Including start and end !), then return a pointer to the first value of the array. |
||||
|
||||
Example of output : |
||||
|
||||
- With (1, 3) you will return an array containing 1, 2 and 3. |
||||
- With (-1, 2) you will return an array containing -1, 0, 1 and 2. |
||||
- With (0, 0) you will return an array containing 0. |
||||
- With (0, -3) you will return an array containing 0, -1, -2 and -3. |
@ -0,0 +1,24 @@
|
||||
## reverserange |
||||
|
||||
### Instructions |
||||
|
||||
Write the function ReverseRange which must: |
||||
|
||||
- allocate (with make()) an array of integers. |
||||
- fill it with consecutive values that begin at `end` and end at `start` (Including `start` and `end` !) |
||||
- finally return that array. |
||||
|
||||
### Expected function |
||||
|
||||
```go |
||||
func ReverseRange(start, end int) []int { |
||||
|
||||
} |
||||
``` |
||||
|
||||
Examples of output : |
||||
|
||||
- With (1, 3) the function will return an array containing 3, 2 and 1. |
||||
- With (-1, 2) the function will return an array containing 2, 1, 0 and -1. |
||||
- With (0, 0) the function will return an array containing 0. |
||||
- With (0, -3) the function will return an array containing -3, -2, -1 and 0. |
@ -0,0 +1,27 @@
|
||||
## reversestrcap |
||||
|
||||
### Instructions |
||||
|
||||
Write a program that takes one or more strings and that, **for each argument**: |
||||
-puts the last character of each word (if it is a letter) in uppercase and the rest |
||||
in lowercase |
||||
-then it displays the result followed by a `\n`. |
||||
|
||||
A word is a sequence of alphanumerical characters. |
||||
|
||||
If there are no parameters, the program displays a `\n`. |
||||
|
||||
Examples of outputs : |
||||
|
||||
```console |
||||
student@ubuntu:~/student/reversestrcap$ go build |
||||
student@ubuntu:~/student/reversestrcap$ ./reversestrcap "First SMALL TesT" | cat -e |
||||
firsT smalL tesT$ |
||||
student@ubuntu:~/student/reversestrcap$ ./reversestrcap go run reversestrcap.go "SEconD Test IS a LItTLE EasIEr" "bEwaRe IT'S NoT HARd WhEN " " Go a dernier 0123456789 for the road e" | cat -e |
||||
seconD tesT iS A littlE easieR$ |
||||
bewarE it'S noT harD wheN $ |
||||
gO A dernieR 0123456789 foR thE roaD E$ |
||||
student@ubuntu:~/student/reversestrcap$ ./reversestrcap | cat -e |
||||
$ |
||||
student@ubuntu:~/student/reversestrcap$ |
||||
``` |
Loading…
Reference in new issue