Ubuntu Pastebin

Paste from ogra at Mon, 15 Aug 2016 09:09:47 +0000

Download as text
 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
#!/bin/sh

set -eu

ROOT=$SNAP_COMMON/classic

if [ -d $ROOT ]; then
    echo "classic already enabled"
    exit 1
fi

if [ $(id -u) -ne 0 ]; then
    echo "This script needs to be called as root" >&2
    exit 1
fi

# prepare dir and copy stuff in place
#mkdir $ROOT
#mkdir $ROOT/snappy

# FIXME: confinement will prevent this
# FIXME2: show progress(?)
echo "Creating classic environment"
version="$(/bin/readlink /snap/ubuntu-core/current)"
/usr/bin/unsquashfs -d $ROOT /var/lib/snapd/snaps/ubuntu-core_${version}.snap
mkdir $ROOT/snappy
#cp -ar /snap/ubuntu-core/current/* $ROOT

# enable
sudo chroot $ROOT /var/lib/classic/enable.sh

# copy important config
for f in hostname timezone localtime; do
    cp -a /etc/writable/$f $ROOT/etc/writable
done
for f in hosts; do
    cp -a /etc/$f $ROOT/etc/
done


# don't start services in the chroot on apt-get install
cat <<EOF > "$ROOT/usr/sbin/policy-rc.d"
#!/bin/sh
while true; do
    case "\$1" in
      -*) shift ;;
      makedev) exit 0;;
      x11-common) exit 0;;
      *) exit 101;;
    esac
done
EOF
chmod 755 "$ROOT/usr/sbin/policy-rc.d"

# workaround bug in livecd-rootfs
chmod 1777 "$ROOT/tmp"
Download as text