-
-
Save choonkeat/a398244e3ce406ad1ee27448f383c7aa to your computer and use it in GitHub Desktop.
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
package main | |
import ( | |
"log" | |
"net/http" | |
"os" | |
"os/exec" | |
) | |
func main() { | |
if ret, err := exec.Command("ps", "-ef").CombinedOutput(); err != nil { | |
log.Printf(err.Error()) | |
} else { | |
log.Printf("[ps]%s[/ps]", ret) | |
} | |
if ret, err := exec.Command("df").CombinedOutput(); err != nil { | |
log.Printf(err.Error()) | |
} else { | |
log.Printf("[df]%s[/df]", ret) | |
} | |
if ret, err := exec.Command("ls", "/snap/").CombinedOutput(); err != nil { | |
log.Printf(err.Error()) | |
} else { | |
log.Printf("[ls]%s[/ls]", ret) | |
} | |
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
log.Println("inside", r.RequestURI) | |
w.Write([]byte(`Hello!!!! ` + r.RequestURI + "\n")) | |
}) | |
log.Println("Listening to :" + os.Getenv("PORT")) | |
log.Fatalln(http.ListenAndServe(":"+os.Getenv("PORT"), nil)) | |
} |
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
ubuntu@ubuntu-xenial:~/chucknorris$ snapcraft clean ; snapcraft ; sudo snap try prime --jailmode | |
Cleaning up priming area | |
Cleaning up staging area | |
Cleaning up parts directory | |
Preparing to pull bin-part | |
Pulling bin-part | |
Preparing to build bin-part | |
Building bin-part | |
Staging bin-part | |
Priming bin-part | |
Snapping 'chuck-norris-webserver' - | |
Snapped chuck-norris-webserver_0.1_amd64.snap | |
chuck-norris-webserver 0.1 mounted from /home/ubuntu/chucknorris/prime | |
ubuntu@ubuntu-xenial:~/chucknorris$ fg | |
-bash: fg: current: no such job | |
ubuntu@ubuntu-xenial:~/chucknorris$ chuck-norris-webserver.my-app123 & | |
[1] 5065 | |
ubuntu@ubuntu-xenial:~/chucknorris$ 2017/05/19 08:39:49 [ps]UID PID PPID C STIME TTY TIME CMD | |
root 1 0 0 05:05 ? 00:00:18 [systemd] | |
root 2 0 0 05:05 ? 00:00:00 [kthreadd] | |
root 3 2 0 05:05 ? 00:00:00 [ksoftirqd/0] | |
root 5 2 0 05:05 ? 00:00:00 [kworker/0:0H] | |
root 7 2 0 05:05 ? 00:00:00 [rcu_sched] | |
root 8 2 0 05:05 ? 00:00:00 [rcu_bh] | |
root 9 2 0 05:05 ? 00:00:00 [migration/0] | |
root 10 2 0 05:05 ? 00:00:00 [watchdog/0] | |
root 11 2 0 05:05 ? 00:00:00 [watchdog/1] | |
root 12 2 0 05:05 ? 00:00:00 [migration/1] | |
root 13 2 0 05:05 ? 00:00:00 [ksoftirqd/1] | |
root 15 2 0 05:05 ? 00:00:00 [kworker/1:0H] | |
root 16 2 0 05:05 ? 00:00:00 [kdevtmpfs] | |
root 17 2 0 05:05 ? 00:00:00 [netns] | |
root 18 2 0 05:05 ? 00:00:00 [perf] | |
root 19 2 0 05:05 ? 00:00:00 [khungtaskd] | |
root 20 2 0 05:05 ? 00:00:00 [writeback] | |
root 21 2 0 05:05 ? 00:00:00 [ksmd] | |
root 22 2 0 05:05 ? 00:00:00 [khugepaged] | |
root 23 2 0 05:05 ? 00:00:00 [crypto] | |
root 24 2 0 05:05 ? 00:00:00 [kintegrityd] | |
root 25 2 0 05:05 ? 00:00:00 [bioset] | |
root 26 2 0 05:05 ? 00:00:00 [kblockd] | |
root 27 2 0 05:05 ? 00:00:00 [ata_sff] | |
root 28 2 0 05:05 ? 00:00:00 [md] | |
root 29 2 0 05:05 ? 00:00:00 [devfreq_wq] | |
root 34 2 0 05:05 ? 00:00:00 [kswapd0] | |
root 35 2 0 05:05 ? 00:00:00 [vmstat] | |
root 36 2 0 05:05 ? 00:00:00 [fsnotify_mark] | |
root 37 2 0 05:05 ? 00:00:00 [ecryptfs-kthrea] | |
root 53 2 0 05:05 ? 00:00:00 [kthrotld] | |
root 54 2 0 05:05 ? 00:00:00 [acpi_thermal_pm] | |
root 55 2 0 05:05 ? 00:00:00 [bioset] | |
root 56 2 0 05:05 ? 00:00:00 [bioset] | |
root 57 2 0 05:05 ? 00:00:00 [bioset] | |
root 58 2 0 05:05 ? 00:00:00 [bioset] | |
root 59 2 0 05:05 ? 00:00:00 [bioset] | |
root 60 2 0 05:05 ? 00:00:00 [bioset] | |
root 61 2 0 05:05 ? 00:00:00 [bioset] | |
root 62 2 0 05:05 ? 00:00:00 [bioset] | |
root 63 2 0 05:05 ? 00:00:00 [bioset] | |
root 64 2 0 05:05 ? 00:00:00 [bioset] | |
root 65 2 0 05:05 ? 00:00:00 [bioset] | |
root 66 2 0 05:05 ? 00:00:00 [bioset] | |
root 67 2 0 05:05 ? 00:00:00 [bioset] | |
root 68 2 0 05:05 ? 00:00:00 [bioset] | |
root 69 2 0 05:05 ? 00:00:00 [bioset] | |
root 70 2 0 05:05 ? 00:00:00 [bioset] | |
root 71 2 0 05:05 ? 00:00:00 [bioset] | |
root 72 2 0 05:05 ? 00:00:00 [bioset] | |
root 73 2 0 05:05 ? 00:00:00 [bioset] | |
root 74 2 0 05:05 ? 00:00:00 [bioset] | |
root 75 2 0 05:05 ? 00:00:00 [bioset] | |
root 76 2 0 05:05 ? 00:00:00 [bioset] | |
root 77 2 0 05:05 ? 00:00:00 [bioset] | |
root 78 2 0 05:05 ? 00:00:00 [bioset] | |
root 79 2 0 05:05 ? 00:00:00 [scsi_eh_0] | |
root 80 2 0 05:05 ? 00:00:00 [scsi_tmf_0] | |
root 81 2 0 05:05 ? 00:00:00 [scsi_eh_1] | |
root 82 2 0 05:05 ? 00:00:00 [scsi_tmf_1] | |
root 87 2 0 05:05 ? 00:00:00 [ipv6_addrconf] | |
root 100 2 0 05:05 ? 00:00:00 [deferwq] | |
root 101 2 0 05:05 ? 00:00:00 [charger_manager] | |
root 148 2 0 05:05 ? 00:00:00 [kpsmoused] | |
root 190 2 0 05:05 ? 00:00:00 [mpt_poll_0] | |
root 191 2 0 05:05 ? 00:00:00 [mpt/0] | |
root 192 2 0 05:05 ? 00:00:00 [scsi_eh_2] | |
root 193 2 0 05:05 ? 00:00:00 [scsi_tmf_2] | |
root 194 2 0 05:05 ? 00:00:00 [bioset] | |
root 195 2 0 05:06 ? 00:00:00 [bioset] | |
root 289 2 0 05:06 ? 00:00:00 [kworker/0:1H] | |
root 294 2 0 05:06 ? 00:00:00 [raid5wq] | |
root 326 2 0 05:06 ? 00:00:00 [bioset] | |
root 346 2 0 05:06 ? 00:00:00 [jbd2/sda1-8] | |
root 347 2 0 05:06 ? 00:00:00 [ext4-rsv-conver] | |
root 348 2 0 05:06 ? 00:00:00 [kworker/1:1H] | |
root 406 2 0 05:06 ? 00:00:00 [iscsi_eh] | |
root 409 2 0 05:06 ? 00:00:00 [ib_addr] | |
root 412 2 0 05:06 ? 00:00:00 [ib_mcast] | |
root 413 2 0 05:06 ? 00:00:00 [ib_nl_sa_wq] | |
root 415 2 0 05:06 ? 00:00:00 [ib_cm] | |
root 416 2 0 05:06 ? 00:00:00 [iw_cm_wq] | |
root 417 2 0 05:06 ? 00:00:00 [rdma_cm] | |
root 423 1 0 05:06 ? 00:00:00 [systemd-journal] | |
root 437 2 0 05:06 ? 00:00:00 [kauditd] | |
root 462 1 0 05:06 ? 00:00:00 [lvmetad] | |
root 490 1 0 05:06 ? 00:00:00 [systemd-udevd] | |
root 530 2 0 05:06 ? 00:00:00 [iprt-VBoxWQueue] | |
root 536 2 0 05:06 ? 00:00:00 [loop0] | |
root 549 2 0 05:06 ? 00:00:00 [loop1] | |
root 1026 1 0 05:06 ? 00:00:00 [dhclient] | |
root 1233 1 0 05:06 ? 00:00:00 [iscsid] | |
root 1234 1 0 05:06 ? 00:00:02 [iscsid] | |
daemon 1238 1 0 05:06 ? 00:00:00 [atd] | |
root 1245 1 0 05:06 ? 00:00:00 [acpid] | |
syslog 1248 1 0 05:06 ? 00:00:00 [rsyslogd] | |
root 1255 1 0 05:06 ? 00:00:00 [accounts-daemon] | |
root 1260 1 0 05:06 ? 00:00:00 [sshd] | |
root 1273 1 0 05:06 ? 00:00:00 [cron] | |
root 1283 1 0 05:06 ? 00:00:00 [systemd-logind] | |
message+ 1289 1 0 05:06 ? 00:00:01 [dbus-daemon] | |
root 1299 1 0 05:06 ? 00:00:01 [lxcfs] | |
root 1315 1 0 05:06 ? 00:00:03 [snapd] | |
root 1356 1 0 05:06 ? 00:00:00 [mdadm] | |
root 1360 1 0 05:06 ? 00:00:00 [polkitd] | |
root 1417 1 0 05:06 ? 00:00:00 [irqbalance] | |
root 1466 1 0 05:06 ttyS0 00:00:00 [agetty] | |
root 1479 1 0 05:06 tty1 00:00:00 [agetty] | |
root 1481 1 0 05:06 ? 00:00:02 [VBoxService] | |
root 2017 1260 0 07:14 ? 00:00:00 [sshd] | |
ubuntu 2019 1 0 07:14 ? 00:00:00 /lib/systemd/systemd --user | |
ubuntu 2022 2019 0 07:14 ? 00:00:00 [(sd-pam)] | |
ubuntu 2117 2017 0 07:14 ? 00:00:01 [sshd] | |
ubuntu 2118 2117 0 07:14 ? 00:00:00 -bash | |
root 2551 2 0 07:23 ? 00:00:00 [kworker/u4:1] | |
root 2740 2 0 07:51 ? 00:00:00 [kworker/1:2] | |
root 3770 2 0 08:04 ? 00:00:00 [kworker/u4:0] | |
root 3778 2 0 08:06 ? 00:00:00 [kworker/0:3] | |
root 4346 2 0 08:14 ? 00:00:00 [kworker/1:0] | |
root 4481 2 0 08:25 ? 00:00:00 [kworker/0:0] | |
root 4544 2 0 08:36 ? 00:00:00 [kworker/u4:2] | |
root 4680 2 0 08:37 ? 00:00:00 [kworker/0:1] | |
root 4858 2 0 08:38 ? 00:00:00 [kworker/1:1] | |
ubuntu 5065 2118 0 08:39 ? 00:00:00 /snap/chuck-norris-webserver/x4/binary-blob | |
ubuntu 5078 5065 0 08:39 ? 00:00:00 ps -ef | |
[/ps] | |
2017/05/19 08:39:49 fork/exec /bin/df: permission denied | |
2017/05/19 08:39:49 exit status 2 | |
2017/05/19 08:39:49 Listening to : | |
ubuntu@ubuntu-xenial:~/chucknorris$ | |
ubuntu@ubuntu-xenial:~/chucknorris$ | |
ubuntu@ubuntu-xenial:~/chucknorris$ | |
ubuntu@ubuntu-xenial:~/chucknorris$ cd ../chucknorris2/ | |
ubuntu@ubuntu-xenial:~/chucknorris2$ snapcraft clean ; snapcraft ; sudo snap try prime --jailmode | |
Cleaning up priming area | |
Cleaning up staging area | |
Cleaning up parts directory | |
Preparing to pull bin-part | |
Pulling bin-part | |
Preparing to build bin-part | |
Building bin-part | |
Staging bin-part | |
Priming bin-part | |
Snapping 'norris-webserver' / | |
Snapped norris-webserver_0.1_amd64.snap | |
norris-webserver 0.1 mounted from /home/ubuntu/chucknorris2/prime | |
ubuntu@ubuntu-xenial:~/chucknorris2$ jobs | |
[1]+ Running chuck-norris-webserver.my-app123 & (wd: ~/chucknorris) | |
ubuntu@ubuntu-xenial:~/chucknorris2$ norris-webserver.my-app123 | |
2017/05/19 08:40:30 [ps]UID PID PPID C STIME TTY TIME CMD | |
root 1 0 0 05:05 ? 00:00:18 [systemd] | |
root 2 0 0 05:05 ? 00:00:00 [kthreadd] | |
root 3 2 0 05:05 ? 00:00:00 [ksoftirqd/0] | |
root 5 2 0 05:05 ? 00:00:00 [kworker/0:0H] | |
root 7 2 0 05:05 ? 00:00:00 [rcu_sched] | |
root 8 2 0 05:05 ? 00:00:00 [rcu_bh] | |
root 9 2 0 05:05 ? 00:00:00 [migration/0] | |
root 10 2 0 05:05 ? 00:00:00 [watchdog/0] | |
root 11 2 0 05:05 ? 00:00:00 [watchdog/1] | |
root 12 2 0 05:05 ? 00:00:00 [migration/1] | |
root 13 2 0 05:05 ? 00:00:00 [ksoftirqd/1] | |
root 15 2 0 05:05 ? 00:00:00 [kworker/1:0H] | |
root 16 2 0 05:05 ? 00:00:00 [kdevtmpfs] | |
root 17 2 0 05:05 ? 00:00:00 [netns] | |
root 18 2 0 05:05 ? 00:00:00 [perf] | |
root 19 2 0 05:05 ? 00:00:00 [khungtaskd] | |
root 20 2 0 05:05 ? 00:00:00 [writeback] | |
root 21 2 0 05:05 ? 00:00:00 [ksmd] | |
root 22 2 0 05:05 ? 00:00:00 [khugepaged] | |
root 23 2 0 05:05 ? 00:00:00 [crypto] | |
root 24 2 0 05:05 ? 00:00:00 [kintegrityd] | |
root 25 2 0 05:05 ? 00:00:00 [bioset] | |
root 26 2 0 05:05 ? 00:00:00 [kblockd] | |
root 27 2 0 05:05 ? 00:00:00 [ata_sff] | |
root 28 2 0 05:05 ? 00:00:00 [md] | |
root 29 2 0 05:05 ? 00:00:00 [devfreq_wq] | |
root 34 2 0 05:05 ? 00:00:00 [kswapd0] | |
root 35 2 0 05:05 ? 00:00:00 [vmstat] | |
root 36 2 0 05:05 ? 00:00:00 [fsnotify_mark] | |
root 37 2 0 05:05 ? 00:00:00 [ecryptfs-kthrea] | |
root 53 2 0 05:05 ? 00:00:00 [kthrotld] | |
root 54 2 0 05:05 ? 00:00:00 [acpi_thermal_pm] | |
root 55 2 0 05:05 ? 00:00:00 [bioset] | |
root 56 2 0 05:05 ? 00:00:00 [bioset] | |
root 57 2 0 05:05 ? 00:00:00 [bioset] | |
root 58 2 0 05:05 ? 00:00:00 [bioset] | |
root 59 2 0 05:05 ? 00:00:00 [bioset] | |
root 60 2 0 05:05 ? 00:00:00 [bioset] | |
root 61 2 0 05:05 ? 00:00:00 [bioset] | |
root 62 2 0 05:05 ? 00:00:00 [bioset] | |
root 63 2 0 05:05 ? 00:00:00 [bioset] | |
root 64 2 0 05:05 ? 00:00:00 [bioset] | |
root 65 2 0 05:05 ? 00:00:00 [bioset] | |
root 66 2 0 05:05 ? 00:00:00 [bioset] | |
root 67 2 0 05:05 ? 00:00:00 [bioset] | |
root 68 2 0 05:05 ? 00:00:00 [bioset] | |
root 69 2 0 05:05 ? 00:00:00 [bioset] | |
root 70 2 0 05:05 ? 00:00:00 [bioset] | |
root 71 2 0 05:05 ? 00:00:00 [bioset] | |
root 72 2 0 05:05 ? 00:00:00 [bioset] | |
root 73 2 0 05:05 ? 00:00:00 [bioset] | |
root 74 2 0 05:05 ? 00:00:00 [bioset] | |
root 75 2 0 05:05 ? 00:00:00 [bioset] | |
root 76 2 0 05:05 ? 00:00:00 [bioset] | |
root 77 2 0 05:05 ? 00:00:00 [bioset] | |
root 78 2 0 05:05 ? 00:00:00 [bioset] | |
root 79 2 0 05:05 ? 00:00:00 [scsi_eh_0] | |
root 80 2 0 05:05 ? 00:00:00 [scsi_tmf_0] | |
root 81 2 0 05:05 ? 00:00:00 [scsi_eh_1] | |
root 82 2 0 05:05 ? 00:00:00 [scsi_tmf_1] | |
root 87 2 0 05:05 ? 00:00:00 [ipv6_addrconf] | |
root 100 2 0 05:05 ? 00:00:00 [deferwq] | |
root 101 2 0 05:05 ? 00:00:00 [charger_manager] | |
root 148 2 0 05:05 ? 00:00:00 [kpsmoused] | |
root 190 2 0 05:05 ? 00:00:00 [mpt_poll_0] | |
root 191 2 0 05:05 ? 00:00:00 [mpt/0] | |
root 192 2 0 05:05 ? 00:00:00 [scsi_eh_2] | |
root 193 2 0 05:05 ? 00:00:00 [scsi_tmf_2] | |
root 194 2 0 05:05 ? 00:00:00 [bioset] | |
root 195 2 0 05:06 ? 00:00:00 [bioset] | |
root 289 2 0 05:06 ? 00:00:00 [kworker/0:1H] | |
root 294 2 0 05:06 ? 00:00:00 [raid5wq] | |
root 326 2 0 05:06 ? 00:00:00 [bioset] | |
root 346 2 0 05:06 ? 00:00:00 [jbd2/sda1-8] | |
root 347 2 0 05:06 ? 00:00:00 [ext4-rsv-conver] | |
root 348 2 0 05:06 ? 00:00:00 [kworker/1:1H] | |
root 406 2 0 05:06 ? 00:00:00 [iscsi_eh] | |
root 409 2 0 05:06 ? 00:00:00 [ib_addr] | |
root 412 2 0 05:06 ? 00:00:00 [ib_mcast] | |
root 413 2 0 05:06 ? 00:00:00 [ib_nl_sa_wq] | |
root 415 2 0 05:06 ? 00:00:00 [ib_cm] | |
root 416 2 0 05:06 ? 00:00:00 [iw_cm_wq] | |
root 417 2 0 05:06 ? 00:00:00 [rdma_cm] | |
root 423 1 0 05:06 ? 00:00:00 [systemd-journal] | |
root 437 2 0 05:06 ? 00:00:00 [kauditd] | |
root 462 1 0 05:06 ? 00:00:00 [lvmetad] | |
root 490 1 0 05:06 ? 00:00:00 [systemd-udevd] | |
root 530 2 0 05:06 ? 00:00:00 [iprt-VBoxWQueue] | |
root 536 2 0 05:06 ? 00:00:00 [loop0] | |
root 549 2 0 05:06 ? 00:00:00 [loop1] | |
root 1026 1 0 05:06 ? 00:00:00 [dhclient] | |
root 1233 1 0 05:06 ? 00:00:00 [iscsid] | |
root 1234 1 0 05:06 ? 00:00:02 [iscsid] | |
daemon 1238 1 0 05:06 ? 00:00:00 [atd] | |
root 1245 1 0 05:06 ? 00:00:00 [acpid] | |
syslog 1248 1 0 05:06 ? 00:00:00 [rsyslogd] | |
root 1255 1 0 05:06 ? 00:00:00 [accounts-daemon] | |
root 1260 1 0 05:06 ? 00:00:00 [sshd] | |
root 1273 1 0 05:06 ? 00:00:00 [cron] | |
root 1283 1 0 05:06 ? 00:00:00 [systemd-logind] | |
message+ 1289 1 0 05:06 ? 00:00:01 [dbus-daemon] | |
root 1299 1 0 05:06 ? 00:00:01 [lxcfs] | |
root 1315 1 0 05:06 ? 00:00:03 [snapd] | |
root 1356 1 0 05:06 ? 00:00:00 [mdadm] | |
root 1360 1 0 05:06 ? 00:00:00 [polkitd] | |
root 1417 1 0 05:06 ? 00:00:00 [irqbalance] | |
root 1466 1 0 05:06 ttyS0 00:00:00 [agetty] | |
root 1479 1 0 05:06 tty1 00:00:00 [agetty] | |
root 1481 1 0 05:06 ? 00:00:02 [VBoxService] | |
root 2017 1260 0 07:14 ? 00:00:00 [sshd] | |
ubuntu 2019 1 0 07:14 ? 00:00:00 /lib/systemd/systemd --user | |
ubuntu 2022 2019 0 07:14 ? 00:00:00 [(sd-pam)] | |
ubuntu 2117 2017 0 07:14 ? 00:00:01 [sshd] | |
ubuntu 2118 2117 0 07:14 ? 00:00:00 -bash | |
root 2551 2 0 07:23 ? 00:00:00 [kworker/u4:1] | |
root 2740 2 0 07:51 ? 00:00:00 [kworker/1:2] | |
root 3770 2 0 08:04 ? 00:00:00 [kworker/u4:0] | |
root 3778 2 0 08:06 ? 00:00:00 [kworker/0:3] | |
root 4346 2 0 08:14 ? 00:00:00 [kworker/1:0] | |
root 4481 2 0 08:25 ? 00:00:00 [kworker/0:0] | |
root 4544 2 0 08:36 ? 00:00:00 [kworker/u4:2] | |
root 4680 2 0 08:37 ? 00:00:00 [kworker/0:1] | |
root 4858 2 0 08:38 ? 00:00:00 [kworker/1:1] | |
ubuntu 5065 2118 0 08:39 ? 00:00:00 /snap/chuck-norris-webserver/x4/binary-blob | |
ubuntu 5178 2118 0 08:40 ? 00:00:00 /snap/norris-webserver/x3/binary-blob | |
ubuntu 5191 5178 0 08:40 ? 00:00:00 ps -ef | |
[/ps] | |
2017/05/19 08:40:30 fork/exec /bin/df: permission denied | |
2017/05/19 08:40:30 exit status 2 | |
2017/05/19 08:40:30 Listening to : | |
^C | |
ubuntu@ubuntu-xenial:~/chucknorris2$ |
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
name: norris-webserver | |
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2' | |
summary: Single-line elevator pitch for your amazing snap # 79 char long summary | |
description: | | |
This is my-snap's description. You have a paragraph or two to tell the | |
most important story about your snap. Keep it under 100 words though, | |
we live in tweetspace and your description wants to look good in the snap | |
store. | |
grade: devel # must be 'stable' to release into candidate/stable channels | |
confinement: strict # use 'strict' once you have the right plugs and slots | |
parts: | |
bin-part: | |
source: . | |
plugin: dump | |
apps: | |
my-app123: | |
command: binary-blob | |
plugs: [network-bind] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment