-
Notifications
You must be signed in to change notification settings - Fork 0
default env stuff
License
kennethd/etcskel
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This file was installed with your user account to describe a few special features of accounts on this system. The package which installed these files may be browsed online @ http://git.ylayali.net/?p=etcskel.git or checked out locally via $ git clone git://git.ylayali.net/etcskel.git If you want to report a bug in this package, please send an email to shellutils@ylayali.net ====== LICENSE ====== Copyright 2012 Kenneth Dombrowski <kenneth@ylayali.net> Scripts included in this package are licened under the Apache 2.0 license, configuration files and documentation are public domain. ====== DOTFILES ====== True to its ''/etc/skel'' origins, a number of //dotfiles// are installed the first time the upgrade script is run, or when the account is created if it is indeed created from ''/etc/skel'', including a reasonable ''~/.bashrc'', ''.vimrc'', ''.bash_logout'', & etc... These files are expected to be updated by most active users and the upgrade script will never overwrite them once installed. ===== ~/.bash_custom ===== If you want to customize your bash environment, this is the recommended place. The file does not exist by default, and will not be tracked or overwritten by the repo. <file bash .bash_custom> # prepend mediagoblin's bin to PATH if not already there if [[ ":$PATH:" != *":$HOME/mediagoblin/bin:"* ]] then # ~/.profile is pretty aggressive about keeping ~/bin @ front of PATH # so we will insert mg's bin as second export PATH="$HOME/bin:$HOME/mediagoblin/bin:${PATH##$HOME/bin:}" fi </file> ====== BACKUPS ====== The main feature provided is automatic backups. Installing my homegrown backup scripts for all user accounts, and having to maintain them across a dozen accounts after upgrades, is the raison d'etre for this package. There are two equally important parts to a successful backup plan: creating the backup (done, as described below), and copying the backup to a remote host, which with some configuration, helper scripts will also take care of for you. ===== automatic backups ===== The provided automatic backup scripts will not only backup your files, but also document the server environment: which packages are installed (along with their versions) for e.g. python, perl, and php libs The default location for backup storage is ~/backups: fusetron@gilgamesh:~$ ls -l ~/backups/ drwxr-sr-x 2 fusetron fusetron 4096 Sep 2 00:12 conf drwxr-sr-x 2 fusetron fusetron 4096 Sep 2 00:32 full ===== backup strategies ===== The scripts support two backup strategies: * full backup daily * full backup weekly + incremental backup daily The default configuration will perform a full backup daily, if you have a lot of files resulting in cumbersome large files, you may want to switch to the incremental plan; you will still get the huge complete backup on Sundays, but all other days will produce a backup consisting only of files which changed since the previous Sunday (so restoring will usually require two files, first extracting the backup from the previous Sunday, then extracting the most recent backup on top of it). See ''~/etc/backup/config'' ===== sync to dropbox ===== You can use dropbox.com to store your remote backups, and have access to them from any of your comput 8276 ers or dropbox-enabled devices. It is free for up to 2GB. If you don't have one already, create a dropbox account. You will have to authorize etcskel-backups to upload files on your behalf. You only have to perform this setup once per account. If you are setting up a new dropbox account, feel free to accept an invitation from me @ http://db.tt/NvvJZEIC (we will both get some extra storage) First, make sure you have the 'dropbox' python module: kenneth@gilgamesh:~$ sudo pip install -U dropbox To perform the authorization, at your user shell, run ''etcskel-dropbox-term'' and type ''login'': kenneth@gilgamesh:~$ etcskel-dropbox-term Dropbox> login url: https://www.dropbox.com/1/oauth/authorize?oauth_token=YOURUNIQUETOKEN Please authorize in the browser. After you're done, press enter. Dropbox> exit Copy the URL into a browser and push the "Authorize" button. Come back to the terminal and push enter, then type ''exit'' to get out of the shell. Any directory configured to be backed up in the file ''~/etc/etcskel/dropbox-sync-dirs'' will now be synced daily. ''etcskel-dropbox-term'' is actually a full featured CLI client, you can use it to interact with your dropbox folder from the command line, type ''help'' at the prompt for a list of commands. Remember to consider the data you are sending to a third party, if you have sensitive third-party data in your database dumps, for example, you may want to consider using rsync-backups to a private server instead. ===== rsync-backups ====== As an alternative to dropbox, if you have an internet-accessable host somewhere you can configure ''rsync-backups'' to take care of transferring your backups for you. ''rsync-backups'' relies on shared SSH keys, as far as I know it is not compatible with any cloud services, only with actual UNIX server accounts elsewhere on the internet. Enabling ''rsync-backups'' should require no more than editing ''~/etc/backup/rsync'', a number of changes are required: * RSYNC_BACKUPS_HOST must be set * RSYNC_BACKUPS_USER must be set * RSYNC_BACKUPS_PATH must be set Once these three variables are configured, run the script that tries to set up data-sharing permissions for you: $ rsync-backups-auth-setup If successful, the last change you need to make for automatic backups is to uncomment the line in the config file: RSYNC_BACKUPS_ENABLED=yes If you run into problems with this script, please send a detailed report to shellutils@ylayali.net. ====== CRON ====== One of the side benefits of the backup setup is a certain transparency wrt cronjobs. VCS-friendly cron scripts was another incentive for this package. The default crontab is based on vixie cron's special timespec strings: @daily, @weekly, @hourly, etc & an included script called ''run-parts'' which will execute all scripts within the associated directory. Your crontab (try `crontab -l`) should look something like this: <code bash> # any scripts in these directories will be run at the appropriate time @reboot [ -d "$HOME/cron.reboot" ] && /bin/run-parts $HOME/cron.reboot @hourly [ -d "$HOME/cron.hourly" ] && /bin/run-parts $HOME/cron.hourly @daily [ -d "$HOME/cron.daily" ] && /bin/run-parts $HOME/cron.daily @weekly [ -d "$HOME/cron.weekly" ] && /bin/run-parts $HOME/cron.weekly @monthly [ -d "$HOME/cron.monthly" ] && /bin/run-parts $HOME/cron.monthly @yearly [ -d "$HOME/cron.yearly" ] && /bin/run-parts $HOME/cron.yearly </code> Your ''~/cron.daily'' directory probably contains scripts for **backup**, **logrotate**, and **webalizer**, but you can drop your own scripts in there too You can (and should) edit your crontab by issuing the command ''crontab -e'', look for a line like: <code bash> #MAILTO=you@example.com </code> uncomment it & change the address to point to your webmaster so it looks like: <code bash> MAILTO=somebody@yourdomain.com </code> If you ever mess up your crontab too badly & want to start over, run the command ''reset-crontab'' ===== creating a cron script ===== Ideally cron scripts are simple invocations of other programs; some of the etcskel backup scripts are generally poor models to follow because they jump through hoops to use ''at'' to stagger invocations of io-intensive scripts (so everyone's backups don't kick off at the same time, overwhelming the disk io). If your script is disk-intensive, please do use use similar techniques to avoid your script running at the top of the hour, but in general you will want to keep things as simple as can be, for example: The ''ylayali'' user makes use of a wiki package called ''dokuwiki'', and a dokuwiki plugin to bring in the latest **xkcd** comic, but the plugin doesn't invalidate the cached copy of the page it is included on so a cron script invalidates the page's cache by updating the page's timestamp once a day: <file bash> #!/bin/sh # update the timestamp of the front page to prevent caching xkcd for too long touch /vhost/ylayali.net/var/dokuwiki-data/pages/start.txt </file> Just drop the script in your ''cron.daily'' directory, and it will run at midnight every day. You can name the script anything, but it should be executable & include a shebang line pointing to its intended interpreter. The regular UNIX environment is pretty restricted when scripts are run by cron, often scripts that work fine from your login shell will fail due to $PATH differences & the like, check out ''man 5 crontab'' if you run into problems. ====== UPGRADING ====== One of the installed ''cron.weekly'' scripts will compare your version of the etcskel version with that of the upstream developers, and send you an email if you are out of date. If you receive such an email and want to upgrade, a script is provided for you. You should be aware of its configuration though, if you have made local modifications to any files distributed by this package, your changes may be overwritten. If you want to maintain your own copy of any of the files distributed by etcskel, you can prevent them being upgraded by listing them in the config file ''~/etc/etcskel/no-overwrite'' If you set ETCSKEL_UPDATE_VERBOSE=yes in ''~/etc/etcskel/config'', the upgrade script will output a status for each file in the package indicating whether it will be overwritten or skipped, and a diff of any files mentioned in ''~/etc/etcskel/no-overwrite'' if your copy is different from the repo version. Status messages go to STDERR and diffs to STDOUT, so you can do: $ etcskel-update >/tmp/$LOGNAME-etcskel-update.diff to see the status output on your console, and then investigate the file ''/tmp/$LOGNAME-etcskel-update.diff'' to review the differences in your locally managed files. In any case, a backup is created every time you run the script, so there should always be a path for recovery (even if the upgrade script itself gets broken you always have your daily backups to fall back to) ====== FORKING ====== Creating a fork of etcskel is easy with git. I maintain a fork called 'etcskel-kenneth' which contains more of my personal configs, but still allows me to pull changes in from the upstream 'etcskel' project. Set it up like this: kenneth@x1:~/git$ mkdir etcskel-kenneth kenneth@x1:~/git$ cd etcskel-kenneth/ kenneth@x1:~/git/etcskel-kenneth$ git init kenneth@x1:~/git/etcskel-kenneth$ git remote add origin gitosis@git.ylayali.net:etcskel-kenneth.git kenneth@x1:~/git/etcskel-kenneth$ git remote add upstream gitosis@git.ylayali.net:etcskel.git kenneth@x1:~/git/etcskel-kenneth$ touch .etcskel-kenneth kenneth@x1:~/git/etcskel-kenneth$ git add .etcskel-kenneth kenneth@x1:~/git/etcskel-kenneth$ git commit -m 'initial commit' kenneth@x1:~/git/etcskel-kenneth$ git push origin master:refs/heads/master kenneth@x1:~/git/etcskel-kenneth$ git fetch upstream kenneth@x1:~/git/etcskel-kenneth$ git merge upstream/master kenneth@x1:~/git/etcskel-kenneth$ git push origin master We primarily want this branch to track upstream changes, and changes to the files upstream knows about will be made in that repo. In the case of wanting to contribute changes back upstream, it is probably best to cherry-pick commits from that repo rather than trying to selectively push: kenneth@dhalgren:~/git/etcskel$ git remote add kenneth gitosis@git.ylayali.net:etcskel-kenneth.git kenneth@dhalgren:~/git/etcskel$ git fetch kenneth kenneth@dhalgren:~/git/etcskel$ git cherry-pick 22709bee111ee35e417e145ed0eadf014639de02 You can now begin tracking your fork by editing ~/etc/etcskel/config: 13c13 < ETCSKEL_REMOTE_URL="git://git.ylayali.net/etcskel.git" --- > ETCSKEL_REMOTE_URL="git://git.ylayali.net/etcskel-kenneth.git" ====== EDITING ====== This section is for developers working on the etcskel files themselves A handy command to open all files in the project is: vim `find . \( -name '*.pyc' -o -path '*.git/*' -o -name '*.swp' -o -name '*.swo' \) -prune -o -type f -print` or, due to 'test file with spaces', you might try the following, but it may mess with your terminal find . \( -name '*.pyc' -o -path '*.git/*' -o -name '*.swp' -o -name '*.swo' \) -prune -o -type f -print0 | xargs -0 vim
About
default env stuff
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published