Showing posts with label planet-ubuntu. Show all posts
Showing posts with label planet-ubuntu. Show all posts

Thursday, October 7, 2021

Installing Ubuntu Core onto 64-bit Bare Metal

I have a re-purposed AMD64 laptop motherboard, ready to become an experimental Ubuntu Core server.

It's in fine condition. You can see that it boots an Ubuntu LiveUSB's "Try Ubuntu" environment just fine. Attached to the motherboard is a new 60GB SSD for testing. The real server will use a 1TB HDD.

But Ubuntu Core doesn't install on bare metal from a Live USB. It's still easy, though.

1. Boot a "Try Ubuntu" Environment on the target system.

  • Test your network connection. The picture shows a wireless connection. This particular laptop has a wireless chip that is recognized out-of-the box, so I didn't need to get out the long network cable.
  • Test that your storage device works. You can see in the picture that Gnome Disks can see the storage device.

2. Terminal: sudo fdisk -l. Locate the storage device that you want to install Ubuntu Core onto.

  • The entire storage device will be erased.
  • My storage device is at /dev/sda today. It might be different next boot. Yours might be different.

3. Open the web browser and download Ubuntu Core.

4. Write Ubuntu Core to the storage device.

  • Warning: This command will erase your entire storage device. If there is anything valuable on your storage device, then you have skipped too many steps!
    xzcat Downloads/<.img.xz file> | sudo dd of=/dev/<target_storage_device> bs=32M status=progress; sync
  • So mine was
    xzcat Downloads/ubuntu-core-20-amd64.img.xz | sudo dd of=/dev/sda bs=32M status=progress; sync
  • Source: https://ubuntu.com/download/intel-nuc

5. Reboot into Ubuntu Core.

  • When prompted by the "Try Ubuntu" environment, remove the LiveUSB so you are booting from your newly-written storage device.
  • Be patient. My first boot into Ubuntu Core led to a black screen for nearly a minute before the system acknowledged that it actually has been working the entire time.
  • After 3-4 minutes of non-interactive setup alternating between blank screens and scrolling setup output, Ubuntu Core finally asked me two questions:  Which network to connect to, and my Ubuntu SSO e-mail address.
  • Finally, the system rebooted again. This time it didn't ask any question - just displayed the new Ubuntu Core system's IP address.

6. Log into Ubuntu Core.

    On my Desktop:
    me@Desktop:~$ ssh me@192.168.1.x
    Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-77-generic x86_64)
Success: A working Ubuntu Core on bare metal.

Sunday, December 20, 2015

Are you ready for new members?

In a few days, many Ubuntu users will unwrap new hardware, plug it in, and have a fantastic experience.

Some users will get inspired to join the community to solve bugs, add features, contribute code, and much more.


Support Gurus: use Find-a-Task

New, enthusiastic users often show up in the many Ubuntu help forums.

Encourage them to try Find-a-Task to see the variety of ways they can help.
Just send them over, and we'll do the rest.


Team Leaders: Is your team ready?

Is your team ready to welcome, train, and integrate these new volunteers?

Has your team looked at it's Find-a-Task roles for volunteers? It's easy to add or change your team's listings.

Is your team approachable? Can you be contacted easily by a new volunteer? Is your web page for new volunteers accurate?


Improving Find-a-Task

Find-a-Task is the Ubuntu community's job board for volunteers. Introduced in January 2015, Find-a-Task shows fellow volunteers the variety of tasks and roles available, and links those roles to the team web pages.

Please share your suggestions to improve Find-a-Task to the Ubuntu Community Team mailing list.

Wednesday, November 4, 2015

UOS Overflow Session: FInd-a-Task

The Ubuntu Online Summit has added an overflow session on Find-a-Task, the Ubuntu community's volunteer job board. The job board tries to link volunteers with a wide range of jobs that need to be done.

  • Does it work?
  • Have you tried it?
  • Do you know anyone who has joined a team after using it?
  • Is your team listed on it?
  • How can it be improved?
  • Is it the best gateway for undecided new volunteers?

Join us tomorrow, 05 Nov at 1800 UTC to discuss the future of Find-a-Task, and the best ways to recruit new Ubuntu Members.

Watch Live at http://summit.ubuntu.com/uos-1511/meeting/22644/growing-new-community-members/
Or join us on freenode IRC:  #ubuntu-uos-overflow

See you there!

Saturday, October 31, 2015

Is your team ready for UOS?

The Ubuntu Online Summit (UOS), 03-05 November 2015, is only a few days away.

Is your team ready to welcome, train, and integrate new volunteers inspired by UOS?

Has your team updated it's Find-a-Task roles for volunteers? It's easy to add or change your team's listings.

Find-a-Task is the Ubuntu community's job board for volunteers. Introduced in January 2015, Find-a-Task shows fellow volunteers the variety of tasks and roles available.


It's for everyone, new and old

UOS is one of the events that energizes the Ubuntu community. It is a great time for volunteers to change tracks, to try something new.

Your Find-a-Task roles should reflect that. Don't limit yourself to new enthusiasts. Your roles should welcome experienced members, too!


Improving Find-a-Task

Please share your suggestions to improve Find-a-Task during any of the UOS Community Roundtable sessions.
See you there!

Saturday, October 10, 2015

Point New Participants to Find-a-Task!

Find-a-Task is the Ubuntu community's job board for volunteers.

Introduced in January 2015, Find-a-Task shows fellow volunteers the variety of tasks and roles available.


Are you using Find-a-Task?

Volunteers can browse the many ways to contribute to Ubuntu, and choose their favorite. No hassle, no pressure, no sign-up, no commitment.

New enthusiasts don't know about Find-a-Task. (How could they?)
It only works if *you* encourage new volunteers to try it.


It's for new participants

Take a quick look, and see the variety of volunteer roles available. We have listings for many different skills and interests, including plenty of non-technical tasks.


It's also for longtime participants

Life moves on. Jobs and family and hobbies change.

Losing interest in your current role, or have less time for it? Renew the magic - use Find-a-Task to try something new and different!

Real friends don't let their mates burn out or drop off.  When you see a friend start to teeter or flame out, guide them to Find-a-Task and help them recover with a different role.


Adding Listings and Improving Find-a-Task

It's easy to add or change your team's listing.

Please share your suggestions to improve Find-a-Task on the ubuntu-community-team mailing list.

Thursday, September 3, 2015

The best DebConf 15 videos

I simply cannot take time off work to attend DebConf, so each year I watch the videos instead. It took almost a month, thanks to the back-to-school rush at work, but I finally got through the sessions I wanted to see.

Here are my highlights from DebConf 15:

Cool Stuff


Creating A More Inviting Environment For Newcomers New Experiences From MoM SoB Teammetrics - A detailed discussion of how a mature team with tapering contributions re-energized itself with new enthusiasts. How they were recruited, mentored, trained, and finally assigned key roles in the team. Lots of discussion of mentoring strategies and the costs of mentoring (less time for the work) from the developer/maintainer perspective. Lots of good ideas for any mature team, and thoroughly applicable to Ubuntu teams too.

Linux in the City of Munich AKA LiMux - There has been a lot of FUD written about one of the largest public conversions to an open-source platform, and it was great to see an actual insider talking about the project. Worth a watch.

Lightning Talks 2 - The first Lightning Talk was a proposal to add a new service to Debian. The service tests all uploaded packages for many known faults (using valgrind, infer, etc.), and automatically files bug reports on the faults. This should provide a large number of real bite-sized bugs for drive-by patches, and corresponding hefty improvement in code quality. Most cool.


Under the hood


Your Systemd Tool Box - Dissecting And Debugging Boot And Services - This is a great walk-through of the new (to me) tools. Had a terminal window open alongside to try each of the tools. Saved the video for a refresh, it's a lot to digest in one sitting.

Systemd How We Survived Jessie And How We Will Break Stretch - Fantastic discussion of coming systemd features: Persistent interface names, networkd, kdbus, and more. Also great discussion of how to get involved around the edges.

Dpkg The Interface - A presentation by the current maintainer, explaining how he keeps dpkg stable and the future roadmap. Since Snappy uses dpkg (but not apt), that roadmap is important! I have used dpkg for a decade, but never thought about all the bits of it I never see....


Keeping Free Software Free


Debians Central Role In The Future Of Software Freedom - A presentation by the President of the Software Freedom Conservancy (SFC), explaining the problems they see, their strategies to attack those problems, and how they try to effectively challenge GPL violations. A bit of Canonical-bashing in this one at a couple points (some deserved, some not).

At 23:30, it introduces the Debian Copyright Aggregation Project, where Debian contributors can opt to revocably assign their copyright to SFC, and can also permit the SFC to enforce those copyrights. This is one strategy SFC is pursuing to fight both CLAs and license violations.




Wednesday, September 2, 2015

You should be using Find-a-Task

Find-a-Task is the Ubuntu community's job board for volunteers.

Introduced in January 2015, Find-a-Task shows fellow volunteers the variety of tasks and roles available.

The goal of Find-a-Task is for a volunteer, after exploring the Ubuntu Project, to land on a team or project's wiki page. They are interested, ready to join, and ready to start learning the skills and tools. 

However, it only works if *you* use it, too.


Try it.


Take a quick look, and see the variety of volunteer roles available. We have listings for many different skills and interests, including many non-technical tasks.


Is your team listed?


Hey teams, are you using Find-a-Task to recruit volunteers?
  • Are your team roles listed?
  • Are they accurate?
  • Is your landing page welcoming and useful to a new volunteer?

When it's time to update your postings on the job board, simply jump into Freenode IRC: #ubuntu-community-team.


Gurus: Are your pointing Padwans toward it?


Find-a-Task is a great place to send new enthusiasts. No signup, no login, no questions. It's a great way to survey the roles available in the big, wide, Ubuntuverse, and get new enthusiasts involved in a team.

It's also handy for experienced enthusiasts looking for a new challenge, of course.
  • If you're active in the various forums, refer new enthusiasts to Find-a-Task.
  • Add it to your signature.
  • If you know a Find-a-Task success story, please share.

Improving Find-a-Task


Ideas to increase usage of Find-a-Task are welcome.
Ideas on how to improve the tool itself are also welcome.
Please share your suggestions to improve Find-a-Task on the ubuntu-community-team mailing list.

Thursday, January 22, 2015

Is your team using Find-a-Task?

Find-a-Task is the Ubuntu community's job board for volunteers.

 

Is your team listed?


It's the place for volunteers to find new, interesting, fulfilling ways to contribute to Ubuntu.
It's the place for them to discover your team or project.

Get listed today!


We have made it super easy to get your team onto Find-a-Task: No login, no editing. Just jump into #ubuntu-community-team with a volunteer role in mind:

Example:
  • Category: Programming
  • Role: QML De-frobber
  • Very short description: Get rid of QML Frob with the Ubuntu Frobbing Team
  • Landing page: http://wiki.ubuntu.com/FrobbingTeam/QMLDefrobber

That's right...you can list technical roles, too.


Nah, I don't want volunteers


If the old way is working for you, and your team has lots of spare capacity, then more power to you! Please share your secret sauce.

But if you could use a few more hands to grab a work item or two, a Find-a-Task listing is fast and simple.

You really should, you know.

Tuesday, January 13, 2015

Introducing Ubuntu Find-A-Task



The Ubuntu Community website has an awesome new service: Find-A-Task

It's a referral service - it helps volunteers discover teams and tasks that match their interests.

  • Link to it!
  • Refer new enthusiasts toward it!
  • Advertise your teams and projects on it!

Give it a try and see how it can work for your team or project.


How do I get my team listed?


So easy and so fast.
  1. What volunteer role do you want to advertise?
  2. What's a very short, exciting description of the role?
  3. Which Find-A-Task paths do you think this role is appropriate for? 
  4. Create a great landing page on the wiki. (example)
    • Drop by #ubuntu-community-team and let us know.
      • Role: Frobishers, 
      • Description: "Help Frobnicators add fabulous Frob!"
      • Path: One, in the Coding and Development submenu
      • Landing URL http://wiki.ubuntu.com/FrobTeam/Frobishers

    Your landing page:


    This is a volunteer's first impression of your team. Make it shine.

    When volunteers show up at your wiki page, they are already interested. They want to know how to set up, who to contact, and how to get started on their first easy work item. They want instructions and details.

    If you don't provide what they want, they may move on to their next choice. Find-A-Task makes it easy for them to move on.



    Credits


    Tremendous thanks to:

    Saturday, December 13, 2014

    Say, what are you doing this afternoon?

    Bus Stop - Under The Rain by Leonid Afremov
    Here's a happy little afternoon project for new users trying to play with a new
    language or script, and getting their feet in the open-source ecosystem.

    Your phone's handy weather app depends upon the goodwill of a for-profit data provider, and their often-opaque API (14 degrees? Where was it observed? When?) That's a shame because most data collection is paid for by you, the taxpayer.

    Let's take the profit-from-data out of that system. Several projects have tried to do this before (including libgweather), but each tried to do too much and replicate the one-data-provider-to-rule-them-all model. And most ran aground on that complexity.


    Here's where you come in

    One afternoon, look up your weather service's online data sources. And knock together a script to publish them in a uniform format.

    Here's the one I did for the United States:
    Worldwide METAR observation sites
    US DOD and NOAA weather radars
    US Forecast/Alert zones

    • Looking for data on non-METAR (non-airport) observation stations, weather radar sites, and whatever forecast and alert areas your country uses.

    • Use the same format I did: Lat (deg.decimal), Lon (deg.decimal), Location Code, Long Name. Use the original source's data, even if it's wrong. Area and zones should use the lat/lon of the centroid.

    • The format is simple CSV, easy to parse and publish.

    • Publish on GitHub, for easy version control, permalinking, free storage, and uptime.

    • Here's the key: Your data must be automatically-updated. Regularly, your program must check the original source and update your published version. How I did it with a cron job. Publish both the data and your method on GitHub. 

    • When you have published, drop me an e-mail so I can link to your data and source.

    If you do it right, one afternoon to setup your country's self-updating database. Not a bad little project, you learn a little, and you help make the world a better place.


    My country doesn't have online weather data

    Sorry to hear that. You're missing some great stuff.

    If you live in a country with a reasonably free press and reasonably fair elections, make a stink about it. You are probably already paying for it through taxes, why can't you have it?

    If you live somewhere else, then next time you have a revolution or coup, add 'open data' to the long list of needed reforms.


    What will this accomplish?

    This will create a free, sustainably updated, uniform, crowdsourced set of accurate worldwide data that will be easy to compile into a single global database. If you drop out, your online code will ensure another volunteer can step in.

    This is one fundamental tool that other free-weather projects have lacked. And any weather project can use this.

    The global database of locations is really small by most database standards. Small enough to easily fit on a phone. Small enough to be bundled with apps that can request data directly from original sources...once they can look up the correct source to use.


    How will this change the world?

    It's about simple tools that make
    it easy to create free, cool software.
    And it's about ensuring free access to data you already paid for.

    Not bad for one afternoon's contribution.

    Friday, January 24, 2014

    Transit schedule data demystified - using GTFS

    General Transit Feed Specification (GTFS) is the Google-originated standard format for transit route, stop, trip, schedule, map, and fare data. Everything except realtime.

    It's called a feed because it (usually) includes an RSS update for changes.
    There are lists of feeds on the Google wiki, and on the separate GTFS data website.

    Each organization's GTFS file includes all their services, so some agency files can get pretty big, and get updated often. Any schedule change or route adjustment means a new release of the entire GTFS file. The file itself is merely a big zipfile, containing several csv files that are strangely required to be mislabelled as .txt.

    Here's the contents of Milwaukee County Transit System's GTFS file:

    $ unzip -l mcts.zip 
    Archive:  mcts.zip
      Length      Date    Time    Name
    ---------  ---------- -----   ----
          169  2014-01-10 05:01   agency.txt
        40136  2014-01-10 05:00   calendar_dates.txt
         5746  2014-01-10 05:01   routes.txt
       307300  2014-01-10 05:00   stops.txt
     35198135  2014-01-10 05:00   stop_times.txt
       650622  2014-01-10 05:01   trips.txt
      8369736  2014-01-10 05:01   shapes.txt
         3490  2014-01-10 05:01   terms_of_use.txt
    ---------                     -------
     44575334                     8 files

    Yeah, 44MB unzipped.
    But only 5MB zipped. Still not something you want to download every day to your phone.

    Let's find a stop at Mitchell International Airport:

    $ cat stops.txt | grep AIRPORT
    7168,7168,AIRPORT,,  42.9460473, -87.9037345,,,1
    7162,7162,AIRPORT & ARRIVALS TERMINAL,,  42.9469597, -87.9030569,,,0
    

    It's right, there are two stops at the airport. Each stop has a latitude and longitude, a unique ID number, and a descriptive name. The final field designates a timepoint (1=Timepoint, 0=Not).

    Let's try an intersection where two routes cross:

    $ cat stops.txt | grep "HOWELL & OKLAHOMA"
    709,709,HOWELL & OKLAHOMA,,  42.9882051, -87.9043319,,,1
    658,658,HOWELL & OKLAHOMA,,  42.9885464, -87.9045333,,,1
    $ cat stops.txt | grep "OKLAHOMA & HOWELL"
    5152,5152,OKLAHOMA & HOWELL,,  42.9881561, -87.9046550,,,1
    5068,5068,OKLAHOMA & HOWELL,,  42.9883466, -87.9041176,,,1
    

    Here's a problem that will require some logic to solve. I consider the intersection to be one place (not a GTFS term). Many trips and routes can use the same stop. Multiple stops (GTFS terms) can exist at the same place. In this case, northbound, southbound, eastbound, and westbound buses each have a different stop at the same place.

    This might make your job easier...or harder.

    GTFS cares about trips and stops. It doesn't care that Stops #709 and #5152 are twenty meters apart, and serve different routes - that it's a transfer point. Nothing in GTFS explicitly links the two stops. Generally, you must figure out the logic to do that - you have the lat/lon and the name to work with.

    GTFS does have an optional transfers.txt file, that fills in the preferred transfer locations for you. But that's for a more advanced exercise.


    Let's see what stops at #709:

    $ grep -m 5 ,709, stop_times.txt 
    4819177_1560,06:21:00,06:21:00,709,         14,,0,0
    4819179_1562,06:49:00,06:49:00,709,         14,,0,0
    4819180_1563,07:02:00,07:02:00,709,         14,,0,0
    4819181_1564,07:15:00,07:15:00,709,         14,,0,0
    4819182_1565,07:28:00,07:28:00,709,         14,,0,0
    


    These fields are trip_id, arrival_time, departure_time, and stop-sequence (14th).

    Let's see the entire run of trip 4819177_1560:

    $ grep 4819177_1560 stop_times.txt 
    4819177_1560,06:09:00,06:09:00,7162,          2,,0,0  # Hey, look - stops out of sequence in the file
    4819177_1560,06:09:00,06:09:00,7168,          1,,0,0  # Begin Trip
    4819177_1560,06:11:00,06:11:00,7178,          3,,0,0
    [...]
    4819177_1560,06:20:00,06:20:00,8517,         13,,0,0
    4819177_1560,06:21:00,06:21:00,709,         14,,0,0   # Howell & Oklahoma
    4819177_1560,06:22:00,06:22:00,711,         15,,0,0
    [...]
    4819177_1560,07:17:00,07:17:00,1371,         66,,0,0
    4819177_1560,07:19:00,07:19:00,6173,         67,,0,0
    4819177_1560,07:20:00,07:20:00,7754,         68,,0,0  # End of trip 
    

    We can also look up more information about trip 4819177_1560:

    $ grep 4819177_1560 trips.txt 
      GRE,13-DEC_WK,4819177_1560,N BAYSHORE - VIA OAKLAND-HOWELL METROEXPRESS,0,515111,13-DEC_GRE_0_12
    

    This needs a little more explanation
    • route_id: Green Line (bus)
    • service_id (weekday/days-of-service): 13-DEC_WK
    • headsign: N BAYSHORE - VIA OAKLAND-HOWELL METROEXPRESS
    • direction_id (binary, 0 or 1): 0
    • block_id (useful only if the same bus changes routes): 515111
    • shape_id (useful for route maps): 13-DEC_GRE_0_12

    Let's look up the route_id:

    $ grep GRE routes.txt
      GRE,MCTS,  GRE,MetroEXpress GreenLine,,3,http://www.ridemcts.com/Routes-Schedules/Routes/GRE/,,

    The full route name is MetroEXpress GreenLine, it's a bus (type-3 = bus) route, and we have the operator website for it.

    Let's look up the service_id:

    $ grep -m 10 13-DEC_WK calendar_dates.txt 
    13-DEC_WK,20140113,1
    13-DEC_WK,20140114,1
    13-DEC_WK,20140115,1
    13-DEC_WK,20140116,1
    13-DEC_WK,20140117,1
    13-DEC_WK,20140120,1
    13-DEC_WK,20140121,1
    13-DEC_WK,20140122,1
    13-DEC_WK,20140123,1
    13-DEC_WK,20140124,1

    Ah, this specific trip is a weekday (Monday-Friday) only trip.


    Let's look up the route map shapefile for the trip:

    $ grep 13-DEC_GRE_0_12 shapes.txt 
    13-DEC_GRE_0_12,  42.946054, -87.903810,10001
    13-DEC_GRE_0_12,  42.946828, -87.903659,10002
    13-DEC_GRE_0_12,  42.946824, -87.903588,10003
    13-DEC_GRE_0_12,  42.946830, -87.903472,10004
    [...]
    13-DEC_GRE_0_12,  43.123137, -87.915431,670004
    13-DEC_GRE_0_12,  43.123359, -87.915228,670005
    13-DEC_GRE_0_12,  43.124016, -87.914535,670006
    13-DEC_GRE_0_12,  43.124117, -87.914440,670007
    

    The line for this trip has 520 points. That's pretty detailed.



    So what do we know?

    We know that Stop #709 is served by the GreenLine route, it's the 14th stop in direction 0, it's a bus line, we have all the times the stop is served, and we have the route website. We know the route map and all the other stops of any trip serving that stop.

    How can we find the next scheduled bus at stop #709?

    One way is to start with all trips that stop at #709 from stop_times.txt.

    Since we probably know what time it is, we can filter out all the past times, and most of the future times. This leaves us with a nice, small list of, say, 10 possibles that include trips that don't run today at all (we must delve deeper to determine).

    We can look up each of those trips in trips.txt, and get the route.

    Each trip also includes a service_id code. The calendar_dates.txt file tells us which dates each service_id code is valid.

    Right, we need to do three lookups.

    The shell code gets a bit complex with three lookups, so I shifted to Python and wrote a basic next-vehicle-at-stop-lookup in about 160 lines. Python lists are handy, since it can handle all the stops at a location just as easily as a single stop. Python's zip module is also handy, so I can read data directly from the zipfile. But at 13 seconds, Python is probably too slow for this kind of application:

    $ time ./next_bus.py 
    
    Next departures from Howell & Okahoma
    16:16   GRE N AIRPORT - VIA OAKLAND-HOWELL METROEXPRESS
    16:22   GRE N BAYSHORE - VIA OAKLAND-HOWELL METROEXPRESS
    16:26    51 OKLAHOMA - TO LAKE DRIVE
    16:28    51 TO 124TH ST. - VIA OKLAHOMA
    16:30   GRE N AIRPORT - VIA OAKLAND-HOWELL METROEXPRESS
    16:35   GRE N BAYSHORE - VIA OAKLAND-HOWELL METROEXPRESS
    16:43    51 TO 124TH ST. - VIA OKLAHOMA
    16:44   GRE N AIRPORT - VIA OAKLAND-HOWELL METROEXPRESS
    16:45    51 TO NEW YORK
    16:45   GRE N BAYSHORE - VIA OAKLAND-HOWELL METROEXPRESS
    16:56   GRE N BAYSHORE - VIA OAKLAND-HOWELL METROEXPRESS
    
    real 0m13.171s   # Ugh. If I had started 13 seconds sooner, I wouldn't be bored now.
    user 0m10.740s
    sys 0m0.260s
    



    All that time crunching the GTFS file has not gone unnoticed.

    Trip planners (like Google) pre-process the data, mapping out and caching link-node and transfer relationships, limiting the trip data to the next hour or two (as appropriate), and using rather fancy algorithms to prune the link-node map to a likely set of  possibilities before looking at trips along those links.

    That's one reason Google Transit is much faster than 13 seconds.

    But that's all advanced stuff.

    Also advanced is how to integrate real-time data, which uses one of several different formats. Next time...



    Monday, December 2, 2013

    upstart-socket-bridge

    Upstart-socket-bridge is a lot like xinetd. They replace the need for some daemons by monitoring a port, and then launching the desired application when an inbound connection is detected. U-s-b is part of a family of Upstart services that replace many daemon monitoring and listening functions and hooks.

    Unlike xinetd, services need to be customized (patched) to run with upstart-socket-bridge.

    Documentation is quite sparse. Hence this blog post. That's not intended to criticize; it's really hard to write "good" documentation when you don't know the use cases or the experience level of the user. If you have experience with writing sockets in C, and understand what a file descriptor is and how to use one,  then the documentation is just fine. I didn't before I began this odyssey.




    How do I make it work?

    Here are three simple examples of how it works.
    One uses shell script.
    One uses Python3.
    One uses C.



    Hello, World! with shell script


    The script that gets triggered by the port action. The port is just a trigger, no data gets exchanged on the port.

    1) Let's create a shell script called test-script. This script merely prints out the Upstart-related environment variables into a file.

    #!/bin/sh
    outfile=/tmp/outfile
    date > $outfile            # Timestamp
    printenv | grep UPSTART >> $outfile
    exit 0


    2)  Create an Upstart .conf, let's call it /etc/init/socket-test.conf

    description "upstart-socket-bridge test"
    start on socket PROTO=inet PORT=34567 ADDR=127.0.0.1  # Port 34567
    setuid exampleuser                                    # Run as exampleuser, not root
    exec /bin/sh /tmp/test-script                         # Launch the service


    3)  Let's run it. Connect to the port using netcat.

    $ nc localhost 34567
    ^C       # End the process using CTRL+C


    4)  Look at the result. Hey, look, it's all the environment variables we need!

    $ cat /tmp/outfile


    5)  Clean up:

    $sudo rm /etc/init/socket-test.conf           # Disconnect the launch trigger
    $rm /tmp/test-script /tmp/outfile             # Delete the test service





    "Hello, World" service in Python 3

    (UPDATED: Thanks to Dmitrijs Ledkovs for getting this to work!)

    It's a simple echo server - the Python version of the C service below. It requires two files, the application and the Upstart .conf. It demonstrates how a service reads uses the port connection for a trigger and exchanging data.


    1) Let's create the Python 3 file. Let's call it test-service.py

    #!/usr/bin/python3
    import os, socket
    
    # Create the socket file descriptor from the the env var
    sock_fd = socket.fromfd(int(os.environ["UPSTART_FDS"]),
                            socket.AF_INET, socket.SOCK_STREAM)
    
    # Accept the connection, create a connection file descriptor
    conn, addr = sock_fd.accept()
    
    # Read
    message = conn.recv(1024).decode('UTF-8')
    
    # Manipulate data
    reply = ("I got your message: " + message)
    
    # Write
    conn.send(reply.encode('UTF-8'))
    
    # Finish
    conn.close()



    2)  Create an Upstart .conf, let's call it /etc/init/socket-test.conf

    description "upstart-socket-bridge test"
    start on socket PROTO=inet PORT=34567 ADDR=127.0.0.1  # Port 34567
    setuid exampleuser                                    # Run as exampleuser, not root
    exec /usr/bin/python3 /tmp/test-service.py            # Launch the service


    3) Let's run it. Connect to the port using netcat, and then type in a string.

    $ nc localhost 34567
    Hello, World!                       # You type this in. Server read()s it.
    I got your message: Hello, World!   # Server response.  Server write()s it.


    4) Cleanup is simple. Simply delete the two files.

    $ sudo rm /etc/init/socket-test.conf         # Disconnect the bridge
    $ rm /tmp/test-service.py                    # Delete the test service







    "Hello, World!" service in C


    It's a simple echo server - the C version of the Python service above. It requires two files, the application and the Upstart .conf. It demonstrates how a service reads uses the port connection for a trigger and exchanging data.

    1)  Let's create a C file. Let's call it test-service.c

    #include <stdlib.h>
    #include <netinet/in.h>
    #include <string.h>
    
    int main()
    {
        /* Read the UPSTART_FDS env var to get the socket fd */
        char *name = "UPSTART_FDS";
        char *env = getenv (name);       // Read the environment variable
        int sock_fd = atoi(env);         // Socket file descriptor
    
        /* Don't need to do any of these normal socket tasks! Hooray!
        / int port_num;           
        / int sock_fd = socket(AF_INET, SOCK_STREAM, 0);  
        / memset((char *) &serv_addr, 0, sizeof(serv_addr));
        / serv_addr.sin_family = AF_INET;
        / serv_addr.sin_addr.s_addr = INADDR_ANY;
        / serv_addr.sin_port = htons(port_num);
        / struct sockaddr_in serv_addr
        / bind(sock_fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr));
        / listen(sock_fd, 5)                                                 
        */
    
        /* Accept() the connection. Returns the second fd: 'conn_fd' */
        struct sockaddr_in cli_addr;   // Requires netinet/in.h
        int clilen = sizeof(cli_addr);
        int conn_fd = accept(sock_fd, (struct sockaddr *) &cli_addr, &clilen);
    
        /* Service is active. Read-from and write-to the connection fd */
        char response[276] = "I got your message: ";
        char buffer[256];
        memset((char *) &buffer, 0, sizeof(buffer));  
        read(conn_fd, buffer, 256);                   // Read from conn_fd
        strcat(response, buffer);                     
        write(conn_fd, response, strlen(response));   // Write to conn_fd
    
        /* Close the connection fd. Socket fd can be reused */
        close(conn_fd);
        return 0;
    }

    2)  Compile it using gcc, and output the compiled application as an executable called test-service. I put mine in /tmp to make cleanup easier. If you're familiar with gcc, the important element is that there are no flags and no libraries:

    gcc -o test-service test-service.c


    3)  Create an Upstart .conf, let's call it /etc/init/socket-test.conf

    description "upstart-socket-bridge test"
    start on socket PROTO=inet PORT=34567 ADDR=127.0.0.1  # Port 34567
    setuid exampleuser                                    # Run as exampleuser, not root
    exec /tmp/test-service                                # Launch the service


    4) Let's run it. Connect to the port using netcat, and then type in a string.

    $ nc localhost 34567
    Hello, World!                       # You type this in. Server read()s it.
    I got your message: Hello, World!   # Server response.  Server write()s it.


    5) Cleanup is simple. Simply delete the three files.

    $ sudo rm /etc/init/socket-test.conf         # Disconnect the bridge
    $ rm /tmp/test-service.c /tmp/test/service   # Delete the test service



    How does it work?

    Here is the oversimplified explanation. Each stream of data whizzing round inside your system is tracked by the kernel. That tracking, sort of like an index or a pointer, is called a file descriptor (fd). A few fds are reserved (0=stdin, 1=stdout, 2=stderr) and you run into these in shell scripting or cron jobs.

    A pipe or port or socket is just a way to tell the kernel that a stream of data output from Application A should be input to Application B. Let's look at it another way, and add that fd definition: An fd identifies a data stream output from A and input to B. The pipe/socket/port is a way to express how you want the fd set up.

    Now the gritty stuff: A socket/port can have a single server and multiple clients attached. The server bind()s the port, and listen()s on the port for connections, and accept()s each connection from a client. Each connection to a client gets issues another file descriptor.

    That's two file descriptors: The first defines the port/socket in general, and the second defines the specific connection between one client and the server.

    Upstart tells your server application (since it's not actually serving, let's just call it the "service") the first file descriptor.
    • Your service doesn't start a daemon at boot.
    • Your service doesn't bind() to the socket/port. Upstart does that.
    • Your service doesn't listen() on the socket/port. Upstart does that.
    • Your service doesn't fork() for each connection. Upstart launches an instance of your service for each connection. Your service can terminate when the connection ends...if you want it to.
    • Your service does accept() the connection from a client, communicate using the resulting file descriptor, and end when the connection close()s.

    Let's try it with the example above:
    1. Upstart and Service are running on Server. Client is running somewhere else - maybe it's also running on Server, maybe it's out on the network somewhere.
    2. The file /etc/init/socket-test.conf tells Upstart to monitor port #34567 on behalf of test-service application. As currently written, it will begin monitoring at boot and stop monitoring at shutdown.
    3. When Client --like netcat-- connect()s to port #34567, Upstart launches test-service application with a couple extra environment variables.
    4. test-service reads the environment variables, including the file descriptor (fd).
    5. test-service accept()s the connection on the file descriptor. This creates a second fd that Service can use to communicate.
    6. When Client and test-service are done communicating, they close() the connection fd.
    7. test-service can end. Upstart will restart it next time an inbound connection is received.




    How do I make it work with a service I didn't write? (like my favorite Game Server or Media Server or Backup Server)

    Maybe it will work, maybe it won't. There are a couple issues to consider. I don't see an easy, non-coding solution because we're talking about changing the nature of these services.
    • Change from always-on to sometimes-on.
    • Change to (save and) quit when the connection is done instead of listen()ing for another connection. I don't see any upstart trigger for a socket connection ending.
    • Might make some service code simpler. No longer need to fork() or bind().
    • Not portable to non-Upstart systems, so the daemon code remains. Adds a bit to code complexity and a new testing case.
    • A different trigger (hardware, file change, etc) might be a better trigger than a connection to a socket. Upstart has bridges for those, too.

    Tuesday, May 7, 2013

    Brainstorm Big 5 - May 2013

    These are a few of the more interesting current ideas on Brainstorm. When you prepare for UDS, also do a quick Brainstorm search. It's a good way to see what users have thought about the topic in the past.

    If you want to leave Developer Feedback on a Brainstorm Idea, but lack permissions, then please contact me. I can assign you permission, or simply add your response for you.  (ian dash weisser at ubuntu dot com)




    The all-time top four:

    The current top four all-time Brainstorm Ideas. They change from time to time as new ideas overtake old ideas, or as ideas get merged or implemented or closed.

    You may see a common theme among them:

    1) Restoring the bootloader by Ubuntu Live media
    2) Graphical frontend to edit GRUB menu
    3) Provide a simple interface for labeling partitions and external drives
    4) Better Hardware Profile Manager

    Here is what I see: None of these seem like features requested by unskilled users.

    Instead, these seem more likely to be used by migrating power-users who have imprinted upon previous systems...and then discovered their first hurdle on the learning curve.

    Now, I'm not proposing that we should implement any of these ideas. Instead, consider it a data point - here is one measure of how Ubuntu is perceived by rather skilled new users. Not what they actually need to be productive, but what they spend their time looking for fruitlessly.

    And when they don't find it, some of them rant about Ubuntu. Goodness, just look at some of those comments.
    • Do we want these issues to be the first hurdles for this type of user?
    • Is there an easy alternative we can draw them into?
    • Is there a better message that Ubuntu, Launchpad, the forums, the Teams, etc. should be communicating to them?
    • Are these opportunities to begin their learning curve in a kinder, gentler way?
    • I wonder why those users, after overcoming the hurdle, did not implement a solution to help those who came after them?






    Monetization by committee

    To round out the Big 5 this month,

    Alternative Sources of Income

    The top Idea of the past six months, this is a crazy-quilt of monetization ideas.  I've been -among other things- a banker and a real-business-with-employees owner and a QA inspector, so I completely understand how unrealistic some of the money-handling-and-administration Solutions really are. But like the all-time top-four (above), the real message is the intent and the context.
    1. People are still really frustrated by [what they think are] bugs.
      Frustrated enough that some are willing to pay [small amounts] for bug bounties.
      Yet apparently not frustrated enough to actually get involved.

    2. There is also a lot of FUD still floating around about unity-lens-shopping, and some new users are still getting attracted to the tinfoil-hat crowd's message.
    • Is this an opportunity to recruit for the Bug Squad? LoCos? Teams? Upstreams?
    • How can we make our commitment to personal data privacy clearer?
    • How can we improve the message that Ubuntu users are participants, not customers?

    Feel free to discuss in the appropriate Brainstorm Idea page, or in the comments section of this blog, or by e-mail...or anywhere else you like. Like at UDS.
    Yeah, at UDS.
    See you on IRC at UDS!

    Saturday, May 12, 2012

    Ubuntu Brainstorm and UDS-Q

    Greetings, fellow Brainstormers,

    I have, as usual, been monitoring the latest Ubuntu Developer Summit from afar. And I'm pleased to see a lot of Brainstorm Ideas popping up in various sessions.

    That's one of Brainstorm's great purposes - to provide a range of ideas ready for discussion by developers.

    - If you were UDS participant, please let us know how Brainstorm can help you better next time. Even if you didn't use Brainstorm at all, we would love to know why you didn't consider it as a preparatory source. There is always room for improvement, and relevance to you is one of our big goals! Feel free to send an e-mail to the moderator list, or e-mail me privately, or leave a comment on this blog post.

    - If you weren't a UDS participant, even a remote one like me, set aside some time to plow through the various session records. A lot of decisions get made in those rooms! And some -usually the ones important to you- of them don't get discussed widely afterward. If you see a project that interests you, get involved! Ubuntu grows from community contributions and participation. Brainstorm Ideas are merely the first step.

    Here's a sampling of the Ideas I saw in action on just Monday! Many are probably from non-Brainstorm (parallel) origin...but I don't care about the origin, I care that it got talked about. I care that it improves Ubuntu.

    Sound Theme, especially customizing:
         http://summit.ubuntu.com/uds-q/meeting/20655/sound-theme/
         http://brainstorm.ubuntu.com/idea/3665/

    Embedded Device images and development:
         http://summit.ubuntu.com/uds-q/meeting/20498/foundations-q-embedded-rootfs/
         http://brainstorm.ubuntu.com/idea/21841/

    Hardware Testing:
         http://summit.ubuntu.com/uds-q/meeting/20383/hardware-q-distributed-testing/
         http://brainstorm.ubuntu.com/idea/19151/
         http://brainstorm.ubuntu.com/idea/24693/
         http://brainstorm.ubuntu.com/idea/29704/
         http://brainstorm.ubuntu.com/idea/21604/
         http://brainstorm.ubuntu.com/idea/29367/
         ...and several more.

    Cheers, and keep talking!

    Saturday, November 26, 2011

    Ubuntu Brainstorm - inside the sausage factory

    Brainstorm gets about 2,000 submissions each year.
    What do we do with all those ideas?
    How can they help you, without bogging you down?

    Well, we close about 85% of them immediately. That's good - it keeps the system from being spammed by all those bugs, complaints, and other not-really-ideas.

    About 2% get reviewed by the Ubuntu Technical Board. We try to get the most out of that 2%!

    Most new Brainstormers are new to the Ubuntu community - they find Brainstorm in their first excursion looking for a way to contribute. A Brainstorm idea is their first attempt to speak up, so we try to handle them carefully.

    (If you were, er, untactfully treated by any moderator in the past, then please accept my most humble apologies. If you find a recent idea we handled tactlessly, *please* let me know!)


    The Idea Sandbox

    Of course, most of those first-ideas aren't very good. My first idea was awful, too.
    - Make it more like my old OS
    - Fix this bug
    - This doesn't work very well
    - Hey, do this. It's self-evident
    - Substitute application X for application Y in the default install
    - Create a whole new distro for a very small audience
    - Develop a whole new application
    - I don't like this
    - Someone should be in charge of this
    - Make this incredibly minor change to one application
    - If only my perfect idea would reach SABDFL, *he* would appreciate it, though none of you other fools do.

    In the Sandbox, we gently address every idea. Is it a bug in the wrong venue? Is it a dispute or complaint in the wrong venue? Does it clearly describe a real problem that has multiple possible solutions? Has the problem already been solved some other way? Is this a duplicate? Was it discussed by the community before (and the result)? Is the submitter still interested in the idea, or was it a fire-and-forget notion? Is the issue handled within an existing project or team, or does it cross boundaries?

    Most submitters, of course, abandon their idea when they realize that nobody will implement it for them...or that they need to do some research or file a bug report or otherwise become a contributing community member.

    We do a lot of basic instruction on how the Ubuntu software ecosystem works, and try to change many of them from a customer-mindset to a community-member mindset. That's a hard transition, and we're still trying to find better ways to do it.

    This is an opportunity to recruit new members for YOUR project/team, and turn a lot of potential complainers into contributors and advocates. We're trying, and good ideas on improving our methods are welcome. So are more drop-ins from other teams - come in, answer a few project-specific questions, and leave with the contacts for a half-dozen new people interested in your subject.


    30-day voting

    15% of that 2000 pass the Sandbox - the problem statement is real and clear, and it won't waste the community's time. Some of that 15% is marginal - the problem is real enough, but needs community input to refine.

    We leave those marginal ones open for only 30 days, to give the submitter the public feedback they want. These have the clear understanding that we're leaving it open for feedback to help refine the issue - it won't be seen by the Ubuntu Technical Board.

    30-day wonders are also helpful to developers who want to use Brainstorm for project-related polling or questions. Just ping a moderator in #ubuntu-brainstorm so we can skip it past the Sandbox for you.


    6-month voting

    Around 10% of the original 2000 are left open for the full 6-month voting period (and, indeed, left open long after that. We have still-open ideas from 2008).

    If you find a question that's relevant to your project or team, and have an answer, please ping a moderator in #ubuntu-brainstorm, so we can put your answer in the "Developer Comments" section of the idea, and close it for you.

    Similarly, if the issue has been raised and answered somewhere else (Launchpad, AskUbuntu, Blog Post), just post the link to the answer, and flag the idea so we know to close it.


    The Ubuntu Technical Board

    Every three months, the UTB selects 10 of the highest-voted ideas to review. 40 a year out of 2000 initial submissions, or around 2%. The 'review' isn't a promise to implement - indeed most result in a "hey, we agree this is a great idea, somebody in the community should implement this..." Some get added to UDS discussions, some turn into milestones for future releases. Some simply become bug reports.

    Every idea that the UTB reviews that simply becomes a "hey, great" or a bug report is a wasted opportunity. You didn't need to wait three months for that kind of feedback - by being involved with the right project or team, or filing the bug report yourself, you could have done all that yourself!

    We incorporate past UTB feedback into our moderation - for example we now routinely close ideas to create a whole new project unless they include a realistic resource plan. We encourage idea submitters to engage the appropriate bug tracker / upstream project / Ubuntu Team directly whenever possible. We want the best 40 new ideas before the UTB, real head-scratchers that will require research and create discussion and show up at UDS...and then as taskings.


    We have resources for your project

    Brainstorm doesn't need to be a filter for only the UTB - we can be a structured-community-feedback filter for *lots* of projects and teams. We have a lot of very smart and knowledgeable community members that help refine the ideas and solutions. If your project/team reviews Brainstorm input on a regular basis, please let us know. If you're looking for certain types of ideas, or want us to moderate your relevant ideas in a different way, just pop in to #ubuntu-brainstorm and let us know.


    Are you ready for the challenge?

    If you're an AskUbuntu or Forums or IRC guru looking for the next challenge to your technical and diplomatic skills, looking to help shape the next generation of contributors...well, come on by.

    Saturday, November 19, 2011

    The Unexpected Success of Ubuntu Brainstorm

    Once upon a time, there was a busy, vibrant community...with some communication issues. Yes, I'm talking about the Ubuntu community. Back in 2007.

    So Ubuntu created a website to foster community discussion about ideas to improve Ubuntu. http://brainstorm.ubuntu.com

    Conventional Wisdom from the old-timers who remember those heady days is that it didn't work out. The site was quickly overwhelmed with bugs (not ideas), complaints (not ideas), and unrealistic expectations. It didn't work.

    And Conventional Wisdom had those facts right...but reached entirely the wrong conclusion! Brainstorm has been successful in ways that were unexpected at the time.


    1) Brainstorm is indeed lousy at directly turning submissions into code.

    Well, we knew this already, didn't we? There is no roomful of monkeys poised over their keyboards eagerly awaiting the next idea to begin cranking out Shakesperian code. There never was. There never will be. Implementation was never really expected to be a metric of success...community action was supposed to be the metric.


    2) Brainstorm is a great early-warning system for controversy.

    What? You can avoid getting blindsided? Brainstorm is awesome at reflecting the community's (lack of) consensus on a wide range of issues. For example, when 'close window' window button changed sides, the ideas on the topic were plentiful. Similarly, today most ideas are about Unity. Brainstorm is also a pretty good barometer of whether an issue is temporary or chronic, and our moderators are excellent at separating valid issues from mere whining (so you don't have to).


    3) Brainstorm is a great place to recruit enthusiastic new members.

    The website is a portal-of-entry for users who are just starting to get involved, but don't understand the community's structure yet, or how the various teams and projects interact.


    4) Brainstorm keeps project community input manageable.

    If you are involved with a project, you know how challenging it is to manage certain types of community feedback. Brainstorm has reviewers and moderators who do nothing but handle those tough cases. Better yet, it's set up to let the community itself moderate feedback for you. And it's set up so that you only answer an issue once...ever.


    5) Brainstorm finds your blind spots.

    Maybe it's documentation, maybe it's a workflow, maybe it's a use case, maybe it's a legacy, maybe it's something else. The trend of feedback across years helps you improve user experience.


    So, in the spirit of Ubuntu Community Appreciation day,

    - Thanks to nand for writing and maintaining Ideatorrent.

    - Thanks to the best moderators and reviewers in the world: Vahan Harutyunyan, DarwinSurvivor, Komputes, DrG, alourie, andruk, and Thonixx

    Your valiant efforts to raise the quality of discussions and ideas, and to uphold the Ubuntu Code of Conduct, challenge me to strive. I'm very proud to work with people of such high caliber.