Srikanth Perinkulam

Menu Close

Category: Technology (page 1 of 2)

Network auto-latch

I realised the raspberry pi that hosts my nextcloud setup wasn’t quite latching back on to the network if the router was turned off or if the internet was sketchy. Was a pain to hard boot the device manually to reset it. Decided to write a short script to reset the network connection when it noticed something was off.


ping -c4 192.168.0.1 > /dev/null
if [ $? != 0 ] 
then
  echo "SOS..Restarting eth0 for network latch"
  /sbin/ifdown 'eth0'
  sleep 5
  /sbin/ifup --force 'eth0'
fi

A chron job runs every 10 minutes to take pulse of the network, runs the above code and picks up connectivity without manual intervention!

Bringing the cloud home

I finally got my Shoebox server setup working! I now have three Single board Computer [SBC] working in tandem behind my home router to accomplish what I’ve been wanting to do for quite sometime now – Setting up an easy-to-maintain, in-house server for all my data and web hosting needs. Fixing this all together has been a tremendous learning experience. I still need to weed out some pesky issues but I believe I have the bearing right now.

Here’s my current setup:

  1. NexcloudPi installed on a Raspberry pi 3B+ board
  2. Yunohost installed on an Odroid XU4 board
  3. Diet-Pi installed on another Raspberry pi 3B+ board

I’ve been using Nextcloud as my data storage solution for more than a year now. It does what I expect it to do and much more. NextcloudPi handles the intricate details and takes out the hassles that come with hosting data on personal servers.

On the ODroid-XU4, I installed debian stretch as the base OS and then manually installed Yunohost as my web server. I use ServerPilot on my Digital ocean servers and was looking for a close match while self hosting. Love YHs web-ui and they did seem to support quite a few web apps. I also have my eyes on cozy and caprover. Might explore these at a later point in time if decide to switch to a different SBC.

Both NextcloudPi and Yunohost have letsencrypt tools to setup and manage certificates for the domains/sub domains. While super useful, I realised to benefit from that feature, I had to rely on haproxy. With some pointers from the Nextcloud forum, I decided to use another pi to front as the main server. Installed Diet-pi on it since it’s just something I really liked and configured haproxy on it to map to the corresponding server based on the hostname. While at it, I also added in a switch between the router and various servers.

I still need to work on making this more robust. One niggling issue is the speed is heavily compromised. I’m guessing it’s do with my haproxy config and I should be able to fix it pretty soon. Once I have this sorted out, I need to spend some time hardening the security of the server, further configure Yunohost, device my backup strategies and finally moving my websites over from Digital Ocean.

ODroid XU4 SBC

Meena and my family gifted me an Odroid XU4 SBC earlier last month as a Christmas/B-day gift. One of my projects during the year-end holidays was to setup a robust home server; Essentially getting my webservers home from Digital Ocean, where they are currently hosted. This would be a terrific companion to the nextcloud fileserver that I setup earlier using a raspberry pi.

Earlier this week, I chanced upon DietPi and decided to launch it on the eMMC chip. One of the first things I did was to install Pi-Hole. With uBlock addons’ that should be some good riddance to ads across my home network! Would be interesting to keep track of these network pings to see what devices are needlessly calling ‘home’.

I’ve ported my web applications to the Odroid board and am currently testing out the server internally before I ‘turn on’ the traffic switch. All looks super-promising so far! Over the next few months, I’ll have to tweak the settings and tune this mini-beast a bit for performance. For now though, I’m more than happy with what it’s delivering!

Snappy Nextcloud

Last year, I procured a Nextcloud box and moved part of my data to it. I’d just heard about Ubuntu Snappy Core OS and was keen on porting my install to that setup. I finally got around doing that last week and thought I’d quickly jot down the install steps for reference later. Essentially, I installed the Core OS on a 32GB microSD card and installed Nextcloud as a snap. Two 1TB hard drives service the Pi3 and are synced with rclone. Below is a crude outline of the setup:

Install and sign-in to the UbuntuCore OS:

1.Download the latest Ubuntu Core OS and use Etcher to burn it on to a microSSD card.

2.On your local machine generate a public/private rsa key using the following command:
ssh-keygen -t rsa
Create an UbuntuOne account if you don’t already have one and import your ssh key to your account. You’ll need this to ssh into your Core OS pretty soon.

3.Slide in the microSSD card onto the Pi3 board. Then connect a monitor, keyboard and hard drive to the Pi3 and power it on. The Pi3 Board B comes with in-built wi-fi and bluetooth and once powered on it should automatically prompt you to connect to the wi-fi and then to your UbuntuONE account. Once this is setup, you should be able to ssh into the CoreOS from your local machine using:
ssh [email protected]
+ If ssh fails – “Error – signandsend_pubkey: signing failed: agent refused operation”. This is most likely because the ssh agent is already running but isn’t able to find the private keys. To add the keys to the authentication agent, enter ssh-add. Also to see list of fingerprints of all identities added use ssh-add -l + To add a password for the user: sudo passwd ubuntu-username + To re-configure network at anytime: sudo console-conf

External Drive setup
1.I use two external hard-drives one as a primary and the other as a secondary. First format the drives: sudo fdisk /dev/sda
+ Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): o
Created a new DOS disklabel with disk identifier 0x8b913f43.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-1953458175, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-1953458175, default 1953458175):
Created a new partition 1 of type 'Linux' and of size 931.5 GiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

2.Format the partition and give it the label data. This label will be used to reference it for mounting later: sudo mkfs.ext4 -L data /dev/sda1
+ mke2fs 1.42.13 (17-May-2015)
/dev/sda1 contains a ext4 file system labelled ‘data’
last mounted on Sat Nov 18 08:38:49 2017
Proceed anyway? (y,n) y
Creating filesystem with 244182016 4k blocks and 61046784 inodes
Filesystem UUID: c03685e6-fc4d-4d69-b8cf-8b17b24f2e0a
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

3.To mount the partition we’re forced to rely on systemd since most of Ubuntu core system is read-only and editing /etc/fstab is not an option. Mount units need to be named after the mount point directories they control. So create the media-data.mount unit: sudo vi /writable/system-data/etc/systemd/system/media-data.mount and add in the following content:

[Unit]
Description=Mount unit for data
[Mount]
What=/dev/disk/by-label/data
Where=/media/data
Type=ext4
[Install]
WantedBy=multi-user.target

4.Reload systemd to reflect the changes,Start and enable the mount volume so it gets automatically mounted:

sudo systemctl daemon-reload
sudo systemctl start media-data.mount
sudo systemctl enable media-data.mount

5.Make sure Ubuntucore is up to date and refresh:

sudo snap refresh
sudo reboot

After the reboot make sure /media/data is mounted and functional: sudo systemctl status media-data.mount

Install and configure Nextcloud as a snap

1.Install Nextcloud: sudo snap install nextcloud
2.Access the nextcloud install from any browser in the network using the IP address: http://192.168.0.xx, create an admin account and complete the installation.
3.Enable the ‘External Storages’ app under ‘Apps’.
4.Associate the removable media with nextcloud: sudo snap connect nextcloud:removable-media core:removable-media
5.Map /media/data with nextcloud in the external storage with the following settings:

Folder name: data
External storage: Local
Authentication: None
Configuration: /media/data
Available for: All

6.Setup encryption certificates: sudo nextcloud.enable-https self-signed
7.To access the setup pi3 server from outside the local network, you’ll need to map the dynamic dns provided by your ISP to a global address. I used no-ip and my netgear router to facilitate this.
8. Do note that when you upload files, by default they’re saved to the microSD card!! + here: /var/snap/nextcloud/common/nextcloud/data/NC_user/files. Read this forum for details.
9. If more than one user would be using the external data mount either install the ‘File access control’ app and setup rules or create folders for each person and just mount those folders for each user in the Nextcloud admin panel.

Fired up!

Finally got around procuring a pi3 and setup the Nextcloud Box! Getting this up and running was super fun and pretty straight forward.

The OS Image that was delivered with the box was built for the pi2. So I had to format the drive with Gparted and flashed the pi3 image with Etcher (One nifty piece of software!). Once the hardware was fired up, it just took care of itself. The web install was a 1-click setup.

Early this year as I initiated taking more control over my data, I also setup a Nextcloud server on the cloud. It’s been about eight months now and am thoroughly impressed with it. With the incredible iOS and android apps and the nifty client for linux I’m more than convinced the take this a step further and setup my personal home server.

Over the next few weeks as I tinker more with this, I need to make this a more robust setup and make full use of the snappy Ubuntu core.

Centralized publishing

Early in 2017, I consciously decided to consolidate all my social accounts and use my website as the main ‘vehicle’ for online interactions. While exploring options, I chanced upon the Indieweb philosopy which seemed to resonate quite a lot with my thoughts. Over the next few weeks I started taking steps to eventually migrate my publishing platform to a more robust framework. Below is a rough outline of what I have in place so far. I’ll try to keep this article live with updates as I work on enhancements.

Core framework:

This website is built with WordPress and is currently hosted on DigitalOcean [DO] fired-up by ServerPilot. I upgraded to DO early in 2017 from a shared server and I’m enjoying the tremendous benefits that comes with it. More on that is here.

 Interaction with Silos:

While I’m not quite an online dweller on social networks, I do post once a while on Instagram, Twitter and Facebook. Over the last few years, I’ve syndicated my posts to these networks on and off using various plugins. But none of those had features to fetch the interactions or responses back to my portal. Something that I really ‘craved’ for. While looking for better alternatives, I chanced upon the concept of webmentions. Meandering through the gamut of options, I eventually found a few tweaks that would work best for my publishing workflow.

The first step was to get my wordpress install talk indieweb. The WP starter page and the Advanced WP setup page on the Indieweb wiki were good places to get the wheels rolling and setup a base framework. Since I predominantly publish or draft articles while commuting, I was exploring options to post from a mobile device (iPhone). I lost my trust on the official wordpress app after it lost a couple of my drafts. And then I chanced upon Workflow which looked reliable and seemed to fit all my needs. Outlined below is a rough note on how I interact with the three silos using the workflow app on my iPhone and some custom functions in my WP install.

The general idea was to collect, process and publish. Based on the desired action (Post a status or activity update, Bookmark a link, Reply to a post and Publish a photo) I designed workflows to process the information and push it over to the WordPress action. One minor issue was that the post-kinds plugin sets up and uses a wordpress taxonomy called ‘kind’ to hand-shake with the micropub server. Since the WP action in Workflow did not accept entries for taxonomies, I had to create a ‘latch’ to identify the posts that I create via my workflows and map them to the corresponding ‘kind’ taxonomy. A few trials and I figured I could use a ‘custom field’ in the workflow app with some custom code in my functions plugin to map this out for me. The other minor tweak was to make my posts microformat compliant for the webmentions to work their magic. To get this working all I had to do was to feed the requisite html corresponding to that specific action into markdown just before passing it to the wordpress action in workflow.  Once that was done posting from my phone became a lot more easier (and fun!).

I chose to rely on a couple of slick plugins to post to the silos. SNAP helps me push notes out to twitter and I use a tag ‘trigger’ in my workflow to decide which posts I do not want publish on to twitter. I also use some custom code to add webactions to my twitter specific posts.  And then followed Chris Aldrich’s tweak to collect twitter mentions on a specific page. To handle Instagram, I use the Dsgnwrks Instagram Importer to consume photos (and their reactions). Ownyourgram for some reason wasn’t pushing photos to my server.

Intents and desires:

While the current publishing workflow works like a charm, I do need to do a few more tweaks to make this a more seamless process. Few things to note in no particular order:

  • ‘Sync’ desktop and mobile workflows. Currently I’ve different workflows while posting from these platforms. I use the Indieweb Pressthis bookmarklet while on the desktop and the ‘workflow’ app while posting from my iPhone.
  • Design a platform independent workflow. With workflow’s recent acquisition by apple, I’m skeptical of the outcome and need to come up with something that’s more resilient. Shouldn’t be dang difficult to spin a quick PWA or tweak some of the nifty tools that folks have already built.
  • Make my PeriRSS feed reader ‘talk’ to my portal. Basically enhance it with webactions.
  • Talk better with microformats.
  • Publish my code / workflows so others can easily tweak or adapt them for their use.

Discourse

Learn about Discourse, the 100% open source discussion platform built for the next decade of the Internet.

Source: Discourse

Migrations, Workflows and Awesomeness

Since mid 2016, I’ve been wanting to consolidate all the portals I manage. Having set them up on separate domain spaces, It was getting excruciatingly difficult to update/maintain/upgrade them. The admin interface at times was dead slow and I had restrictions with server permissions which wasn’t quite helpful. My first thought was to procure a home server and host all the portals from there. Besides speed and control, It would also give me flexibility to tinker with other self-hosted apps that I’ve been itching to work on. It looked like a great solution but I knew it would also need me to invest a lot of time, getting up to speed with server administration. With my new running schedule and several other things, time was a luxury I didn’t have and I was soon scouting for alternatives.

Read more

Enabling WiFi from the terminal

After a few rough beta installs of the OS, I decided to do a clean install of  Freya. It’s been a smooth sail so far but for the intermittent WiFi disconnects. For some reason the WiFi gets soft disabled at times. Until I figure out what’s causing this to happen and for future reference here’s a nifty work-around:

  • Determine the current state of the radio transmitters using rfkill. You’ll be able to see immediately If any of your devices are soft blocked.
 $ sudo rfkill list all 
  • Unblock radio transmitters as needed. In my case, something was turning the Wi-Fi off. I just had to turn this on using the below command:
 $ rfkill unblock wifi 

Note: In a few laptops the Wi-Fi  key is also mapped to the Bluetooth function, so to activate or deactivate you’ll just have to tap a few times to disable or enable wifi and/or bluetooth.

Important plugins for your WP Installation

Over the last seven years, since I moved to a self hosted platform I’ve grown really fond of WordPress as a CMS. The ease of its installation and maintenance, the power of scaling, the flexibility to adapt it to your requirements and it’s ever present support framework is something that I’ve really grown to appreciate over time.

I’ve worked on several installations of WordPress and over these years extensively tested quite a few plugins.  Read more

Updates from Epiphany

End of Year Showcase:

Today was the last day of the academic year for the kids. We got them to put up a small act as an End of Year showcase and invited their parents to come witness it. The idea was to get parents to be more invested in their kids education besides building the confidence of the kids. The kids were amazing on stage and put up a real pricey show! You should be able to access the video through this link: http://vimeo.com/22119752

Academics:
On the academic front, We’ve finished administering and tracking the kids final papers. At the beginning of the year the target was to gain a 1.5year growth on Reading Fluency, Reading Comprehension, Speaking & Listening, Grammar, Writing and Math. Our class average was at a mid KG level.[ Meaning, most of my kids who just entered second grade were just at the KG level].

The final diagnostics put them at a  1.2yrs growth in RF, 0.5yrs growth in RC, 1.2yrs growth in S&L, 1.5yrs growth in Writing and 1.0 yrs growth in Math. Though we haven’t been able to strike the targeted goal, guess this year would be a sound foundation for their growth next year. This summer should give the necessary time to plan and strategize for the oncoming academic year.

Parting gifts:

– Aditya More – the weakest kid in the class[Who till now hasn’t spoken even a simple complete sentence in english in class ] stood up in front of the 70 odd parents and 90 odd kids and spoke three sentences! Couldn’t have asked for a better gift…
– Khushi nudged me aside and handed over this thank you note!

Thanks for all the support you folks have provided till date. Will keep you posted once the next academic year starts.

Have a great weekend ahead.

Dual booting Multiple OS

Hosting more that one OS on your hard disk can be a pain if you’re not really sure on configuring the boot loader. I’ll confine the scope of this post to parenting only Debian based Linux OS ( Ubuntu ) and WIndoze. Because for the most part of it, I’ve only worked on them.

Why would you have to Install / reconfigure Grub in the first case?

1) You had to install Windows after you installed Ubuntu/Linux which led to the Grub ( Previously installed by Ubuntu ) to be over written by the Windows Boot loader.

2) You screwed up an installation right at the wrong spot and now you can boot neither Windows nor Linux.

Installing Grub through a Live CD:

  1. Insert the Ubuntu Live CD into the tray and restart your system
  2. Once you’re at the Live CD Desktop, Navigate to the terminal ( Applications>Accessories>Terminal)
  3. Type sudo fdisk -l /* This would list all the OS installations and drives that you have. Make note in which drive Ubuntu has been installed – Let’s say it’s hda3*/
  4. Next we’ll have to enter the Grub shell. Fot that type sudo grub
  5. In the grub menu type find /boot/grub/stage1 . This would return a listing of the drives in which the OS’s/ boot records are installed.
  6. Identify where Ubuntu’s Grub is on, by relating the output from step 3 and the above output.Now to let the Grub shell know what grub files are to be used, type root (hd0, 3) /* You’ll have to change this accordingly as per your output from step 3*/
  7. Now to install Grub on MBR,  type setup (hd0)
  8. By now, You should have got a success message from the grub shell telling you that the Grub has successfully been installed.
  9. Type quit and exit the terminal. Reboot and this should have properly fixed your Grub.

Installing Grub using the Super Grub disk:

If in case you do not have a Live CD, you can download a super grub disk and use it to setup the Grub for you. Check this page for more info on using the Super grub disk.

Note:

Installing Grub in your MBR will overwrite WIndows bootloader. If in case you do not find Windows in your boot menu after rebooting, all that you have to do is to make an entry in the Grub boot list.

Making an Entry of Windows in the Grub boot list:

  • In the terminal , type sudo gedit /boot/grub/menu.lst /* Always have a backup of this file. Screwing this will only cause more trouble */
  • Add the following lines wherever you would like the Windows entry to be listed

title WIndows XP Professional Edition

root(hdX,Y) /* Based on the fdisk -l output. Note: /dev/hda1 ==(hd0,0). /dev/hda2==(hd0,1) –> Grub  convention */

savedefault

makeactive

chainloader +1

  • Save Menu.lst and reboot. This should resolve the issue

Passwords and Security

Just ten minutes before I was supposed to leave for work yesterday,  I had this remote urge to get back Hardy running on my desktop. I had it installed but because of a windows re-install, the GRUB boot menu was overwritten. So all that I had to do was to re-install Grub!

 Powered the CPU , inserted Gutsy’s Live CD, logged into the desktop and fired a few commands in the terminal. The shell gave in a success message and I quickly rebooted to check if the Grub was installed. And boy, it did get installed right in the first go 🙂 !

I had to catch the 10:45 service so I powered the CPU off and ran my might to reach in time. Post work when I get back home and turn on the Desktop to check back on sweet old Ubuntu, I’m in for a surprise – I didn’t remember the Password for my Admin acccount ! Even before my instincts to re-install the OS took control, I rebooted and logged into Windoze. Googling a bit had even more surprises in store – A few posts in the Ubuntu Forum stated a minutes walk to Glory – You could override the admin’s password by a few quick commands! And till date, I was thinking Linux gave me all the security in the world. How wrong I was ! Or was I ?

This only made me think if Linux had a backgate entry, Bill’s Windoze should as well. Again thanks to Sergey and Larry, I realized hacking the windoze admin password was a cake walk too! Damn, it took me so many years to realise that. It was no damn rocket science!

This incident forked out a few salient points

1) If there’s a password – It can and will be hacked. It’s only a matter of when and how!

2) Linux is still a better vault when it comes to data security- Check this link

3) If you’re really worried about data security, You have every reason to be! It’s a murky world out there 😉 !

4) We’ve got one of the best processors – the Brain. High time we knew how to use it effectively 🙂 !

The Heron’s up there in the Servers!

The Ubuntu family has now doled out their latest OS – Ubuntu 8.04 code named – Hardy Heron. This release is more than different when compared to it’s previous releases. Majorly because it’s got a Wubi installer which facilitates installation directly from a Windows platform. The OS gets installed on the same partition just like any other software application, thus relieving a linux noobie from all the hassles of partitioning a drive. It can also be uninstalled just like any other app. through the Add/ Remove programs. 🙂

Hardy Heron is a Long term Support ( LTS ) version. The Ubuntu community release LTS versions once in every two years and I belive this version is going to be supported till 2011 ! For server editions the support is for Five years! 🙂

Hardy comes in with the Firefox 3 ( Still in the Late stages of Beta ), Open Office 2.40 and the GIMP (2.4.5) . Early reviews suggest the OS is pretty stable and gels with a breeze in Windows.  Ubuntu 7.04 ( Gutsy Gibbon ) literally smirked at Vista. Wonder what Hardy has in store!

Any reasons why you shouldn’t be giving this  a shot? 🙂

Rush and download it from here !

 

Damn! It’s all black!

Having something of you own definitely costs you a penny more!

I moved over my WordPress blog to a self hosted domain about a month back. It wasn’t much of a problem to start out with. But of late the loose threads are soon popping up!  Server down time, FTP issues, Database issues , linking issues to name a few.

After hooking to bland white themes for quite some time I thought I’d transition to a few dark themes. Wanted to use Red but then I realised I alone wouldn’t be reading  the posts on this blog. So settled for Black! Scouted for a couple of themes for my blog and baselanded on the elegant DF Theme. To relate it to my blog, I modified my site’s theme to black as well. All looked rosy(ROSY? 😉 ) on my Desktop with Firefox.  They blended well in IE too. Safari was never an issue. It only made the site look Royal! Tweaked the font size et al and finally it was all set up.

About two weeks later, people soon started dropping their comments! The color ain’t jelling! , Where’s the text? , Change the font! . Fools! Don’t they have a color sense? One more week passed and still the same comments. Nut Cases! Give them some aesthetic senses!

I never understood their suggestion…till today! I happened to check my site and blog on a different system , on a different browser with different settings at a different place ( not on my desktop at home) . And I realise how bad a testing I’d done when setting up my site. All I could see was BLACK. The font wasn’t visible, the contrast was too bad, the voting widget was all jacked up and , the comments tag was a bit too confusing , people were responding to one post instead of another, the tags were being misplaced. In a gist, The whole site was in a mess and it still is! What a jerk I was, to set my LCD monitors brightness and Contrast settings to the max and test the display! Sigh!

Folks! Really sorry for having neglected your suggestions!

I’m currently having very limited access to internet and my company’s Internet policies prohibits me from accessing login to my site! It’s a pity , this site and blog is to remain in a sad state of affairs as long as I’m in the Pune campus 🙁 . That ideally translates to another month or till I manage to get an accomodation somewhere in the City!

So till I manage to set things right, I’m just hoping your monitor’s display settings are set to make this site/blog readable. Too much of an expectation, but still that’s the best I can ask for! 🙂

And thanks a ton for your comments. Lest I would still be basking in twilights glory!